- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I would like to copy the field information from the following record form to the catalog item input form:
An important requirement is that the catalog item entry form must be displayed in the platform content frame, not in a separate tab or window.
1. Pass the record's sys_ID to the URL in the UI action.
2. After receiving the sys_ID from the URL in the catalog item's client script, call the script include using Ajax.
3. Use the sys_ID in the script include to identify the record and retrieve field information.
4. Set the value received from the script include in the catalog item's field.
I thought I could copy it this way, but I realized that the sys_ID is not set in the URL at step 2.
Does anyone know a better way to do this?
Unfortunately, I can't share the script.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @bonsai
Use this sample ui action and Catalog client script:
function copyToCatalog() {
var sysId = g_form.getUniqueValue();
var caller = g_form.getValue('caller_id');
var catItemSysId = '218151833710100054b6a3549dcf5d6f'; // replace with your catalog sys_id
var url = 'com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=' + catItemSysId;
// 3. Append data as parameters if you need
url += '&sysparm_caller=' + encodeURIComponent(caller);
url += '&sysparm_source_id=' + encodeURIComponent(sysId);
gs.setRedirect(url);
}
Catalog Client Script:
function onLoad() {
var sys_id = getParmVal('sysparm_source_id');
var caller = getParmVal('sysparm_caller');
//put your logic after getting value
alert(sys_id);
alert(caller)
function getParmVal(name){
var url = document.URL.parseQuery();
if(url[name]){
return decodeURI(url[name]);
} else {
return;
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
you can have a UI action on that custom table which opens that catalog item
But it will open in native view only and won't open portal
what's the business requirement here?
Why not take them to portal on click of button on form and auto populate the variables?
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @bonsai
Use this sample ui action and Catalog client script:
function copyToCatalog() {
var sysId = g_form.getUniqueValue();
var caller = g_form.getValue('caller_id');
var catItemSysId = '218151833710100054b6a3549dcf5d6f'; // replace with your catalog sys_id
var url = 'com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=' + catItemSysId;
// 3. Append data as parameters if you need
url += '&sysparm_caller=' + encodeURIComponent(caller);
url += '&sysparm_source_id=' + encodeURIComponent(sysId);
gs.setRedirect(url);
}
Catalog Client Script:
function onLoad() {
var sys_id = getParmVal('sysparm_source_id');
var caller = getParmVal('sysparm_caller');
//put your logic after getting value
alert(sys_id);
alert(caller)
function getParmVal(name){
var url = document.URL.parseQuery();
if(url[name]){
return decodeURI(url[name]);
} else {
return;
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
you can have a UI action on that custom table which opens that catalog item
But it will open in native view only and won't open portal
what's the business requirement here?
Why not take them to portal on click of button on form and auto populate the variables?
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
