Help with a Business Rule across multiple tables

Wendy Peterson
Giga Guru

I need some help with a BR. I've tried everything I can think of to get it to work. I tried to do it with the Set Values in the BR with no luck.

Record Producer to Open a Request on Table "sn_sm_legal_request" - Then it creates a Task on table "sn_sm_legal_task" - The group that gets it needs to complete a question called CPA approved with a value of yes or no "u_cpa_approved" - There is a Question that needs to be set on Request Table "sn_sm_legal_request" with the same value.

So on Task answer Question and when that task is closed it updates the Request- Both values are same u_cpa_approved

Any ideas? - Thanks so much... I've been working at this for hours.

1 ACCEPTED SOLUTION

I understand. They have the same name, but they are on two different tables. That's not an issue at the database layer.



The line in my script (updated per your screenshots) does the work of copying the value from task's field to the requst's field.



req.u_cpa_approved = current.u_cpa_approved;


View solution in original post

12 REPLIES 12

Create an AFTER business rule on the task table something like this.


note, this is not meant to be a copy/paste solution - review an update accordingly. I don't know the parent field that links the request to the task as I don't have that plugin activated currently.



Name: Update parent CPA Approval


Table: sn_sm_legal_task


Advanced: true


Insert: true


Update: true


When to run: After


Condition: CPA Approval | changes


Script:


(function executeRule(current, previous /*null when async*/) {



  var req = new GlideRecord('sn_sm_legal_request');


  if (req.get(current.parent)) {


  req.u_cpa_approval = current.u_cpa_approval;


  req.update();


  }



})(current, previous);


I tried that and nope no luck. Do you think it's cause I named the field the same thing and maybe I should have named it something else? I just figured it would be easier having it the same



2016-09-13_15-26-08.png




2016-09-13_15-26-37.png


Thanks for the screenshots! Big help!!!



It can be named the same thing. No issue there. They are two different fields on two different tables.



I believe I called it 'u_cpa_approval' in my script. Did you change that to 'u_cpa_approved'?


No fields are the same



2016-09-13_15-44-13.png



2016-09-13_15-45-09.png


I understand. They have the same name, but they are on two different tables. That's not an issue at the database layer.



The line in my script (updated per your screenshots) does the work of copying the value from task's field to the requst's field.



req.u_cpa_approved = current.u_cpa_approved;