- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2022 06:06 AM
Hi,
I have an Inbound email action that automatically populates variables on a catalog item and submits a sc_req_item.
on the catalog item there is an 'On Change' catalog client script which runs when a particular field 'Leaver Name' is populated, this then fetches a users asset information and displays it within a text field called 'Equipment Assigned' - Please see catalog script below:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if(newValue == '')
g_form.clearValue('leaver_name'); // give correct variable name here
if(oldValue != newValue){
var ga = new GlideAjax('GetAssetTags');
ga.addParam('sysparm_name', "getDetails");
ga.addParam('sysparm_userID', newValue);
ga.getXMLAnswer(function(answer){
if(answer != ''){
g_form.setValue('equipment_assigned', answer); // give correct variable name here
}
});
}
//Type appropriate comment here, and begin script below
}
I know that this can only be run on the catalog form itself, however is there a way to automatically run during the inbound email action process.
so in theory what I want to achieve is the following:
1. inbound email action runs
2. all variables are filled including the leaver name
3. the client script on change runs automatically when the requested item is created populating the 'Equipment Assigned' field.
do I need to use a business rule or an onSubmit catalog client script instead.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2022 04:09 AM - edited 12-13-2022 04:10 AM
@Syed N there is a spelling mistake, correct it:
asset.addQuery('assigned_to',ln);
The above code has single s in assigned_to
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2022 02:56 AM
Is there a way to show all assets assigned to the user.
here we can have multiple assets.
ill try the above code now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2022 03:23 AM
yes, replace below line code to show all assets:
var asset_tag1='';
var asset = new GlideRecord('alm_asset');
asset.addQuery('asigned_to',ln);
asset.query();
while(asset.next())
{
asset_tag1 = asset.asset_tag + " - "+asset.display_name + " , "+asset_tag1;
}
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2022 03:59 AM
That brought back the details but it brought back from what looks like every single asset - please see image below:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2022 04:09 AM - edited 12-13-2022 04:10 AM
@Syed N there is a spelling mistake, correct it:
asset.addQuery('assigned_to',ln);
The above code has single s in assigned_to
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2022 04:40 AM
@RaghavSh Thank you so much for your help on this.
it did the trick