Using UI action to update multiple child records

chrisn_
Mega Guru

Hello everyone,

Thank you in advance for your interest and assistance! I am trying to create a UI action that will live on the project record that if clicked will update a custom field on it's associated cost plans. I am combing through existing UI actions for guidance, if anyone knows of any threads or has any suggestions on how I can best accomplish this I would be incredibly grateful.

14 REPLIES 14

Uncle Rob
Kilo Patron

Have you tried anything so far?

 

 

Uncle Rob
Kilo Patron

the script to udpate the child expense lines would look something like this...

 

var el = new GlideRecord('fm_expense_line');
el.addQuery('source_id',current.sys_id);
el.query();
while (el.next()){
   el.u_your_custom_field = 'whatever value you want';
   el.update();
}

Oleg
Mega Sage

You should use server side UI Action (Client is unchecked) with the code like

var gr = new GlideRecord("cost_plan");
gr.addQuery("task", current.getUniqueValue());
gr.setValue("u_customField",  "custom value");
gr.updateMultiple();

That's way better than mine 😞