onForeignInsert in ServiceNow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
scenario if i have two reference fields and both are referring to different tables how to use onForeigninsert because in that we only use target so how will servicenow know which table to refer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
The onForeignInsert event script is processed at the start of the creation of a related, referenced record, before the record is created.
The onForeignInsert script runs separately for each reference field mapping, not once for all fields together.
// This script runs when a referenced record does not exist
// and ServiceNow is about to create it
if (target.getTableName() == 'sys_user') {
// Logic for User table
target.user_name = source.caller_id;
target.first_name = source.first_name;
target.last_name = source.last_name;
} else if (target.getTableName() == 'sys_user_group') {
// Logic for Group table
target.name = source.assignment_group;
target.description = "Created via Transform Map";
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
but what if i have two reference fields and both are referencing the same table then how will servicenow know which field i am talking about
