web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

InventBatchIdLookup Form Tabs

(0) ShareShare
ReportReport
Posted on by 1,214

Hi. I'm working with InventBatchIdLookup form which three different tabs containing different grids and different datasources. 

My focus here is only on the first two tabs, Batch number tab & On-hand tab.

Batch numbers tab datasource is from InventBatch table.

On-hand tab datasource is from InventDim table.

I added two fields from InventBatch table inside On-hand tab grid.

inventbatchlookup.png

My problem is, these Best Before Date & Manufacturing Date is only displayed when I open the On-hand tab from Batch numbers tab. 

If I open the On-hand tab directly as shown in the picture, the fields will be blank. Only when I switch to Batch numbers tab then switch to On-hand tab again will the values be displayed.

Honestly I don't know where to start. I figured this could be refresh issue and this tabChanged() method is where it's is happening but I don't know what to change or override.

public void tabChanged(int _fromTab, int _toTab)
{
    super(_fromTab, _toTab);

    mustSaveLast = true;

    element.setSelectMode();

    if (_toTab == #tabPageReference)
    {
        element.selectMode(inventDimTrans_inventBatchId);
        inventDimTrans_inventBatchId.setFocus();

        inventTrans_ds.executeQuery();
    }
    else
    {
        if (filterLookup)
        {
            selectedFormDataSource.research();
        }

        SysTableLookup::lookupTabChanged(callerControl,
                                         selectedControl,
                                         selectedFormDataSource);
    }
}

void setSelectMode()
{
    void setSelectedControlAndDataSource(FormStringControl  _selectedControl,
                                         FormDataSource     _selectedFormDataSource)
    {
        selectedControl         = _selectedControl;
        selectedFormDataSource  = _selectedFormDataSource;
    }

    if (inventDimFormSetup.hasCallerItemId())
    {
        switch (tab.tab())
        {
            case 2  :
                this.selectMode(inventDim_inventBatchId);
                inventDim_inventBatchId.setFocus();
                setSelectedControlAndDataSource(inventDim_inventBatchId, inventDim_ds);
                break;
            case 3  :
                this.selectMode(inventDimTrans_inventBatchId);
                inventDimTrans_inventBatchId.setFocus();
                setSelectedControlAndDataSource(inventDimTrans_inventBatchId, inventDimTrans_ds);
                break;
            case 1  :
            default :
                this.selectMode(ctrlInventBatch_inventBatchId);
                ctrlInventBatch_inventBatchId.setFocus();
                setSelectedControlAndDataSource(ctrlInventBatch_inventBatchId, inventBatch_ds);
        }
    }
    else
    {
        this.selectMode(ctrlInventBatch_inventBatchId);
        setSelectedControlAndDataSource(ctrlInventBatch_inventBatchId, inventBatch_ds);
    }
}


Can you help explain what's actually going on with these tabs? Thank You very much.

*This post is locked for comments

I have the same question (0)
  • HAIRUL HAZRI Profile Picture
    1,214 on at
    RE: InventBatchIdLookup Form Tabs

    Hi Crispin, this is the init method. I've added the highlighted line. By "refresh/initialize links with InventBatch datasource", is that what you mean?

    void init()
    {
        super();
    
        this.initReturnMode();
    
        callerControl   = SysTableLookup::getCallerStringControl(element.args());
    
        element.updateDesign(InventDimFormDesignUpdate::Init);
    
        inventDimFormSetup.initInventDimQueryDatasource(inventDim_ds);
        inventDimFormSetup.initInventSumQueryDatasource(inventSum_ds);
        inventDimFormSetup.initInventSumQueryDatasource(inventBatch_ds); //Added by Hairul
    
        xSysLastValue::getLast(this);
        ctrlShowAvail.value(showAvail);
    
        if (inventDimFormSetup.hasCallerInventDimParm())
        {
            ctrlLinkDim.value(linkDim);
        }
        else
        {
            linkDim = false;
            ctrlLinkDim.visible(false);
        }
    
        inventAvailabilityFormCache = InventAvailabilityFormCache::construct();
    
        if (#PDSPotencyEnabled)
        {
            if (inventDimFormSetup.hasCallerItemId())
            {
                pdsItemId = inventDimFormSetup.callerItemId();
                baseAttribute = InventTable::find(pdsItemId).pdsBaseAttributeId;
            }
    
            if (element.args().dataset() == tableNum(ProdBOM))
            {
                callerProdBOM = element.args().record();
                pdsNormalizedQty.visible(true);
            }
        }
    }

    I found the linkactive on InventDim ExecuteQuery() method:

    void executeQuery()
    {
        WMSPalletId wmsPalletId;
    
        if (inventDimFormSetup.hasCallerItemId())
        {
            inventAvailabilityFormCache.refreshCache();
    
            inventDimFormSetup.executeInventDimQueryDatasource(this,
                                                               linkDim,
                                                               showAvail
                                                              );
    
            wmsPalletId = inventDimFormSetup.callerWMSPalletId();
    
            if (wmsPalletId)
            {
                this.query().dataSourceTable(tableNum(InventDim)).addRange(fieldNum(InventDim,wmsPalletId)).value(queryValue(wmsPalletId));
            }
    
            element.updateDesign(InventDimFormDesignUpdate::LinkActive);
    
            super();
        }
    }

    But I don't understand how to "open the OnHand tab after every link is activated". Please explain more. Thank You.

  • Verified answer
    HAIRUL HAZRI Profile Picture
    1,214 on at
    RE: InventBatchIdLookup Form Tabs

    This issue is solved by referring here. My requirement was exactly the same as that post, adding fields from InventBatch to On-Hand tabPage, which datasource is from InventDim. Using the display method, I got the correct value and no refresh issue seems to appear.

    Regards.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 3

#3
Scott_itD Profile Picture

Scott_itD 2 Community Manager

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans