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

Hi Kiara,

It is nice your issue is solved.

If my answer replied your question please mark appropriate response as correct so that the question will appear as resolved for other users who may have a similar question in the future.

Regards,
Saurabh


Thanks and Regards,

Saurabh Gupta

Maybe the records are being created, it's just that it's not linked to the record so it's not appearing in the related list?

Check sn_audit_advanced_observation.list to verify that the record is being created.

Maybe it has to do with the current.parent from your script, maybe the parent field is not populated on the ones you tested with?