Business rule to change state change of rm_story table

Balakrishna_ABK
Tera Guru

I want to change the state of rm_story table to ready whenever 'test result' changes to fail of rm_scrum_task table via business rule. i have made following changes but not working.

Balu4_0-1687266202216.pngBalu4_1-1687266248743.png

 

Suggest me better approach

2 ACCEPTED SOLUTIONS

@Balakrishna_ABK 

 

You can follow steps given in below video link to understand how to update parent record which is story record from child scrum task table

https://www.youtube.com/watch?v=LK5XnFFhH-A

View solution in original post

Ever had child records that needed to "promote" significant updates to a parent record? No more business rules. No more complicated code. In less than 15 min you can build it in #ServiceNow flow designer. This video will also teach you... - how to use Flow Variables - how to iterate through Field

Riya Verma
Kilo Sage
Kilo Sage

Hi @Balakrishna_ABK ,

 

Hope you are doing great.

  1. create a new business rule on "rm_scrum_task" table .
  2. Specify the conditions for the business rule to trigger. In this case, the condition should be: current.test_result.changesTo('fail').
  3. Add the script to perform the state change for the related "rm_story" record. You can use the GlideRecord API to update the "rm_story" table.

 

(function executeRule(current, previous) {
   var storyGR = new GlideRecord('rm_story');
   storyGR.addQuery('sys_id', current.rm_story); // Assuming a reference field "rm_story" links the two tables
   storyGR.query();
   if (storyGR.next()) {
      storyGR.state = 'ready';
      storyGR.update();
   }
})(current, previous);
​

 

Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma

View solution in original post

4 REPLIES 4

Manmohan K
Tera Sage

Hi @Balakrishna_ABK 

 

Create a After business rule instead of before and add below script in Business rule (Modify and add correct backend value of ready state)

 

var story = new GlideRecord('rm_story');

    if (story.get(current.rm_story)) {

      story.state = 'ready';    //add backend value of ready state

      story.update();
    }

 

Hi Manmohan thanks for your reply, how can we achieve same from flow designer ?

@Balakrishna_ABK 

 

You can follow steps given in below video link to understand how to update parent record which is story record from child scrum task table

https://www.youtube.com/watch?v=LK5XnFFhH-A

Ever had child records that needed to "promote" significant updates to a parent record? No more business rules. No more complicated code. In less than 15 min you can build it in #ServiceNow flow designer. This video will also teach you... - how to use Flow Variables - how to iterate through Field

Riya Verma
Kilo Sage
Kilo Sage

Hi @Balakrishna_ABK ,

 

Hope you are doing great.

  1. create a new business rule on "rm_scrum_task" table .
  2. Specify the conditions for the business rule to trigger. In this case, the condition should be: current.test_result.changesTo('fail').
  3. Add the script to perform the state change for the related "rm_story" record. You can use the GlideRecord API to update the "rm_story" table.

 

(function executeRule(current, previous) {
   var storyGR = new GlideRecord('rm_story');
   storyGR.addQuery('sys_id', current.rm_story); // Assuming a reference field "rm_story" links the two tables
   storyGR.query();
   if (storyGR.next()) {
      storyGR.state = 'ready';
      storyGR.update();
   }
})(current, previous);
​

 

Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma