The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Need to call a workflow from the business rule and send the values to the workflow , so that i can use that values in wf.

Sreekar ML
Tera Contributor

- i have created a work flow and that needs to be triggered from the business rule and need to pass values to the workflow and need to fetch that values and display in the workflow ,

i tried many ways i'm able to trigger the workflow , but not able to fetch the values that are being passed from the business rule .

-------

code that i'm using for calling a workflow is ---

var w = new Workflow();
var vars = {"name":"shankar","age":25};
w.startFlow('f2732b8adba633003cea0181ca9619d0', ' ', 'workflow name', vars);

 

----------

inside the workflow [ Run Script ] i'm using the below code to fetch the values , please help

gs.log("username is -"+ workflow.variables.name);

 

please check the code and provide solution. 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Sreek,

have you configured the workflow input variables in the workflow and it should work

https://docs.servicenow.com/bundle/helsinki-servicenow-platform/page/administer/using-workflows/task/t_WorkflowInputVariables.html

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Sreek,

have you configured the workflow input variables in the workflow and it should work

https://docs.servicenow.com/bundle/helsinki-servicenow-platform/page/administer/using-workflows/task/t_WorkflowInputVariables.html

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Ankur ,Thank for the answer ,

yes , i have used the input variable in the workflow ,

but while passing the value from the business rule i have not used the same id of the input variable.  

after using the same id of the input variable that i have created , it is working fine . 

 

before modification 

var w = new Workflow();
var vars = {"name":"shankar"};    
w.startFlow('f2732b8adba633003cea0181ca9619d0', ' ', 'workflow name', vars);

in place of 'name' i have provided the input variable id 'u_name'

 

after modification 

var w = new Workflow();
var vars = {"u_name":"shankar"};   //  here i have modified 
w.startFlow('f2732b8adba633003cea0181ca9619d0', ' ', 'workflow name', vars);

 

added the logs in workflow runscript ...

gs.log("username is -"+ workflow.variables.u_name);

 

working as expected ..