Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Answered

Job class to update" item model group "in inventModelGroupItem Table i'm facing issues !

Posted on by 206
Hi every one!I have a requirement to change itemmodelgroup of item from /inventModelGroupItem/ table. Ihave to select UPDATE model group only where item type is /Item/ for all items. Item type is coming from Invent Table so Ihave to join the tables and then select /inventModelGroupItem/ for update.when i run thi class i face the error /Cannot edit a record in Relationship between items and item model groups (InventModelGroupItem). The record has never been selected/.  I have added the following code :
 InventModelGroupItem  inventModelGroupItem;        EcoResProduct         ecoresproduct;        InventTable           inventTable;        ttsBegin;                 while select forUpdate inventModelGroupItem            where inventModelGroupItem.ItemId != ''            join inventTable            where inventModelGroupItem.ItemId         == inventTable.ItemId            &&    inventModelGroupItem.ItemDataAreaId == 'QTS'            &&    inventTable.ItemType   == ItemType::Item        inventModelGroupItem.ModelGroupId = 'WA';        inventModelGroupItem.update();            ttsCommit;        info(/completed/);
 
 
  • Verified answer
    Mohamed Amine Mahmoudi Profile Picture
    Mohamed Amine Mahmoudi 9,531 Super User 2024 Season 2 on at
    Job class to update" item model group "in inventModelGroupItem Table i'm facing issues !
    Hi,
     
    make sure you pointed to the legal entity QAS
    otherwise you can use changeCompany('USMF')
    try this :
            while select forUpdate inventModelGroupItem            
                where inventModelGroupItem.ItemId != ''            
                join inventTable            
                where inventModelGroupItem.ItemId         == inventTable.ItemId            
                &&    inventModelGroupItem.ItemDataAreaId == inventTable.DataAreaId
                &&    inventTable.ItemType   == ItemType::Item 
            {
    
            }
    Best regards,
    Mohamed Amine MAHMOUDI

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans