How to pass current.sys_id(Dynamic sys_id value) in the url from business rule

vijayraja
Kilo Explorer

Hi Friends,

I have business rule on update on change rquest,which checks for the check box selected.If check box is selected, it will throw error message with hyperlink.

This hyperlink redirects to some catalog item form.Here i want to set catalog variable with change number.

When i pass current.sys_id in the url which is not working.

I checked in community as well, there they have pass hardcoded sys_id which is working for me but setting dymanic is not working.

Url in the business rule of change request table.

var url = 'com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=e826b8c50a0a3c1e019410bb1031d102&sysparm_change= current.sys_id

 

Here sysparm_id is the sys id of the catalog item which i want to redirect if user clicks on hyperlink

 

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Vijay,

I assume since you are transferring the change request sys_id and change request number you must be having some onload client script to fetch value from URL and set it in the variable

var url = 'com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=e826b8c50a0a3c1e019410bb1031d102&sysparm_change=' + current.sys_id + '&sysparm_changeNumber=' + current.number;

below is the onload catalog client script which would help you get the change number and set to variable

function onLoad(){

var url = top.location.href;
var changeNumber = new URLSearchParams(url).get("sysparm_changeNumber");

g_form.setValue('variableName',changeNumber);

}

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

4 REPLIES 4

Sagar Pagar
Tera Patron

Try this,

var sys_id = current.sys_id;
var url = 'com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=e826b8c50a0a3c1e019410bb1031d102&sysparm_change='+sys_id;

The world works with ServiceNow

Jaspal Singh
Mega Patron
Mega Patron

Hi Vijay,

 

You can try below.

 

var changeis=current.sys_id;//stores sys_id in variable changeis
var url = 'com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=e826b8c50a0a3c1e019410bb1031d102&sysparm_change='+changeis;

Just make sure change field on the form where you want to set the Change value is reference field else it will set sys_id of the change.

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Vijay,

I assume since you are transferring the change request sys_id and change request number you must be having some onload client script to fetch value from URL and set it in the variable

var url = 'com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=e826b8c50a0a3c1e019410bb1031d102&sysparm_change=' + current.sys_id + '&sysparm_changeNumber=' + current.number;

below is the onload catalog client script which would help you get the change number and set to variable

function onLoad(){

var url = top.location.href;
var changeNumber = new URLSearchParams(url).get("sysparm_changeNumber");

g_form.setValue('variableName',changeNumber);

}

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

Thanks @Ankur Bawiskar for the reply.It worked.