Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Trying to access variable value from workflow to script include

ak48
Tera Contributor

Hi,

I have a script include and there is a value stored in the variable and I have to access that value from workflow run script then how can I access that value? Please help me on this 

Thanks

1 ACCEPTED SOLUTION

Try this

var myScript = {  //myScript - script include name
  getValue: function() {
var abc = gef[1];
    return abc;
  }
};

// In your workflow script
var myIncludedScript = gs.include('myScript');
var value = myIncludedScript.getValue();
gs.info(value); 

View solution in original post

10 REPLIES 10

Sai Kumar B
Mega Sage

@ak48 

If your workflow is on RITM table, you can access variables as below

var variable1 = current.variables.variable_name;

//Pass the above variable as a parameter to script include function

var passVariable = new scriptIncludName().functin(variable1);

 

ak48
Tera Contributor

In script include there is variable

var abc = gef[1];

var x = function (){

return abc;

};

 

In workflow run script

var def = new script_include().x();

I am trying it but not achieved results 

 

 

Try this

var myScript = {  //myScript - script include name
  getValue: function() {
var abc = gef[1];
    return abc;
  }
};

// In your workflow script
var myIncludedScript = gs.include('myScript');
var value = myIncludedScript.getValue();
gs.info(value); 

ak48
Tera Contributor

Awesome it's working now