Using workflow.scratchpad.<variable> in script Include

SHA3
Giga Expert

Hi Experts,

Is it possible to use output of a run script activity from workflow in workflow.scratchpad.<var> in script include and then use it in UI Action to control its visibility.

Ask here is. In UI Action condition: Script Include will be called and based workflow.scratchpad.<var> the visibility of the UI Action to be controlled.

Appreciate your responses.

1 ACCEPTED SOLUTION

Harsh Vardhan
Giga Patron

Hi Shilpa,



please check the below thread.


Accessing the Workflow Scratchpad from Business Rules - ServiceNow Wiki



Simply you can retrieve it in your script include function.



Also refer the below link.



Workflow Scratchpad Tip | SN Commander



Thanks,


Harshvardhan


View solution in original post

2 REPLIES 2

Harsh Vardhan
Giga Patron

Hi Shilpa,



please check the below thread.


Accessing the Workflow Scratchpad from Business Rules - ServiceNow Wiki



Simply you can retrieve it in your script include function.



Also refer the below link.



Workflow Scratchpad Tip | SN Commander



Thanks,


Harshvardhan


Hi Harsh,



I have already tried this. I am getting Undefined as the result when i try to print it in gs.log.


Below is my function in script include:


checkworkflow: function() {


  //get the workflow script include helper


  var msg = '';


  var workflow = new Workflow();


  //get the requested items workflow context


  //this will get all contexts so you'll need to get the proper one if you have multiple workflows for a record


  var context = workflow.getContexts(current);


  //make sure we have a valid context


  if (context.next()) {


  //get a value from the scratchpad


  msg = context.scratchpad.important_msg;


  //msg now equals "scratch me", that was set in the run script activity


  gs.log("Message equals = "+ msg +' '+current.number);


  }




Log output looks like : Hello World undefined RITM0010049