Load data on Control to Entity Table using Transform Map

BKash
Tera Contributor

Hello, I am trying to load data on Control to Entity (sn_compliance_m2m_control_entity) using Transform Maps so that the Reliant entities get added to the Common controls. I am not sure how to achieve this. Can anyone help me on this??

1 ACCEPTED SOLUTION

IsabelyA
Kilo Guru

 The first step was to prepare a file (CSV or Excel) with two main columns: one with the control number (for example, CTRL0001234) and another with the name of the entity (type Entity A).

After uploading the file to ServiceNow, it automatically generated an Import Set table. I then created a Transform Map, where I defined this table as the source and the sn_compliance_m2m_control_entity table as the destination.

In the Field Maps, I configured the logic so that the system would search for the control by number and fill in the field with the corresponding sys_id, and the same for the entity - I searched for the entity name and used its sys_id to fill it in correctly.

I also added a check to ensure that the same combination of control and entity wasn't created more than once, avoiding duplicates.

View solution in original post

3 REPLIES 3

IsabelyA
Kilo Guru

 The first step was to prepare a file (CSV or Excel) with two main columns: one with the control number (for example, CTRL0001234) and another with the name of the entity (type Entity A).

After uploading the file to ServiceNow, it automatically generated an Import Set table. I then created a Transform Map, where I defined this table as the source and the sn_compliance_m2m_control_entity table as the destination.

In the Field Maps, I configured the logic so that the system would search for the control by number and fill in the field with the corresponding sys_id, and the same for the entity - I searched for the entity name and used its sys_id to fill it in correctly.

I also added a check to ensure that the same combination of control and entity wasn't created more than once, avoiding duplicates.

BKash
Tera Contributor

Thank you for your reply @IsabelyA . Can you give me the code for check that ensures avoiding duplicates, that'd be very helpful. Thanks in advance!

 

var exists = new GlideRecord('sn_compliance_m2m_control_entity');
exists.addQuery('control', target.control);
exists.addQuery('entity', target.entity);
exists.query();
if (exists.next()) {
    return; 
}