Field value change automatically

SAM321
Tera Contributor

Hi all, so i have a requiremnt to change the field value automatically and auto save.

(ie).. There is two custom tables Table A and Table B , 

Table A have field 'phase'(choice type) and Table B have field 'state'.(choice type)

when Table B field state is changed to 'work in progress' and saved, Table A field phase should change automatically to stock request (choice) and form  get auto saved. how to achieve this.

1 ACCEPTED SOLUTION

@SAM321 
1] Now your BR will be on Table B. (After Update) and Condition as State Changes to Work in Progress.

2] In script part: 

 

(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
 
var procNumber = current.procurement_number; //Here,give your 'procurement number' field bakend name.
   
 var gr = new GlideRecord("Table_A"); // Give your Table A name
 gr.addQuery('sys_id', procNumber);
 gr.query();
 if (gr.next()) {  
  gr.phase = "stock_request";  // Give your Phave filed backend name and its choice 'Stock request' value
  gr.update();
    }

})(current, previous);

 

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

Thank you

 

View solution in original post

11 REPLIES 11

@Sonu Parab its working... but when i change the choice to previous value in Table B... It is not getting reflected in Table A

Hi @SAM321 ,
--> I think it is because of Condition as State Changes to Work in Progress.

--> So your BR will run only when you change the State to 'Work In Progress'.

-->I will suggest, You can set the condition according to your requirement.


e.g.
--> If you want to run your BR only when State changes to Work in progress then set condition as State Changes to Work in Progress.
OR If you want to run your BR only when State changes to any other state then use OR block to set condition .

OR if you want to run your BR every time when State field change the you can add only one condition as 'State Changes'

 

Hope this helps you!

Please mark this as correct answer if it helped in achieving the required outcome.

Thank you