If Condition in Computed Column
Hi all,
Here, we will see how to use the if condition in a computed column. In my requirement, I want to return 0 if RefType is SaftyInvent; otherwise, the value of future days from the same view.
For detailed understanding about computed columns, please check the previous blog.
TestReqTransView is a view created using the ReqTrans table.
X++ Code
private static server str compColumnDelayDays() { DictView reqTransView = new DictView(tableNum(TestReqTransView)); str reqTransDs = reqTransView.query().dataSourceTable(tableNum(ReqTrans)).name(); return SysComputedColumn::if( SysComputedColumn::equalExpression( SysComputedColumn::comparisonField( dataentityviewstr(TestReqTransView), reqTransDs, fieldStr(ReqTrans, Reftype) ), SysComputedColumn::comparisonLiteral(ReqRefType::SafetyInvent) ), '0', SysComputedColumn::returnField( tableStr(TestReqTransView), reqTransDs, fieldId2name(tableNum(TestReqTransView), fieldNum(TestReqTransView, FUTURESDAYS)) ) ); }
No comments:
Post a Comment