- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2023 11:26 PM
Hi All,
I have written a catalog client script to display asset information based on requested for field
It is working fine when I do a 'Try It' in catalog item , but not in service portal.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2023 12:07 AM
@Priyanka145 Try the below script to clear if the user doesn't have any asset attached in alm_hardware table.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var rfor = g_form.getValue('requested_for');
var grd = new GlideRecord('alm_hardware');
grd.addQuery('assigned_to', rfor);
grd.query(setAssetInfo);
function setAssetInfo(grd) {
if (grd.next()) {
var asset = grd.asset_tag;
g_form.setValue('device_information', asset);
}else{
g_form.setValue('device_information', "");
}
}
}
Can you please mark my answers helpful and accept as a solution if it helped 👍✔️
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2023 12:07 AM
@Priyanka145 Try the below script to clear if the user doesn't have any asset attached in alm_hardware table.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var rfor = g_form.getValue('requested_for');
var grd = new GlideRecord('alm_hardware');
grd.addQuery('assigned_to', rfor);
grd.query(setAssetInfo);
function setAssetInfo(grd) {
if (grd.next()) {
var asset = grd.asset_tag;
g_form.setValue('device_information', asset);
}else{
g_form.setValue('device_information', "");
}
}
}
Can you please mark my answers helpful and accept as a solution if it helped 👍✔️
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2023 12:49 AM
@Priyanka145 Can you please also mark my answers helpful as it helped you 👍
Anvesh