Hi,
In this post, we will view the code to use SysComputedColumn with an if loop and cast operation.
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, TransTypeName, Voucher and TransactionAmount.
Step 2: Created a method "computeTransAmount" to display the transaction amount to cast from real to integer for Payment transactions.
public static str computeTransAmount()
{
TableName viewName = tableStr(DAXCustomerTrans); //Entity name
str transTypeName = SysComputedColumn::returnField(viewName, identifierStr(CustTrans), identifierStr(TransType));
str amountCurStr = SysComputedColumn::returnField(viewName, identifierStr(CustTrans), identifierStr(AmountCur));
return SysComputedColumn::if (SysComputedColumn::equalExpression(transTypeName, SysComputedColumn::returnLiteral(LedgerTransType::Payment)),
SysComputedColumn::cast(amountCurStr, 'int'),
amountCurStr);
}
Step 3: Assigned view method "computeTransAmount" to the field "TransactionAmount".
Step 4: Build the solution. In the table browser able to see the transaction amount being truncated (column transaction amount) for payment transactions.
Output:
Thanks,
Chaitanya Golla

Like
Report
*This post is locked for comments