So a record is created in Dynamics 365 which connects to a web API for a web app we use that I put together a custom connector for.
There are a number of custom fields that I am trying to map. The issue I'm running into now is if the field is blank in CRM, it is submitting that with nothing to the other web API which is expecting. This causes the Flow to fail, so trying to figure out how to make the entire custom_field conditional. This is what I am looking at:
So, for example, if the Project Kickoff is blank, it still tries to submit:
"custom_fields": [ { "custom_field_id": "434755", "value": "" }, { "custom_field_id": "442485", "value": "Test User" } ]
This triggers an error.
How can I make that entire object in the array conditional?
Solved! Go to Solution.
Ok, got this working. There are likely many ways of doing this, but this is the way I did it.
As far as the if statement in the "Set variable" when true, it looks like the following. I was trying to avoid having 25 conditions eating up a ton of real estate on the screen, so elected to do this which is probably as equally hard to read... didn't seem to be any good way to do this.
if(equals(items('Iterate_Through_Field_List_Values'),'481385'),triggerBody()?['tcc_mlaccount'],if(equals(items('Iterate_Through_Field_List_Values'),'442485'),triggerBody()?['tcc_mlcontact'],''))
EDIT:
Here are some better pictures:
Hi @ishraqiyun77 ,
You could initialize an array variable to store custom_fields value.
Configure append to array variable action to append non-null custom_field_id to this array.
Finally, click here and populate array variable to this field.
Hope it makes sense.
Best Regards,
Hi @v-bacao-msft,
I think I follow somewhat.
I'd pick the Append to Array variable action, set the name, and then add an expression that if a given Dynamics 365 field is populated (i.e., custom_field_value), add the custom_field_id to the array, correct?
I guess I'm not seeing how I'd create an array of objects though, which is what I'd need to do in this case.
Seems like I'd need to something like one of these properties, but I don't quite get what I'd be passing in for the first paramter ("object").
To add to this, I'm trying to start small. I'm messing with the compose action and then passing that into the connector for the custom_field array. What I have below works, and from that I can figure out how to pass in array and all. What I'm not figuring out is how to make this entire object conditional. I can pass an empty array to the API, but I can't return empty objects.
One thought was to initialize an array with all of the custom_field_id, iterating through it, and creating a new object with each iteration... but apparently that isn't possible:
Making progress, but for some reason this always evaluates to false.
Ok, got this working. There are likely many ways of doing this, but this is the way I did it.
As far as the if statement in the "Set variable" when true, it looks like the following. I was trying to avoid having 25 conditions eating up a ton of real estate on the screen, so elected to do this which is probably as equally hard to read... didn't seem to be any good way to do this.
if(equals(items('Iterate_Through_Field_List_Values'),'481385'),triggerBody()?['tcc_mlaccount'],if(equals(items('Iterate_Through_Field_List_Values'),'442485'),triggerBody()?['tcc_mlcontact'],''))
EDIT:
Here are some better pictures:
Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!
Power Platform release plan for the 2021 release wave 1 describes all new features releasing from April through September 2021.
User | Count |
---|---|
88 | |
58 | |
42 | |
37 | |
36 |
User | Count |
---|---|
85 | |
72 | |
61 | |
56 | |
40 |