Flow Designer Subflow- How do I get custom variables from JSON Payload?

TramaineM
Kilo Sage

This is going to be a very noob question but I'm working on my coding skills 🙂

I'm using the Jira Spoke to integrate Jira with our ServiceNow instance. I have it working mostly except that it is not getting the values of 5 custom fields that are within the payload. These custom fields were added in Jira to match the existing Change record fields such as Justification, Test Plan etc. in ServiceNow. 

In the payload, they are called customfield_11247 through customfield_11251. Here is an example: 

In the subflow (which was cloned from the Process Jira Webhook subflow), I added the custom fields individually as a new input and the type "string", but they are showing blank when the webhook is triggered. 

I would think it would be string since it's not an object containing additional fields, but any help would be appreciated? Thanks!

1 ACCEPTED SOLUTION

Hey ok so here's another, better approach that doesn't require you to modify any script includes that they locked down. I don't know why I didn't even see this before.

You have inputs.payload in the subflow which is a string of the entire payload so all you gotta do in your Flow Designer is create your own action, with a script step. Now you make payload an input to the step, and the outputs can be all your custom fields. Now you can get to them like

var allInputs = JSON.parse(inputs.payload);
outputs.customfield11247 = allInputs.issue.fields.customfield_11247;

So that's just one example now you can make customfield11247 an output variable to your script step and an output to the action you created. Now you can access all your custom fields this way, just pass the payload to your custom action in the subflow.

And you don't even have to change the inputs to the subflow.

I went down the rabbit hole on this one but now I don't even think it was necessary 🙂

View solution in original post

15 REPLIES 15

Chris Sanford
Giga Guru

Ok just FYI the images didn't work they are broken can you share the images then I will try to help. I can't get JIRA spoke on my PDI because I think it's only downloaded from the store.

Sure I can, I'll try inserting instead of copy/paste.

find_real_file.pngfind_real_file.png

find_real_file.png

 

Chris Sanford
Giga Guru

Ok thanks, I mean that looks good from that screen but I guess I would have to see the entire code to understand. I would go to the PDI but the JIRA spoke isn't available there unfortunately

TramaineM
Kilo Sage

Any ideas? Replying so this can get more visibility. Thanks