Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

InventBatchIdLookup Form Tabs

(0) ShareShare
ReportReport
Posted on by 1,204

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

  • Verified answer
    HAIRUL HAZRI Profile Picture
    HAIRUL HAZRI 1,204 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.

  • HAIRUL HAZRI Profile Picture
    HAIRUL HAZRI 1,204 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.

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey Pt 2

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,820 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,514 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans