Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
nigel987
Creator II
Creator II

Load User Defined Function from Script

Hi,

I have a user defined function called GetPayLoad, which I defined in Tools -> Edit Module.

function GetPayLoad(jsonString, fieldName) {

  if (jsonString) {

  var json = eval('('+jsonString+')');

  if (json.hasOwnProperty(fieldName)) {

  return json[fieldName];

  }

  }  

  return null;

}

It works as expected.


Now I would like to export it to a text file so that I can reuse it in other applications. Therefore I exported the function to a txt file, inserted an include command in the script and tried to use the function during load.


RemoteTable:

LOAD

    ad_uuid,

    GetPayLoad(payload_json, 'fromMail') AS fromMail;

SQL SELECT

    ad_uuid,

    toJson(payload) AS payload_json

FROM ...;


Now I get the error

Unknown statement

function GetPayLoad(jsonString, fieldName) {

  if (jsonString) {

  var json = eval('('+jsonString+')')

Can anyone help me with that? Do I need to call the function separately somehow?

Thanks! Nihal

1 Reply
avinashelite

As per my knowledge the Macro code has to be in the Macro edit window

Qlikview edit script has the ability to call the function but you cannot have the macro code in the QV edit script

Paste the code in the macro editor and then try