fd_data is not defined

Robert Bigelow
Tera Contributor

I have built a few custom tables, extending the Task table, to bring our HTML forms into our new Service Portal. I've been working on this for a couple weeks, testing each form as I go. I build a Flow to route the form and send an email notification to the right people.

That email is scripted in Flow Designer, using a string literal and concatenation to fill in the blanks from the Record Producer. I use fd_data to access the data in the Flow. It has been working great, until this morning. I finished my last form, and tests are failing. I'm seeing the error in the Execution "fd_data is not defined"

I went back to one of the other flows that was working great to see if I accidentally did something different, but the code is identical. fd_data pops up when I type it in, and I can dot walk through the Flow data as usual.

The crazy part is, now even the Flows that were working great are giving the same error.

This is a tiny snip of what I'm doing. It's pretty standard, and was working great yesterday.

var body = "<table>\
   <tr><td><a href='https://rcchelpdesk.service-now.com/now/workspace/agent/record/u_user_account_form/" + fd_data.trigger.current.sys_id + "'>Link to form</a></td>";
   body = body + "</tr>\
   <tr>\";

I didn't change any of the code, it just stopped working. I suspect the code is fine, and it's something elsewhere in my instance, but I'm not really sure what. Any ideas?

1 ACCEPTED SOLUTION

Robert Bigelow
Tera Contributor

I figured it out.

I'm still not sure why, but it suddenly decided it didn't like the way I was concatenating the strings inline with the sys_id. When I separated those out to three different lines, it works now.

View solution in original post

9 REPLIES 9

MichelSamia
Tera Expert

A small explanation as a result of my investigation: the current.sys_id is not a string, it is an object. Please try to put .toString() after sys_id. It helped me.

You can check it by adding gs.info(typeof(fd_data.trigger.current.sys_id)); to your script

If you are doing string concatenation, the + operator calls the toString function. So, it's not needed. My BKM is to use String(gr.user.email) since the toString() function on a Java object returns a Java String and could throw an exception if gr.user.email is null.
var str = 'My array is ' + ['a','b'];
gs.log('str:' + str);//str:My array is a,b
if client side, (e.g. press F12) then console.log('str:' + str);//str:My array is a,b
I didn't use ANY functions like toString or join. FYI the toString function on JS arrays is join() and If no separator is provided, it defaults to a comma (,).

scottl
Kilo Sage

This is STILL an issue in 2025.      

fd_data.trigger.current.sys_id isn't the actual object. Think of it like a C macro. It is replaced by the actual object at run time. Log something like 'fd_data.trigger.current.sys_id=' + fd_data.trigger.current.sys_id or some flow var and the text in quotes will be different.

And as stated, placing fd_data inline between strings breaks the parsing of the script.