Data Entity add computed field
We have this product import module that has a lot of entities, the main identifier or product number is store in one table. The references to that product is through a GUID. In one of the entitties I need to add a computed field for export. The fastest way to do this is to add a computed string value. One could think that adding some postLoad logic would do the trick, but this field will then not be exported through Data management, only visible in OData.
I've added these two fields:
EPDNr is not a computed field but populated in the postLoad method with this syntax:
public void postLoad() { EPDProduktDto produktDto;
super(); select firstonly EPDNr from produktDto where produktDto.ProduktGUID == this.ProduktGUID;
this.EPDNr = produktDto.EPDNr;
}
EPDNrComputedField is as you might have guessed a computed field.
public static server str computedFieldEPDNr()
{ str EPDNr;
EPDNr = strFmt(@'SELECT EPDNR ' + 'FROM EPDPRODUKTDTO ' + 'WHERE PRODUKTGUID = CONVERT(uniqueidentifier,%1)' + //because GUID is categorized as a unique identifier 'AND DATAAREAID = %2' //do notice that there are no quotation symbols '' og "" ,SysComputedColumn::returnField(tableStr(EPDBasispakningDtoEntity), identifierStr(EPDBasispakningDto), fieldStr(EPDProduktDto, ProduktGUID )) ,SysComputedColumn::returnField(tableStr(EPDBasispakningDtoEntity), identifierStr(EPDBasispakningDto), fieldStr(EPDProduktDto, DataAreaId ))); return EPDNr; }
Only the computed field is visible in the SQL server:
SELECT EPDNRComputedField, *
FROM EPDBasisPakningDtoEntity
WHERE ProduktGUID = CONVERT(uniqueidentifier, 'FCF49C6B-1F7F-418B-8FD9-861A45F680A1')
- Add the field to the Staging table.
- Check that the field is in your target mapping for the entity. If you do not see your field do the following:
- Regenerate target mapping
- Truncate the entity list
- Refreshed entity list
- If you now run a DataManagement project you get only the computed field and not the post loaded one
Comments
Post a Comment