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 :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Production Journal BOM should have only items which are available in Production BOM

(0) ShareShare
ReportReport
Posted on by 15

Hi I need help. I am trying to provide the validation in the ProdJournalTransBOM form where the filed ItemID need to show only those Items which are available in its Production BOM. Rest it should not allow or show any item in the grid. Kindly let me know what could be the probable code for the same. Thanks and Regards.

I have the same question (0)
  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Ankit,

    Under ProdJournalTransBOM\DataSources\ProdJournalBOM\Fields\ItemId, method validate has already been added. You can add your logic to validate if the ItemId is present in the production BOM.

    From what I understand, you wouldn't want other items to show up on the lookup as well. For this requirement, you can  override the lookup method under the same control to restrict the number items showing up in the lookup.

  • ankitrsharma Profile Picture
    15 on at

    Hi Gunjan, Thanks for your kind reply. I agree with you but there are two methods suppose validate as well as modify. Now I need to add a new one lookup there can you kindly suggest what code will be there in validate as well as lookup. Thanks and regards.

  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Ankit,

    Here is the logic you can put in validate method -

    select firstOnly prodBOMLoc
        where prodBOMLoc.ItemId == prodJournalBom.ItemId
           && prodBOMLoc.ProdId == prodJournalBOM.ProdId;
        
    if (!prodBOMLoc)     
    {
        ret = checkFailed(strFmt("Item %1 is not a part of Production BOM", prodJournalBom.ItemId));
    }

    For lookup, this should work -

    public void lookup(FormControl _formControl, str _filterStr)
    {
        SysTableLookup          sysTableLookup = SysTableLookup::newParameters(tableNum(InventTable), _formControl);
        Query                   query = new Query();
        QueryBuildDataSource    qbds1, qbds2;
        QueryBuildRange         queryBuildRangeItemType;
    
        qbds1 = query.addDataSource(tableNum(InventTable));
        qbds2 = qbds1.addDataSource(tableNum(ProdBOM));
        qbds2.joinMode(JoinMode::InnerJoin);
        qbds2.addLink(fieldNum(InventTable, ItemId), fieldNum(ProdBOM, ItemId));
        qbds2.addRange(fieldNum(ProdBOM, ProdId)).value(queryValue(prodJournalBom.ProdId));
    
        sysTableLookup.addLookupfield(fieldNum(InventTable,ItemId));
        sysTableLookup.addLookupMethod(tableMethodStr(InventTable,itemGroupId));
        sysTableLookup.addLookupMethod(tableMethodStr(InventTable,defaultProductName));
        sysTableLookup.addLookupfield(fieldNum(InventTable,ItemType));
    
        sysTableLookup.parmQuery(query);
        sysTableLookup.performFormLookup();
    }

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 689

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 606 Super User 2026 Season 1

#3
CP04-islander Profile Picture

CP04-islander 356

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans