Question on LDAP transform map
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2024 04:00 AM
Hi All,
In LDAP integration we are importing DL records from AD to ServiceNow sys_user table. For this in staging table there is a field name with u_proxyaddresses. currently we are retrieving 4 email ids in this field. but we need a single email address starting with info@. from staging table we are getting email id in the following format 'smtp:info@eensvdw.com'. so we need to remove smtp: as well and populate the remaining mail id in the u_proxyaddresses field.
Please find the attached snapshot.
Can anyone please help me on this to get the proper solution.
Thanks,
Manish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2024 05:26 AM
Your script could look something like this (assuming it all starts with info and ends with .com):
(function transformEntry(sourceField, targetField, map, log, targetRecord) {
// Source field contains the full string
var sourceValue = sourceField;
// Regular expression to match 'info@...' that ends with .com
var match = sourceValue.match(/info.*?\.com/);
if (match) {
// Set the target field to the matched value
targetRecord[targetField] = match[0];
} else {
// If no match found, you can log it or set a default value if necessary
targetRecord[targetField] = '';
}
})(source.u_source_field, target.u_target_field, map, log, target);
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark