Creating references to your objects in Management Center

I was looking into creating a reference editor to show an reference between my object to an SKU and I think it wasn't obvious how to get this relationship to work.

First of I wanted to use the reference editor to show my relationship. I defined it using the code below. I didn't want the ability to create new objects with the reference editor, and I wanted it to be required input.

<ReferenceEditor allowCreate="false" extendedHelpText="${HelpText}" 
    name="catEntryRefEditor" promptText="${Prompt}"
    required="true" />

To enable the reference I created a base reference object definition using the code below. Most of the variables are self explanatory but that I use the objectGroups to define the objectPath for my CreateService and UpdateService wasn't obvious.

<ReferenceObjectDefinition definitionName="BaseCatEntryType" 
    displayNameProperty="partnumber" isBaseDefinition="true" 
    initializeObjectStoreId="true" allowDuplicates="false" 
    derivedId="true" idProperty="catentryId" 
    objectGroups="ObjectReference" />

Next I created an instance inside my object for the reference types I wanted to relate to.

<ReferenceObjectDefinition baseDefinitionName="BaseCatEntryType" 

This steps should enable you to select an SKU and reference it to your object. And if you save the object with a ServiceParam with objectPath ObjectReference and propertyName catentryId you should get the value of the selected SKU into your command.

Secondly we want to load the value back into the reference editor. This was one of the things taking the longest time for me to figure out. After days of debugging I found that you don't use the GetReferencesService but the GetChildrenService using your Reference object type as the objectType param.

<GetChildrenService objectTypes="RefCatalogEntry" url="/cmc/GetCatEntryReferences">
    <ServiceParam name="objectId" propertyName="objectId"/>

The JSP returning the value have to look something like below (I had to use dashes in objects and object for some reason to save this code). The first object type below is the object type of the reference object. The inner object type is the actual object type of your referenced object, in my case CatalogGroupSKU. I had to give the reference object both catentryId and partnumber to show the reference value correctly in the editor and save the value directly. And then the inner object needs both catentryId and partnumber to display the object when it is loaded. If you don't supply both values to the inner object you will either not show an catalog entry you click on the reference or the code field will not be filled when you arrive at the property view.

    <obj-ect objectType="RefCatalogEntry">
        <catentryId><wcf:cdata data="${catentryId}"/></catentryId>
        <partnumber><wcf:cdata data="${partnumber}"/></partnumber>
        <obj-ect objectType="${objectTypeRef}">
            <catentryId><wcf:cdata data="${catentryId}"/></catentryId>
            <partnumber><wcf:cdata data="${partnumber}"/></partnumber>

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.