Converting a array into a string

I have a table with select components and need to format into into a string to put into the db,

The formatting would look like this [(Matches_from_code.data.url[i], issue_selecter[i].value), (Matches_from_code.data.url[i], issue_selecter[i].value), ...] is there any way i can do this

`var issueArray = "";

for (var i = 0; i < {{Matches_from_code.data.id.length}}; i++) {
if ({{issue_selecter[i].value}} != null) {
issueArray += "(" + {{Matches_from_code.data.url[i]}} + ", " + {{issue_selecter[i].value}} + ")";
}
}

if (issueArray !== "") {
issueArray = "[" + issueArray + "]";
}

return issueArray;
`
This is an attempt I made in the js transformer but it in testing when i tried to return {{issue_selecter[i].value}} inside the for loop it was null but returning {{issue_selecter[0].value}} gave me the right output

What am i doing wrong?

Assign your external data to variables:
var matches = {{Matches_from_code.data}}
var issues = {{issue_selecter}}

for (var i = 0; i < matches.id.length; i++) {
if (issues[i].value != null) {
issueArray += "(" + matches.url[i] + ", " + issues[i].value + ")";
}
}

if (issueArray !== "") {
issueArray = "[" + issueArray + "]";
}

return issueArray;

2 Likes

Thanks so much, works perfectly!

1 Like