- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi everyone,
I have a requirement involving a Transform Map where I need to set a field value based on whether a record is inserted or updated.
Here’s the scenario: I’m loading incident data from Excel. The file can contain both existing and new incident records. If the incident already exists, I don’t want to change anything. But if it’s a new record, I need to set a custom resync field to “Yes”, which should trigger a Business Rule to pull data from an external API.
The issue is that the field value is not being set reliably during the transform.
If I set it using a field map script, the value updates, but the Business Rule that depends on it does not trigger as expected.
Has anyone faced a similar situation? What would be the best practice to conditionally set a field during transform while ensuring the related Business Rule executes properly?
Thanks in advance!
@Ankur Bawiskar #servicenow #developer
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @Mani_Mk ,
Try below OnBefore transform script
(function runTransformScript(source, target, map, log, isUpdate) {
if (action == 'insert') {
target.u_resync = 'Yes';
}
})(source, target, map, log, action == 'update');
Use below BR conditions:
current.operation() == 'insert'
&& current.u_resync == 'Yes'
If my response helped, please hit the 👍Thumb Icon and accept the solution so that it benefits future readers.
Regards,
Pratik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @Mani_Mk ,
Try below OnBefore transform script
(function runTransformScript(source, target, map, log, isUpdate) {
if (action == 'insert') {
target.u_resync = 'Yes';
}
})(source, target, map, log, action == 'update');
Use below BR conditions:
current.operation() == 'insert'
&& current.u_resync == 'Yes'
If my response helped, please hit the 👍Thumb Icon and accept the solution so that it benefits future readers.
Regards,
Pratik

