Skip to main content
Dynamics 365 Community / Forums / Finance forum / Job class to update" i...
Finance forum
Answered

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

editSubscribe (1) ShareShare
ReportReport
Posted on by 187
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/);
 
 
Attachments
  • Verified answer
    Mohamed Amine Mahmoudi Profile Picture
    Mohamed Amine Mahmoudi 3,905 User Group Leader 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

Helpful resources

Quick Links

New Blog Features Released!

Check out the new community blog features for viewers and authors…

Setting Up Knowledge Sources for Copilot…

Look at how configuring a comprehensive knowledge base is crucial…

Demystifying Copilot with Georg Glantschnig…

Industry experts answer burning questions directly from our amazing Community…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,183 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 222,733 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,138

Featured topics

Product updates

Dynamics 365 release plans