Computed columns in Views D365FO x++
Here is the computed column example in view which return Yes/No based on if condition
/// <summary>
/// </summary>
/// </summary>
/// return Yes if External Customer has attachment else No
/// </summary>
public static server str computeFileAttached()
{
{
str customerRecID;
str fileAttached;
str result;
str result;
SysDictTable dictDocuRef = new SysDictTable(tableNum(DocuRef));
customerRecID=SysComputedColumn::returnField(tableStr(TestExtCustomerView), identifierStr(TestExtCustomerTable), fieldStr(TestExtCustomerTable, RecId));
str s = strFmt('SELECT TOP 1 %1 FROM %2 WHERE %2.%3 = %4
AND %2.%5 = %6',
dictDocuRef.fieldName(fieldNum(DocuRef, RefRecId), DbBackend::Sql),
dictDocuRef.name(DbBackend::Sql),
dictDocuRef.fieldName(fieldNum(DocuRef, RefRecId), DbBackend::Sql),customerRecID,
dictDocuRef.fieldName(fieldNum(DocuRef,RefTableId),DbBackend::Sql),"9708");
AND %2.%5 = %6',
dictDocuRef.fieldName(fieldNum(DocuRef, RefRecId), DbBackend::Sql),
dictDocuRef.name(DbBackend::Sql),
dictDocuRef.fieldName(fieldNum(DocuRef, RefRecId), DbBackend::Sql),customerRecID,
dictDocuRef.fieldName(fieldNum(DocuRef,RefTableId),DbBackend::Sql),"9708");
result = strFmt('ISNULL((%1), \'\')', s);
return SysComputedColumn::if(
SysComputedColumn::returnLiteral("No"),
SysComputedColumn::returnLiteral("Yes"));
SysComputedColumn::returnLiteral("No"),
SysComputedColumn::returnLiteral("Yes"));
SysComputedColumn::equalExpression(result,'0'),
}
Hope this helps.
Have a nice day.Stay Safe.
Comments
Post a Comment