- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2025 09:27 PM
I created a flow that works when i test but not when it runs in background.
Flow is triggered on contact creation.
It grabs the userid into the variable I then grab that variable and update the email address with adding @email.com.au *not actuall but here for reference.
in both cases on test and Austomation the username is populated into the variable. But in the automated test I dont get any info back into the email variable.
Script running
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2025 10:09 PM
ok the stangest thing I was testing some other suggested code which hadnt worked so I put in my original code like I first had tested to get some screenshots and now its working without running as system user or anything else. very Strange
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2025 09:32 PM
Hi @markdart
Are you getting any error? Have you checked the logs in the flow execution?
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2025 09:41 PM - edited 07-13-2025 09:41 PM
I think:
The issue you're facing is likely due to timing or data availability when the flow runs in the background.
When you run it manually (via "Test"), the record is fully saved and all values are available.
But when triggered automatically on contact creation, some fields (like username) may not yet be committed to the database.
Try something like this :
var gr = new GlideRecord('table_name'); // or 'customer_contact' if you're using CSM
if (gr.get(fd_data.flow_var.contactSysId)) {
var username = gr.user_name || ''; // Adjust the field name as per your contact table
return username + '@email.com.au';
}
return '';
NOTE : modify the script as per your USECASE accordingly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2025 09:50 PM
I got nothing back on my manual test. Updated table in script and check field name is correct
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2025 09:51 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2025 09:47 PM
please share complete flow steps screenshots
any error in flow execution?
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