Hi,
In this post, we will view the code to use Switch case of SysComputedColumn in D365FO.
Step 1: Created a view DAXCustomerTrans(namely) and added tables CustTable and CustTrans as its datasources. Added fields AccountNum, TransDate, TransType, DueDate, Description, AmountCur, TransRecId and TransTypeName.
Step 2: Created a method "computedTransType" to display the transaction type value as 0 for invoice and Payment transactions using Switch method of SysComputedColumn.
private static str computedTransType()
{
TableName viewName = tableStr(DAXCustomerTrans); //Entity name
str transTypeName = SysComputedColumn::returnField(viewName, identifierStr(CustTrans), identifierStr(TransType));
Map comparisonMap = SysComputedColumn::comparisionExpressionMap();
// Invoice
comparisonMap.insert(SysComputedColumn::returnLiteral(8), SysComputedColumn::returnLiteral(0));
// Payment
comparisonMap.insert(SysComputedColumn::returnLiteral(15), SysComputedColumn::returnLiteral(0));
return SysComputedColumn::switch(transTypeName, comparisonMap, transTypeName);
}
Step 3: Assigned view method "computedTransType" to the field "TransTypeName".
Step 4: Build the solution. In the table browser able to see the trans type as zero for invoice and payment transactions.
Output:
Thanks,
Chaitanya Golla
*This post is locked for comments