- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2023 10:53 PM
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2023 12:55 AM - edited 03-08-2023 12:57 AM
@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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2023 11:06 PM
Hi @SAM321 ,
1] To achieve above requirement you have to create one After Update Business Rule on the table B.
and in When to Run section add condition as State Change to Work In Progress'.
2] Then with the help of scripting fetch the record from Table A and set the field phase to stock request.
(To fetch the record of table A, there will be a one field which shows the relation between two table)
Let us know if you have any issue.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2023 11:14 PM
Also you can take help of below threads for scripting.
updating records of one table based on other
Business rule to update field on another table / GlideRecord help
OR could you please share Tables details or a field which is relate to table A to Table B.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2023 11:09 PM
@Sonu Parab can u provide related script, am new to scripting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2023 11:43 PM - edited 03-07-2023 11:45 PM
Hi @SAM321 , Here I have shown one example similar to your requirement, you can make changes accordingly.
1] Business rule on Table B. (My table B is Incident and Table A is Problem.
2] Script : Fetch record of Table A. (Here in my case Incident record is relate to the Problem record.)
So once I changed the state of Incident record then using script it will fetch the perticular Table A record and it will update the field from table A.
Thank you