The CreatorCon Call for Content is officially open! Get started here.

How to set a string value field on one table same as a reference value field on another table?

Suchismita
Tera Contributor

Hello,

Can anyone help me with the logic to set a string value field on one table same as a reference value field on another table?

Scenerio:

I have two fields: 'assigned to' is a reference field in one table & 'Ops lead' is a string field in another table.

'Ops lead' need to be same as 'assigned to' and if assigned to is changed, the other needs to replicate.

 

Any assistance would be extremely helpful and appreciated.

I am self taught scripter so I'm novice.

 

Thank You

1 ACCEPTED SOLUTION

@Suchismita 

 

try below script:

var gr = new GlideRecord("SECOND_TABLE_NAME");

gr.addQuery("sys_id", current.getValue(("NUBMER_FIELD_BACKEND_NAME"));

gr.query();

if(gr.next()){

gr.OPS_LEAD_FIELD_NAME = current.getDisplayValue("ASSIGNED_TO_FIELD_NAME");

gr.update();

}

 

Note: update field names in above script as in your table.

 

Thank you,

Ali

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

View solution in original post

6 REPLIES 6

Ahmmed Ali
Mega Sage
Mega Sage

Hello @Suchismita 

 

Write after update business rule on table where assigned to field exists. update condition as assigned_to changes write the script as below:

 

var gr = new GlideRecord("SECOND_TABLE_NAME");

//add query to get the particular record you want to update here

gr.query();

if(gr.next()){

gr.OPS_LEAD_FIELD_NAME = current.getDisplayValue("ASSIGNED_TO_FIELD_NAME");

gr.update();

}

 

Note: add relevant query in above script.

 

OR let me know how both tables are related.

 

Thank you,

Ali

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

@Ahmmed Alican you please help me with the query?

Hello @Suchismita 

 

How is the second table linked to first table? is there any reference field in first table referring to second table. Then whenever assigned to in first table changes, the record selected in that reference field Ops lead field should be changed to new value. If yes, then let me know the field name of that reference field.

 

else explain how those are related and then we can build query.

 

Thank you,

Ali

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

@Ahmmed Ali 

 

There is another reference field ( Number) in 'assigned to' field's table which shows the second ( ops lead) table.

 

Both 'assigned to' and 'ops lead' are reference fields having the same values but in two different tables.

 

Is it enough to get the relevant query ?

 

Thank You,

Suchismita