Contents

Popular

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The Script Call Out policy lets you add custom JavaScript codes and Python codes that execute within the context of an API proxy flow.

This policy allows you to add or replace/modify/change the Payload and Context Variables. This policy can manage the function of Assign Variables, allowing to configure multiple context variables in the script.

Example

A basic script is provided each for javascript and python in the API UI itself (as seen in the above figure), which acts as a template. Following are the sample scripts available in the Script editor section.

Code Block
titleJavaScript
languagejs
 // function definition
   function myFunction() {
    message.payload = '<Modified Payload >'; 
    message.contextVariable.'<context variable name>' = '<value of modified context variable>'; 
  }
    // function invocation
    myFunction();
Code Block
titlePython
languagepy
 def myFunction():
          if(message.has_key('payload')):
             message['payload'] ='<modified payload >'
        
          if(message['contextVariable'].has_key('<context variable name>')):
            message['contextVariable']['<context variable name>'] = '<Value of context variable>'
          return message;
Adaptavist ThemeBuilder EngineAtlassian Confluence