want to update sys id value into the field

siva14
Tera Contributor

In the below screenshot , i want to update the sys id of category field value into unique field , can anyone help me how to update all data using background script.

#script #background script

 

siva14_0-1707759242906.png

 

2 REPLIES 2

Sumanth16
Kilo Patron

Hi, 

 

 

You can use business rule (or) client script to populate to pass Category sys_id to the Business Unit. 


background script:

var gr = new Gliderecord('your table name');
gr.addQuery('your query here');// use category is not empty

gr.query();

while(gr.next()){
gr.business_unit= gr.category.sys_id;

gr.setWorkflow(false);

gr.update();
}

 

(or) 

 

Client script:

 

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
  if (isLoading || newValue === '') {
    return;
  }

  var incSD = g_form.getReference('your category field name', populate);

  function populate(incSD) {
   
      g_form.setValue(your business unit fied name', incSD.sys_id);
      
    
  }

 

 

 Please mark it as helpful (or) correct if it helps.

 

Thanks & Regards,

Sumanth meda

AshishKM
Kilo Patron
Kilo Patron

Hi @siva14 , 

Can you share more technical details on this, the attached image has Category field editable, so you can update this on form. Is this category field is reference type and pointing to table ( which table ) or its select box pointing to Choice [ sys_choice ] or some form specific select box where values are stored in Question Choice [ question_choice ] table.

 

If there are more record and you want to update via backgroud code then write Fix Script.

 

-Thanks,

AshishKM


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution