Getting error "Cannot read property "length" from undefined" in flow designer.

mit2324
Kilo Expert

Hi all,

I am trying for SNow - JIRA integration using JIRA spoke. Getting error "Cannot read property "length" from undefined". I haven't used length anywhere in the script. Below is the script I have used in subflow, which is getting me the payload. The same script is running in background script, but getting error when I test run the flow.

try{
var issue_type = fd_data.subflow_inputs.template.u_issue_type.toString();
var payload_template = gs.getProperty('jira.'+ issue_type);
var json_val = JSON.parse(payload_template);
var payload = {};
if(json_val !=''){
for(var key in json_val)
payload[key] = fd_data.subflow_inputs.task[json_val[key]].getDisplayValue().toString();
gs.info("Jira_pload: "+ payload);
 
} }
return JSON.stringify(payload);
}
catch (e)
{
return e;
}

Please let me know what could be done to fix the issue. Thanks in advance,

Regards,

Mithun

1 ACCEPTED SOLUTION

mit2324
Kilo Expert

The issue was with the payload value I was trying to send to JIRA, the issue type value (Example Story, Epic etc.,) which Jira expected was not sent in the payload. Also, it's case sensitive.

View solution in original post

4 REPLIES 4

Sagar Pagar
Tera Patron

Hi,

Take a look at -  Error "Cannot read property length from undefined" in my custom workflow activity 'Create PDL'., wh...

 

Thanks,

Sagar Pagar

The world works with ServiceNow

Richard Hine
Tera Guru
Tera Guru

Mithun,

At a guess, your issue lies in your for loop. I would debug inside the loop what the json_val[key] is and ensure that it exists in the variable you are expecting to retrieve it from.

Hope this helps,

Richard

Mathieu Lepoutr
Mega Guru

Hi mit

I'm working as a pre-sales engineer with Exalate.

Exalate was designed with exactly these types of use-cases in mind, you could say that it is our "bread and butter".

One of Exalate's features, apart from syncing tickets bi-directionally, is having access to a script connection type, where the sky is truly the limit and your use-case will be solved by.

Any entity type will out-of-the-box be fully bi-directionally syncronized, which means, if a field gets updated on either side, it will automatically update on the other side, you can change this to make it uni-directional if you so please.

Exalate is easy and straightforward to set-up and you can control exactly which data you want to send and/or receive. 

If you would like to see a customized demo of the product, please book a slot.

Cheers

mit2324
Kilo Expert

The issue was with the payload value I was trying to send to JIRA, the issue type value (Example Story, Epic etc.,) which Jira expected was not sent in the payload. Also, it's case sensitive.