Multiple EcoResItemColorName lookups in the same form

We’ve recently discussed a situation a work, where more than one ItemId and Color lookup was used on the same form.

Form with two ItemIds and two EcoResItemColorNames

The EcoResItemColorName data type uses the  InventProductDimensionLookup to display the available colors for the item. However, if there are multiple items on a form and multiple color lookups the lookups always present the available color values for the first item.

Multiple Color Lookups on a form displays the wrong values

The InventProductDimensionLookup form uses the InventDimCtrl_Frm_Lookup controller class. The init() method
is used to determines the ItemId.

callerHasItemId     = this.callerItemFieldId() != 0;
if (! callerHasItemId)
{
    callerItemIdMethod  = formHasMethod(callingElement.args().caller(),
                                        identifierStr(itemId));
    if (callerItemIdMethod)
    {
        callerHasItemId = true;
    }
}

callerHasInventDimParm  = formHasMethod(callingElement.args().caller(),
                        InventDimCtrl_Frm::inventDimSetupObjectMethod());

callerWMSPalletIdMethod = formHasMethod(callingElement.args().caller(),
                                        identifierStr(wmsPalletId));

super();

If there is no ItemId in the caller form, the init() code checks for an itemId() method on the caller form. This can be used to provide the correct ItemId for each of the lookups.

  1. Rename ItemId to ItemId1
  2. Declare an ItemId variable activeItemId in the forms ClassDeclaration

    public class FormRun extends ObjectRun
    {
        ItemId activeItemId;
    }

  3. Overwrite each lookup() method on the EcoResItemColorFields in the form
  4. Set the activeItemId variable to the corresponding ItemId, e.g. ItemId1 for EcorResColorName1 and ItemId2 for EcoResColorName2

    public void lookup()
    {
        activeItemId = MultiItemColor.ItemId2;

        super();
    }

  5. Create an itemId() method on the form that returns the value of the Itemid variable

    public ItemId itemId()
    {
        return activeItemId;
    }

 

So the correct colors are displayed in the lookup

Multiple Color Lookups on a form

About erpcoder
Azure Cloud Architect and Dynamics 365 enthusiast working in Research & Development for InsideAx

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: