Best answer

Use more fields from the selected dynamic dropdown object

  • 9 June 2021
  • 4 replies
  • 187 views

Hey,

I’m using the UI integration builder and I want to do the following:
I have a trigger that fetches a list of objects similar to this one:

[
{
"id": "cc68c08d-67df-43a6-a6e3-3d35fdd6ee52",
"code": "api-test",
"hash": "iqbyqlzx",
"eventId": "cc68c08d-67df-43a6-a6e3-3d35fdd6ee52",
"event_section_id": 3819439
},
{
"id": "7eb2bee3-372f-40e8-8e7a-b6e3e3bb4fca",
"code": "809805",
"hash": "gkc6wqtm",
"eventId": "7eb2bee3-372f-40e8-8e7a-b6e3e3bb4fca",
"event_section_id": 3820600
}
]

I’m using the trigger to power an action’s dynamic drop down menu. However, I can only use exactly one of these attributes to be accessible as an inputField in the action’s POST request.

My question is - Can I somehow access these other object properties I fetched in the dynamic dropdown in the following POST request?
If I can, what is the best way to do that?

icon

Best answer by GetUWired 9 June 2021, 14:17

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

4 replies

Userlevel 7
Badge +12

If you are just using the form builder, then no but if you switch the form to code mode or convert the project to the CLI you can do it either of these ways:

 

If your api supports retrieving an object by its id then once a user selects an option and you have the object id, you can make another request before your main one that retrieves the full details of that object. 

 

Alternatively,  you could JSON.stringify each of the objects and set the string as a new value in the object before returning the results.

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

//results is an object, results.data is the array of objects I want to use in my dynamic dropdown

results.data.forEach(object => {
var temp = JSON.stringify(object);
object.stringObject = temp;
});

return results.data;
});

Then you can use the new key ‘stringObject’ as the value you want from the dynamic dropdown

then you can JSON.parse the value selected to get it back into its proper form and from there pick off what you need.

Thanks for the quick reply!

So if I understand it correctly, I should first fetch say UUID using the Dynamic Dropdown and then use the UUID to make another call to our API that retrieves the rest of the information?
Should I use the Dynamic Field for this second call? 

Userlevel 7
Badge +12

Hi @Chooboo 


If you go the second call route, you would not use an additional field. The second request would happen behind the scenes prior to your main request. 

I have also edited my initial response as I thought of a second solution that didn’t use a second api call. 

I’ll definitely check it out, thanks again!