Workflow notification. How to use variables from script to email body?

Elena7
Tera Expert

Hello,

 

We got a workflow (table = sc_req_item) with a notification activity in it.

From the script of this Notification activity, i need to Gliderecord to the approvals table to get 2 values from 2 fields.

 

My question is, how to use values from script to the message of the Notification ?

 

I tried below with the reqBy variable but nothing appear.

 

Elena7_2-1686844134218.png

 

 

Elena7_1-1686843889020.png

 

Result 

Elena7_3-1686844220134.png

 

Thanks,

 

 

1 ACCEPTED SOLUTION

Have you tried the following:

 

${workflow.scratchpad.positionTest}

 

 

I know you could create a new notification in the system and pass the scratchpad in the parm fields in the EventQueue to send the data within the email, but try the above first.

 


Please mark this response as correct and/or helpful if it assisted you with your question.
Steven

View solution in original post

6 REPLIES 6

Tony Chatfield1
Kilo Patron

Hi, not sure if I have understood your requirement correctly, but based on this doc

Using variables in Notify workflow activities (servicenow.com)

I think you would need to update your script to create your new variables as scratchpad variables.

Using variables in a workflow (servicenow.com)

These should then be available to consume in your notification. 

 

Hi Tony,

 

i tried to pass data from scratchpad but it seems im doing it wrong.

I am trying to pass data from Run script activity to Notification activity.

Elena7_0-1686932995143.png

 

Run script :

var getAppFields = new GlideRecord("sysapproval_approver");
getAppFields.addEncodedQuery('state=approved^wf_activity.name=Approval facility managers^sysapproval.sys_id=' + current.sys_id);
getAppFields.query();
while (getAppFields.next()) {
	var pos = getAppFields.u_sdm_position.getDisplayValue();
	var prof = getAppFields.u_sdm_profile.getDisplayValue();

}

workflow.scratchpad.positionTest = pos;
workflow.scratchpad.profilTest = prof;

 

 

Notification Message :

 

Elena7_1-1686933161230.png

 

Any advicehow to make it work ?

 

Thanks,

 

Have you tried the following:

 

${workflow.scratchpad.positionTest}

 

 

I know you could create a new notification in the system and pass the scratchpad in the parm fields in the EventQueue to send the data within the email, but try the above first.

 


Please mark this response as correct and/or helpful if it assisted you with your question.
Steven

It works now!

Thank you very much @Steven Parker .