How to pass values from UI action to script include?

prasannakumard
Tera Guru

Hi Team,

Actually, I want to send a notification to selected Approvers in change request under Approver relate list. 

I got approvers by using var sysId = g_list.getChecked()

g_list is client side script in UI action, due to this I want to send this value to Server side and by using gs.evenQueue, sending notifications to selected users.

I'm using the following script to send values from UI action to script include.

UI Action:

function sendServerEmail(){
var sysId = g_list.getChecked().split(","); 
var ga = new GlideAjax('ChangeRequestFunctions');
ga.addParam('sysparm_name', 'sendApproverEmail');
ga.addParam('sysparm_approver_id', sysId.join(','));
action.setRedirectURL(current);
}

Script Include:

sendApproverEmail: function(){
var finApp = this.getParameter('sysparm_approver_id');
var sysIds = finApp.split(",");
gs.log('@@@@@@@Sy_ID: '+sysIds+' '+finApp);
},

Here in the above log I can't able to get any value

Please suggest any another approach or ant valuable suggestion to complete this requirement.

Thanks & Regards,

Prasanna

2 REPLIES 2

Brian McMinn2
Mega Guru

I think your best approach would be to include your script include in your UI Policy in the on and off conditions of that script include. I would not think it is best practice the other way around. Script Includes are more flexible around the scripting platforms of the platform.

 

Thanks,

Brian McMinn

 

Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

Hi,

Why would the user need to click on a UI Action for this? What's the requirement for this? Since I would rather put this into the workflow/flow for the change or perhaps in a async BR to handle it without the user having to do something.

//Göran
Feel free to connect with me:
LinkedIn & Twitter
Subscribe to my YouTube Channel
Buy The Witch Doctor's Guide To ServiceNow