- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
Hi @Ankur Bawiskar ,
I've created two catalog items: one for new software requests and another for existing software. When a request is made for software that's already approved, a link to the approved software appears at the top of the new software request. Clicking the link should take me to the existing software catalog request. The script works as expected and I've shared it for reference. What I need now is, when clicking the link, to navigate from the new software request to the approved software request, and have the software name automatically populated in the software title field of the existing software request. How can I achieve this?
Catalog Client Script: Existing Softare Catalog(Onchange)
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
var absAjax = new GlideAjax('CheckExistingBARecord');
absAjax.addParam('sysparm_name', 'CheckExistingBARecord'); // Match method name exactly
absAjax.addParam('sysparm_appName', newValue);
absAjax.getXML(function(response) {
var result = response.responseXML.documentElement.getAttribute("answer");
result = JSON.parse(result); // Parse the JSON string
if (result.exists === true) {
var links = result.nameArr.map(function(newValue) {
var softwareTitle = encodeURIComponent(newValue);
var dynamicUrl = '/com.glideapp.servicecatalog_cat_item_view.do?v=1&sysparm_id=f9e209223b18ae10dc52da34c3e45a6a&sysparm_name=' + softwareTitle;
return '<a href="' + dynamicUrl + '" target="_blank">' + ' ' + newValue + '</a>';
});
var msg = " Existing Software's with similar name: " + result.nameArr.join(', ') + ".";
g_form.showFieldMsg('software_title', msg, 'error');
if (result.nameArr.length > 0) {
g_form.setValue('select_software', result.nameArr[0]);
}
if (g_form.getTableName() !== 'sc_task') {
g_form.addErrorMessage('Navigate to' + '' + links);
} else {
g_form.hideFieldMsg('software_title', true);
}
}
});
}
Script Include:
Existing software: I need PingID to be automatically populated when I click the link.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
I shared working solution some months ago here
need help in auto populating catalog item 1 variable values in to catalog item 2 variables
pass the variable value in the URL and then write onLoad catalog client script on another catalog item to grab, extract and auto populate
1) update your existing onChange to include software sysId, use this updated list
2) then onLoad catalog client script on other catalog item to grab
function onLoad() {
try {
var url = top.location.href;
if (window == null) {
// for portal
var software = new URLSearchParams(url).get("sysparm_softwaresysId");
g_form.setValue('softwareVariable', software);
}
} catch (ex) {
// for native
var gUrl = new GlideURL();
gUrl.setFromCurrent();
var software1 = gUrl.getParam("sysparm_softwaresysId");
g_form.setValue('softwareVariable', software1);
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
Hi @Abbas_Ahamed
Refer to the following community response, which explains how to populate catalog form values by passing parameters through the URL.
https://www.servicenow.com/community/secops-forum/need-help-in-auto-populating-catalog-item-1-variab...
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
I shared working solution some months ago here
need help in auto populating catalog item 1 variable values in to catalog item 2 variables
pass the variable value in the URL and then write onLoad catalog client script on another catalog item to grab, extract and auto populate
1) update your existing onChange to include software sysId, use this updated list
2) then onLoad catalog client script on other catalog item to grab
function onLoad() {
try {
var url = top.location.href;
if (window == null) {
// for portal
var software = new URLSearchParams(url).get("sysparm_softwaresysId");
g_form.setValue('softwareVariable', software);
}
} catch (ex) {
// for native
var gUrl = new GlideURL();
gUrl.setFromCurrent();
var software1 = gUrl.getParam("sysparm_softwaresysId");
g_form.setValue('softwareVariable', software1);
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader