How to make Create Jira issue Inline script work for additional fields?

Sunpreetk
Tera Contributor

I want to create issue dynamically based on the value added by user via create jira issue catalog item. But some fields in jira mandatory such as severity, Those can be set only via the additional fields. But whenever i add and return inline script , It always gives me this payload error
check screenshiot for reference,
here is code 

(function execute(inputs, outputs) {

// Inputs: a map of field ids and values
var fieldValues = {
"customfield_10189": inputs.severity || "S4 Trivial",
"customfield_13815": inputs.frequency || "Once on one device"
};

// Build encoded query string
var encodedQuery = Object.keys(fieldValues).map(function(key) {
return key + "=" + JSON.stringify({ "value": fieldValues[key] });
}).join("^");

// Output
outputs.encoded_query = encodedQuery;

})(inputs, outputs);
1 REPLY 1

pavani_paluri
Giga Guru

Hi @Sunpreetk ,

 

The payload error is because Jira expects its fields in a specific JSON structure when you create an issue via API, but you’re currently returning an encoded query string (ServiceNow-style field=value^field=value) instead of the JSON Jira needs.

{
"fields": {
"customfield_10189": { "value": "S4 Trivial" },
"customfield_13815": { "value": "Once on one device" }
}
}

 

Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Pavani P