First we built a UI action on the originating table where we were passing values from this table into the catalog item form. The script would grab the values we wanted to pass into the catalog item.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var instanceURL = gs.getProperty("glide.servlet.uri"); | |
//the sysparm_id below is the sys_id of the catalog item you want to order | |
var url = instanceURL + 'com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=299dbe0b0a0a3c4501c8951df102a2ae&manager_request=' + current.sys_id + '&manager_name=' + current.u_manager_name + '&start_date=' + current.u_start_date.getDisplayValue() + '&hr_comments=' + current.u_hr_comments; | |
action.setRedirectURL(url); |
Next we had to put an onLoad script into the catalog item to handle capturing the values and passing them into the correct variables in the catalog item.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function onLoad() { | |
g_form.setValue('manager_request', gup('manager_request')); | |
g_form.setValue('manager', gup('manager_name')); | |
g_form.setValue('start_date', decodeURI(gup('start_date'))); | |
g_form.setValue('hr_comments', decodeURI(gup('hr_comments'))); | |
} | |
function gup( name ) | |
{ | |
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); | |
var regexS = "[\\?&]"+name+"=([^&#]*)"; | |
var regex = new RegExp( regexS ); | |
var results = regex.exec( window.location.href ); | |
if( results == null ){ | |
return ""; | |
} | |
else{ | |
return results[1]; | |
} | |
} |
Thank you for sharing this article,it is will be helpful and very Unique..
ReplyDeleteKeep updating...
ServiceNow Training