Data entity virtual fields and skip validate field, allow edit and allow edit on create
public class BFSPrepaymentTableEntity extends common
{
// Postload & mapEntityToDataSource for virtual fields which helps you to push the values instead of recids
public void postLoad()
{
super();
//Populate virtual field once entity has been loaded from database
this.PrepayIdStr = this.PrepayId;
this.JournalNumStr = this.JournalNum;
this.IsCreatedStr = this.IsCreated;
EcoResCategory ecoResCategory;
select firstOnly ecoResCategory
where ecoResCategory.RecId == this.PrepayCategoryId;
this.EcoResCategoryCommodityCode = ecoResCategory.Code;
}
Public void mapEntityToDataSource(DataEntityRuntimeContext entityCtx, DataEntityDataSourceRuntimeContext dataSourceCtx)
{
super(entityCtx, dataSourceCtx);
//Check if desired data source context is available
if (dataSourceCtx.name() == "BFSPrepaymentTable")
{
BFSPrepaymentTable prepayTable = dataSourceCtx.getBuffer();
prepayTable.PrepayId = this.PrepayIdStr;
prepayTable.JournalNum = this.JournalNumStr;
prepayTable.IsCreated = this.IsCreatedStr;
EcoResCategory ecoResCategory;
select firstOnly ecoResCategory
where ecoResCategory.Code == this.EcoResCategoryCommodityCode;
prepayTable.PrepayCategoryId = ecoResCategory.RecId;
dataSourceCtx.setBuffer(prepayTable);
}
}
//persistEntity - which helps to skip validate fields , allow edit and aloow edit on create , mandatory others ,
We can also skip on DMF - data entities - modify target mapping - skip validate field
Please make sure that provide allow edit and allow edit on create, Yes , mandatory No on on entity level
/// <summary>
///
/// </summary>
/// <param name = "_entityCtx"></param>
public void persistEntity(DataEntityRuntimeContext _entityCtx)
{
this.skipDataSourceValidateField(fieldNum(BFSPrepaymentTableEntity, JournalNum), true);
this.skipDataSourceValidateField(fieldNum(BFSPrepaymentTableEntity, IsCreated), true);
this.skipDataSourceValidateField(fieldNum(BFSPrepaymentTableEntity, PrepayId), true);
this.skipDataSourceValidateField(fieldNum(BFSPrepaymentTableEntity, PayeeBankAccountId), true);
this.skipDataSourceValidateField(fieldNum(BFSPrepaymentTableEntity, VendBankAccountId), true);
this.skipDataSourceValidateField(fieldNum(BFSPrepaymentTableEntity, Value), true);
this.skipDataSourceValidateField(fieldNum(BFSPrepaymentTableEntity, ContractTable), true);
this.skipDataSourceValidateField(fieldNum(BFSPrepaymentTableEntity, PrepayCategoryId), true);
super(_entityCtx);
}
}
Comments
Post a Comment