Skip to main content

Hello, I’m building an integration and I have in an action a dynamic dropdown followed by another dropdown which values depends on the first one. 
In order to do the second dropdown, I used a dynamic field which returns the following : 

return z.request(options)
.then((response) => {
response.throwForStatus();
const results = response.json;
const field = { key : 'champ_type', choices: results.items.map(x => xt'fieldId']) }
return field;

My problem is that I get a list of fieldId and I would like those items to have an understandable label ( in  my case, it’s fieldLabel instead of fieldId). Can someone help me with this ? 

 

Thank you. :) 

@sub150 - Try the following code snippet:

return z.request(options).then((response) => {
response.throwForStatus();
const results = response.json;

const choices = results.items.reduce((prev, current) => {
prevvcurrent.fieldId] = current.fieldLabel;
return prev;
}, {});

const field = {
key: "champ_type",
choices,
};
return field;
});

 


It works ! Thank you very much @ikbelkirasan !