
Hi DAXers,
I recently came across this issue where I built a custom API in Dynamics 365, that accepts a list as one of the parameters, the list is used to drop values and update them in a table. The problem is one of the business requirements is that if the list is null no update should happen, whereas if we receive an empty list, all records should be dropped.
The request looks like this :
[AifCollectionTypeAttribute("elements1", Types::Class, classStr(SLRClassElements1))]
public FDXItemMaintenanceResultMessage createOrUpdateItem(DataAreaId dataAreaId,
str parameter1 = "",
List elements1 = null,
SLRClassElements2 element2 = null)
{
Table table;
ttsBegin;
//some code for updates...
if(elements1 != null)
{
delete_from table where table.Id == parameter1
ListIterator it = new ListIterator(elements1);
while (itB.more())
{
table.clear();
SLRClassElements1 element1 = it.value();
table.initValue();
table.field1 = element1.elementParameter1();
table.field2 = element1.elementParameter2();
table.field3 = element1.elementParameter3();
table.field4 = element1.elementParameter4();
if (table.validateWrite())
{
table.update();
}
it.next();
}
//some other code for updates...
}
ttsCommit
}