Automatically create new record for milestone on the Audit Engagement form related list

anmarkandey
Mega Guru

Hi All,

 

I am looking to implement one of the requirement.

 

For Audit Engagement application, whenever Engagement Lead/Audit Manager creates a new Engagement and submits that, I want to auto-create 6 records of milestones within related list on the form (instead of manually clicking 'New' every time) with basic mandatory data (for each of the stages such as scoping, validation, fieldwork etc. ). So that it becomes mandatory for the auditors to complete close those milestones.

 

Either business rule/client script which should be used to implement the above requirement and how ?

 

Any help to implement the above requirement is greatly appreciated.

Thank you.

1 ACCEPTED SOLUTION

anmarkandey
Mega Guru

Hi All,

 

Below is the solution that worked : 

 

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

    // Add your code here
    var gr = new GlideRecord('sn_audit_advanced_milestone');


    gr.addQuery('parent', current.sys_id); //reference field on related list table

    var milestones = ['Scoping', 'Planning', 'Fieldwork', 'Follow up', 'Reporting', 'Closure'];
    for (i = 0; i < 6; i++) {
        gr.query();


        gr.newRecord();


        gr.parent = current.sys_id;

        gr.milestone_type = i+1+'';

        gr.short_description = milestones[i]+' Milestone';


        gr.insert();
    }



})(current, previous);

View solution in original post

1 REPLY 1

anmarkandey
Mega Guru

Hi All,

 

Below is the solution that worked : 

 

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

    // Add your code here
    var gr = new GlideRecord('sn_audit_advanced_milestone');


    gr.addQuery('parent', current.sys_id); //reference field on related list table

    var milestones = ['Scoping', 'Planning', 'Fieldwork', 'Follow up', 'Reporting', 'Closure'];
    for (i = 0; i < 6; i++) {
        gr.query();


        gr.newRecord();


        gr.parent = current.sys_id;

        gr.milestone_type = i+1+'';

        gr.short_description = milestones[i]+' Milestone';


        gr.insert();
    }



})(current, previous);