Unable to create a record in m2m service entry tabel through background scripts

Madhan27
Mega Guru

Hi Community,

 

Not able to create a record with complete data in m2m table (sa_m2m_service_entry_point_list) using background scripts. 

 

var a= new GlideRecord('sa_m2m_service_entry_point');  
        a.initialize();
        a.cmdb_ci_endpoint = "Test Endpoint";
        a.cmdb_ci_service = "Managed Continuity23512654"
        a.insert();

 

 

Madhan27_0-1700666022723.png

 

Kindly help me with the solution.

 

Thanks in Advance. 

1 ACCEPTED SOLUTION

Maik Skoddow
Tera Patron
Tera Patron

Hi @Madhan27 

In ServiceNow M2M tables connect two other tables via references. That means the fields cmdb_ci_endpoint and cmdb_ci_service are of type "Reference" and NOT "String". You first have to determine the Sys IDs of the respective target records and then assign these Sys IDs to the fields before inserting.

Maik

View solution in original post

2 REPLIES 2

Maik Skoddow
Tera Patron
Tera Patron

Hi @Madhan27 

In ServiceNow M2M tables connect two other tables via references. That means the fields cmdb_ci_endpoint and cmdb_ci_service are of type "Reference" and NOT "String". You first have to determine the Sys IDs of the respective target records and then assign these Sys IDs to the fields before inserting.

Maik

Ty @Maik Skoddow , It worked.