Skip to main content

Interesting issue I am encountering here:

I have an action that sends an API request to ClickUp like so: 

 

I am interested in parsing out the “TE” and “TT” custom fields values, and the data I get back from the API response appears as such:

As you can see, the data should match up like so:

Field Name Field Value
QA Issue Status  
TE 520
TT 54.549472222222222

 

However, when I go to parse out the index of “TE” and lookup the corresponding value via javascript code, I am noticing that input for value is missing the first comma:

 

This is my javascript code:

const names = inputData.names.split(',');
const values = inputData.values;

console.log("Names: " + names );
console.log("Values: " + values);

const teIndex = names.findIndex(name => name.includes('TE'));

console.log("TE Index: "+ teIndex);

if (teIndex !== -1){
var workingValues = values;
var indexCount = -1;

var timeEstimatedValue = -1;
while (workingValues.indexOf(',') !== -1){
indexCount++;

const commaIndex = workingValues.indexOf(',');
const temp = workingValues.substring(0, commaIndex);

console.log("Comma Index: " + commaIndex)
console.log("Temp Value: " + temp)

if (teIndex === indexCount){
console.log("FOUND!")
output = { value: temp }
break;
}

workingValues = workingValues.slice(commaIndex + 1)

console.log("Remaining Values: " + workingValues);
}
}

output = { value: "-1" }

This is the output of the tested step:

As you can see, Console logs the “values” input to be missing that initial comma that when looking at the response data is there.

What is possibly causing that comma to be stripped?

Hi @Dashkin 

Check this related topic:

 


Unfortunately, the issue is that input data is missing that initial comma. Not the formatting itself.

For instance, inspecting response data shows that first character as a comma:

Yet, this comma is not present in the input:

Consequently, the first value at index 0 is “520” when it should be “” (empty string, no data).


@Dashkin 

If you follow the instructions in the guide it will handle that use case since the Field Name would still be present even if there is no matching value.

https://community.zapier.com/code%2Dwebhooks%2D52/guide%2Dparse%2Dcalendly%2Dquestions%2Danswers%2Dline%2Ditems%2Dwith%2Dformatter%2Dand%2Dcode%2Dto%2Duse%2Das%2Dcustom%2Dvariables%2D27697

 

 


Unfortunately, the issue still lies within how Zapier processing the response data from the original API request to provide the [Response Data Tasks Custom Fields Value] field value. No way of formatting or splitting the resulting field value would make the value correct (i.e., make the order of values returned correspond to the order of field names returned).

However, my solution was to write my own Javascript code to completely process the response body of the original API request to a JSON object with JSON.parse.

This solved my issue, since then I could easily find the value of a custom field, by the custom field name.