Flow working on test but not Automated

markdart
Kilo Guru

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 

var sum = fd_data.flow_var.username + '@email.com.au';
return sum;

 

flowemail2.PNG

flowemail1.PNG

  

1 ACCEPTED SOLUTION

 

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 

View solution in original post

10 REPLIES 10

J Siva
Tera Sage

Hi @markdart 
Are you getting any error? Have you checked the logs in the flow execution?
Regards,
Siva

Ct111
Giga Sage

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.

 

 

 

 

markdart_0-1752468570113.png

I got nothing back on my manual test. Updated table in script and check field name is correct

var gr = new GlideRecord('customer_contact'); // 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 '';
 

Ankur Bawiskar
Tera Patron
Tera Patron

@markdart 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader