The CreatorCon Call for Content is officially open! Get started here.

onForeignInsert() script in the Transform Map

anubhavkapoor76
ServiceNow Employee
ServiceNow Employee

Hey All,

Does any one has an idea of how to use onForeignInsert() Event in Transform Map?

Scenario: I am trying to run a transform map on table which has a a user field in it. Now if the user is not in the sys_user table then it has to be created during load. 

I have created a Field Map against the Ref field ( with Reference value name as "name") however using ForeignInsert Script to update email id

1 ACCEPTED SOLUTION

Thanks Himanshu. Yes i sorted this out and used onAfter() function.

View solution in original post

8 REPLIES 8

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Anubhav,

 

You can set choice action to create records in the reference table. 

https://docs.servicenow.com/bundle/orlando-platform-administration/page/integrate/ldap/task/t_SetCho...

 

- Pradeep Sharma

Hi Pradeep,

Thanks. I am just doing that.

However the email id of the user is not populated in user table due to which I have to use Transform Map Script or onForeignInsert() function.

anubhavkapoor76
ServiceNow Employee
ServiceNow Employee

In onForeignInsert() function I am trying the following code:

 

target.<target_table_userrecord_fieldname>.email = source.<email_fieldname>

Himanshu Dubey
Giga Guru

Hi Anubhav,

The onForeignInsert event script is processed at the start of the creation of a related, referenced record, before the record is created please refer below code to understand how to use this event.

var e = new GlideEvent("myimport_ForeignInsert", action, name, "");
e.insert();

Mark Correct if my answer solves your issue and also mark 👍 Helpful if you find my response worthy.

Thanks & Regards

Himanshu Dubey