Need to update Location and Account details if Site ID inserts a value thru data load

Sarah Bouil
Tera Expert

I am loading data into Hardware Asset, if Site ID inserts value then respective Location Name and Account details should be updated. The Location Name and Account details are present in cmn_location table.

 

For Ex: In cmn_location, Location Name: New Jersey and Account: Contract(its a reference field) for the Site ID: 50353 then if we load the data in Hardware Asset, and if the Site ID: 50353 is the Location in Harware Asset should be 'New Jersey' and Account in Hardware should be 'Contract'

4 REPLIES 4

SanjivMeher
Kilo Patron
Kilo Patron

If you have a transform map, make Side ID as coalesce and it should work.


Please mark this response as correct or helpful if it assisted you with your question.

Sarah Bouil
Tera Expert

We have a Serial Number is the 'Coalesce' and also I need to update Location and Account details if Site ID changes, need to do with the Business Rules. Kindly help.

You need to create an onBefore Insert/update Business rule with condition Site ID changes

And in the script

var lc = new GlideRecord('cmn_location');

lc.addQuery('<site id field in location table>',current.<siteid field name>);

lc.query();

 

if (lc.next())

{

current.<account details field name> = lc.<account details field name in location>;

current.<location field name> = lc.<location field name in location>;

}


Please mark this response as correct or helpful if it assisted you with your question.

Sarah Bouil
Tera Expert

I have written the script but Location field is setting to empty after saving the form.

 

Also I noticed the Location field is auto populating thru onChange client script.

 

But both Location(should not set it to empty after saving the form) and Account details should be updated.