Create Record from one table to another table based on field values.

Kiara3
Kilo Contributor

Hello Experts,

I am trying to trigger a record creation on Table B based on certain conditions on Table A via a Business Rule.

Written an AFTER (Insert , Update) Business Rule on Table : sn_audit_control_test

When : State = Closed Complete & Control Effectiveness = Ineffective

Below is the script :

(function executeRule(current, previous /*null when async*/) {
    
    var desc = current.short_description;
    var num = current.sys_id;
    var eng = current.parent.sys_id;
    
    var obsv = new GlideRecord('sn_audit_advanced_observation');
    
    obsv.initialize();
    
    obsv.short_description = desc;
    
    obsv.audit_task = num;
    
    obsv.engagement = eng;
     
    obsv.insert();
    gs.addInfoMessage(obsv.number + " ticket is created");
    
})(current, previous);

 

Went to the Control Test Form

Made these changes : State = Closed Complete & Control Effectiveness = Ineffective

Saved the Record. --> An Observation record got generated and displayed in the Related List on the Control Test Form.

But, when i did the same thing with another Control Record, i noticed no new Observation record was generated. I tried this with multiple Control Records, but nothing happened.

 

Can someone please help me with this requirement.

 

ThankYou !

 

1 ACCEPTED SOLUTION

Place an info message in the beginning of BR, check if that is printing or not.


Thanks and Regards,

Saurabh Gupta

View solution in original post

6 REPLIES 6

Saurabh Gupta
Kilo Patron
Kilo Patron

Can please explain better this "when i did the same thing with another Control Record"


Thanks and Regards,

Saurabh Gupta

Hi Saurabh,

I meant, when i repeated below process for more control test records :

- Went to the Control Test Form

- Made these changes : State = Closed Complete & Control Effectiveness = Ineffective

- Saved the Record.

I was expecting records to generate on the Observation's table as per the Business Rule, but it did not happen.

Regards

Place an info message in the beginning of BR, check if that is printing or not.


Thanks and Regards,

Saurabh Gupta

Okay. I did that. Added "hello" info message.

And surprisingly, this time i made changes to 3 Control Test Forms and all of them created an Observation record respectively.

Just wondering, why the inconsistency !!

By just adding an Info Message, it is working !!

 

PFA