Inbound Email Action Submits catalog request- i need to autopopulate a field before submission

Syed N
Tera Contributor

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.

1 ACCEPTED SOLUTION

@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

View solution in original post

19 REPLIES 19

Syed N
Tera Contributor

Is there a way to show all assets assigned to the user.

here we can have multiple assets.

 

ill try the above code now.

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

Syed N
Tera Contributor

That brought back the details but it brought back from what looks like every single asset - please see image below:

 

SyedN_0-1670932748522.png

 

@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

Syed N
Tera Contributor

@RaghavSh  Thank you so much for your help on this.

it did the trick