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

Advertisements

Über erpcoder
Software Engineer and Dynamics AX enthusiast working in Research & Development for InsideAx

Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

WordPress.com-Logo

Du kommentierst mit Deinem WordPress.com-Konto. Abmelden / Ändern )

Twitter-Bild

Du kommentierst mit Deinem Twitter-Konto. Abmelden / Ändern )

Facebook-Foto

Du kommentierst mit Deinem Facebook-Konto. Abmelden / Ändern )

Google+ Foto

Du kommentierst mit Deinem Google+-Konto. Abmelden / Ändern )

Verbinde mit %s

%d Bloggern gefällt das: