UI Action link to 2 tables

mp_10
Tera Contributor

Hi,

I have a bit complicated scenario. Can someone please guide me.

There are 3 custom tables.

1. Tracker:- contains tracking details of a particular shipment

2.Supply:- contains supply details that is coming on the shipment

3.inventory: contains all the asset details

 

I have a UI action 'Approve' on 'tracker' table. Also I have a relationship created with 'tracker' table and 'supply' table. 

So If Approver click on UI action the records in Supply table that are related with Tracker table should get inserted to 'inventory' table with status 'in stock'.

 

Please guide me

1 ACCEPTED SOLUTION

Harshal Aditya
Mega Sage
Mega Sage

Hi @mp_10 ,

 

Hope you are doing well.

 

Please refer to the script below for your requirement.

 

var getSupply = new GlideRecord("your supply table");
getSupply.addQuery("your field name",current.sys_id);
getSupply.query();
while(getSupply.next()){
    var createInventory = new GlideRecord("your inventory table");
    createInventory.initialize();
    createInventory.status = "in-stock"
    // do the remaining mapping
    createInventory.insert();
}

 

You would need to adjust the script for your requirement.

Please Mark My Response as Correct/Helpful based on the Impact

Regards,
Harshal

View solution in original post

2 REPLIES 2

Harshal Aditya
Mega Sage
Mega Sage

Hi @mp_10 ,

 

Hope you are doing well.

 

Please refer to the script below for your requirement.

 

var getSupply = new GlideRecord("your supply table");
getSupply.addQuery("your field name",current.sys_id);
getSupply.query();
while(getSupply.next()){
    var createInventory = new GlideRecord("your inventory table");
    createInventory.initialize();
    createInventory.status = "in-stock"
    // do the remaining mapping
    createInventory.insert();
}

 

You would need to adjust the script for your requirement.

Please Mark My Response as Correct/Helpful based on the Impact

Regards,
Harshal

Hi Harshal,

 

Thank you so much. This solution worked and I could insert record. 

I have another question too.. My inventory table fields are choice(dropdown). So while inserting details from supply table new values are getting created. I am attaching the screenshot for your reference. Is there any way to correct this?

All the dropdown fields in inventory table populated similarly with extra options taken from supply table. I have entered the same Label names to supply table. (New values didn't create when I gave values instead of labels, but can not go with that option)

Thank you so much for you time and inputs..