Checking record is New

Harshal_Patil
Tera Contributor

Got a new requirement. To check whether record is New, if New then push to another form. Here  what i am trying ... can anyone help me here. 

 

function executeRule(current, previous /*null when async*/)
{
    if (current.isNewRecord()){
        var inc = new GlideRecord('u_incident_temp');
        gs.info('This is a new incident: ' + current.number);
    inc.initialize();
    inc.u_inc_number = current.number;
    inc.u_short_description = current.short_description;
    inc.insert();
    }
})(current, previous);

 

1 REPLY 1

Sai Shravan
Mega Sage

Hello @Harshal_Patil , 

 

Can you give a try with the below script 

 

function executeRule(current, previous /*null when async*/) {
    if (current.isNewRecord()) {
        var inc = new GlideRecord('u_incident_temp');
        gs.info('This is a new incident: ' + current.number);
        inc.initialize();
        inc.u_inc_number = current.number;
        inc.u_short_description = current.short_description;
        var newIncidentTemp = inc.insert();
        
        if (newIncidentTemp) {
            gs.info('New incident record inserted into u_incident_temp with Sys ID: ' + newIncidentTemp);
        } else {
            gs.error('Failed to insert new incident record into u_incident_temp');
        }
    }
}

 

 

Please mark this as correct and helpful, if it works for you.

 

 

Regards,
Shravan
Please mark this as helpful and correct answer, if this helps you