Inegration question about coalesce
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2025 01:35 AM
I have a requirement Employee data integration from SAP to ServiceNow in a custom Employee Profile table.
SAP has unique field Employee ID.
Employee Profile do not have any such field, whereas it has field "User" which is a reference to User table (sys_user).
User table has Employee ID field.
I’m trying to use the COALESCE function, but I’m running into issues. Could you please help or suggest a better approach, any script or something
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2025 02:22 AM
Hello @srohan24
Please verify below points
- Is there any other business rule/script to create profiles.??
- also make sure that if record not found on target table ignore the insert action.
--
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2025 02:35 AM
- there is a BR to Enforce unique user for Employee Profile
- below section of onBefore is ignoring the the insert action
if (profileGr.next()) {
target.setValue('sys_id', profileGr.getUniqueValue());
gs.info('[onBefore] Updating Employee Profile with sys_id: ' + profileGr.getUniqueValue());
} else {
gs.warn('[onBefore] No matching sn_employee_profile for user sys_id: ' + userSysId);
ignore = true;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2025 02:40 AM
where have you written that script?
is that onBefore transform script?
I couldn't find the variable defined anywhere sapEmpNum
Also you need to use next() method to actually go to that gliderecord object
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2025 09:39 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2025 02:19 AM
Hi @srohan24,
I saw your transform script that you shared.
Can you please explain more the whole ambition?
The coalesce field works like a validation whether that field in the coalesce fields exists, the record is updated, if it doesn't exist, it creates a new record... there can be more than just one coalesce fields if needed.
You want to track the SAP ID or you want to store it? You can create a custom field on User table and receive that value in that field...
Or what exactly is the issue?
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */