Hello, there!
I’m making an App and I have an issue trying to format and send a colletion of arrays into the URL of my module.
This is the mappable parameter I’m working with:
{
"name": "fieldsUpdates",
"type": "array",
"spec": [
{
"name": "fieldId",
"type": "text",
"label": "Field ID",
"help": "The field ID can be found at /crm/configs/fields/ in your Bitrix24 environment."
},
{
"name": "fieldValue",
"type": "text",
"label": "New value"
}
],
"label": "Fields update",
"help": "Change the value of the field.",
"required": false
}
The fieldId
is dynamic and depends on the user input.
In my Communication tab, I’ve the following setup:
{
"url": "/crm.item.update.json?entityTypeId={{parameters.entityTypeId}}&id={{parameters.cardId}}&{{parameters.fieldsUpdates.map((field) => `&fields[${field[0]}]=${field[1]}`).join('')}}",
"method": "POST"
}
I need the values of fieldId
to be mapped as fields[fieldId]
before using them in the URL.
I have tried to use JS, as in this example:
const fieldItem1 = ["UF_CRM_1243", "https://google.com"];
const fieldItem2 = ["UF_CRM_4321", "pão com ovo"];
const array = [[...fieldItem1], [...fieldItem2]];
console.log(1, array);
const url = "/crm.item.update.json?entityTypeId={{parameters.entityTypeId}}&id={{parameters.cardId}}";
const parameters = array.map((field) => {return `fields[${field[0]}]=${field[1]}`});
console.log(2, parameters);
const newUrl = url+"&"+parameters.join("&");
console.log(3, newUrl);
But the App said that parameters.fieldsUpdates.map
isn’t found. So I figured that JS isn’t supported, so I backed to the docummentation but I couldn’t make anything work for me.
Any help?