- 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-12-2022 07:31 AM
So equipment assigned is dependent on the reference variable Leaver name.
once leaver name is populated there is a script include that runs which then fetches the alm_asset data of that leaver.
we can declare - cart.setVariable(item, 'equipment_assigned','');
but how will it work with the script include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2022 07:44 AM
We dont need script include in this case.
var ln = '';
var br = new GlideRecord('sys_user');
if (br.get('name', email.body.leaver_name)) {
ln = br.sys_id;
}
With above code we are getting leaver name in In.
After this you can glide alm_asset table based on "In".
Afer that you can set it using
cart.setVariable(item,'equipment_assigned','');
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2022 08:09 AM
Hi Raghav,
i have tried the above.
at present i am already getting the leaver name via the inbound action script.
i somehow need to be able to call the below in the script:
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2022 08:19 AM
@Syed N this code is client code, willnot work in inbound action.
You can directly fetch information from alm_ asset table by gliding it directly from inbound action.
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2022 11:25 AM
@RaghavSh are you able to assist here apoligies my coding skills are not great.