ModelLink To EnterpriseObject

If you have a model with a model link to EnterpriseObject, you will have to take care of following:


  1. Model forms - Platform does not provide an auto-complete SQL or picker view for EnterpriseObject ModelLinks. If you rely on the default, Platform uses the "Standard EnterpriseObject" custom model, which is not meaningful.
    images/download/attachments/144835287/modellink_to_enterprise_object-version-1-modificationdate-1645044067000-api-v2.png
    To make this work, you should define your own report and use that for auto-complete and picker report. For example:

    <ReportList xmlns="http://www.onenetwork.com/Platform">
    <Report>
    <Name>EnterpriseObjectModelLinkReport</Name>
    <SqlDef Name="EnterpriseObjectModelLinkReport" GroupName="PickerReport"><![CDATA[
    select eo.sys_ent_obj_id, eoa.value from ent_obj eo, ent_obj_attr eoa
    where eo.model_name = 'EPT.SampleEnterprise.Office'
    and eo.sys_ent_id = $MY_ENT_ID$
    and eoa.owner_id = eo.sys_ent_obj_id
    and eoa.name = $MY_ENT_ID$ || '~EPT.SampleEnterprise.OfficeNumber'
    and upper(eoa.value) like upper($OFFICE_NUMBER$) || '%'
    order by eoa.value
    ]]></SqlDef>
    <ActionDef>
    <PrimaryModelLevelType>EnterpriseObject</PrimaryModelLevelType>
    <IdField>SysEnterpriseObjectId</IdField>
    </ActionDef>
    <Filters bindSqlNulls="false">
    <CustomFilterField>
    <FieldRef category="PDF" levelType="Undefined">
    <FieldName>OfficeNumber</FieldName>
    </FieldRef>
    <Hidden>false</Hidden>
    <Editable>true</Editable>
    <Type>STRING</Type>
    <Optional>true</Optional>
    <SimpleMapping sqlName="OFFICE_NUMBER"/>
    </CustomFilterField>
    </Filters>
    <Retrieval>
    <CustomRetrievalField>
    <FieldRef levelType="EnterpriseObject" category="PDF">
    <FieldName>SysEnterpriseObjectId</FieldName>
    </FieldRef>
    <Hidden>true</Hidden>
    <Editable>false</Editable>
    <Type>LONG</Type>
    <Optional>true</Optional>
    <SelectedKey>true</SelectedKey>
    <SimpleMapping sqlName="sys_ent_obj_id"/>
    </CustomRetrievalField>
    <CustomRetrievalField>
    <FieldRef levelType="EnterpriseObject" category="PDF">
    <FieldName>ObjectKey</FieldName>
    </FieldRef>
    <Editable>false</Editable>
    <Type>STRING</Type>
    <SimpleMapping sqlName="value"/>
    </CustomRetrievalField>
    </Retrieval>
    </Report>
    </ReportList>


  2. Also update the panel class to use the above-defined report for EnterpriseObject modellink field (add the defaultConfig property):

    EPT.SampleEnterprise.TestEntObjectDetails = Ext.extend(One.model.ModelFormContainer,{
    ...
    defaultConfig: {
    prepareFields : function(fields) {
    var testEntObjML = fields.getField('TestEntObjML');
    delete testEntObjML.pickerView;
    testEntObjML.autocompleteSqlName='EPT.SampleEnterprise.SampleSqls.EnterpriseObjectModelLinkSQL';
    testEntObjML.pickerReport={reportName: 'EPT.SampleEnterprise.EnterpriseObjectModelLinkReport'};
    }
    }
    });


  3. Inbound Interface - For an inbound interface that needs a modellink to EnterpriseObject from another model, create an interface and add fields from the model. Then add custom fields to the interface for each EDF NK of the EnterpriseObject model referenced.
    images/download/attachments/144835287/modellink_to_enterprise_object_ib-version-1-modificationdate-1645044081000-api-v2.png

  4. Add the real key fields of EnterpriseObject in the derived fields area.
    images/download/attachments/144835287/modellink_to_enterprise_object_derived-version-1-modificationdate-1645044089000-api-v2.png

  5. Finally, add a tranformer to populate the EnterpriseObject ObjectKey field as follows:

    @Override
    public void transform(CsvRow row, CsvTransformContext context) throws CsvTransformException {
    EnterpriseObject entObj = new EnterpriseObject();
    entObj.setModelName("EPT.SampleEnterprise.Book");
    entObj.setAttribute("EPT.SampleEnterprise.OfficeNumber", row.get("OfficeNumber"));
     
    ModelLinkAttributeValue siteAttributeValue = new ModelLinkAttributeValue();
    siteAttributeValue.set("EPT.SampleEnterprise.SiteName", row.get("SiteName"));
    siteAttributeValue.set("EPT.SampleEnterprise.SiteOrganizationName", row.get("OrganizationName"));
    siteAttributeValue.set("EPT.SampleEnterprise.SiteEnterpriseName", row.get("EnterpriseName"));
     
    entObj.setAttribute("EPT.SampleEnterprise.Site", siteAttributeValue);
     
    row.set("TestEntObjMLObjectKey", entObj.getUpdatedObjectKey(context.getPlatformUserContext()));
    row.set("TestEntObjMLModelName", "EPT.SampleEnterprise.Office");
    row.set("TestEntObjMLEnterpriseName", "SampleEnterprise");
    }

    Enterprise Objects do have a few limitations; unlike Models they cannot be multi-level, and they are a bit more difficult to query since they use a row-based model for persisting their data (similar to EDFs). They also do not have quite the same performance characteristics as a true Model - they tend to be slower. However, the flexibility of being able to add them through the EPT makes up for many of these deficiencies and gives the EPT author many new options for implementing Enterprise-specific business logic.