OnBefore TransformScript to delete Target records

swaroop
Kilo Sage

Hello All,

When a record is passed using Transform Map, and if sys_id of the source record matches with Target record and if it contains all the fields empty then it should delete the target record. Can anyone suggest me how to do that.

 

 

Thanks & Regards,

S.Swaroop.

1 ACCEPTED SOLUTION

Hi,

As I said you have to enhance my script

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {

// Add your code here
var gr = new GlideRecord('incident');
gr.addQuery('number', source.u_number);
gr.query();
if (gr.next()) {
gr.deleteRecord();

gr.initialize();

gr.number = source.u_number;

gr.short_description = 'My Testing';

gr.insert();
} else {
ignore = true; // since record not found
}

})(source, map, log, target);

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

11 REPLIES 11

Sure.

We can just guide you and may not know the actual requirement.

You should be enhancing code from your side

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hello Ankur,

Sure, will do that from my end.

 

 

Thanks & Regards,

S.Swaroop.