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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

InventBatchIdLookup Form Tabs

(0) ShareShare
ReportReport
Posted on by 1,216

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

  • HAIRUL HAZRI Profile Picture
    1,216 on at

    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,216 on at

    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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Prashant Singh Profile Picture

Prashant Singh 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans