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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

BULK Update Job Issue

(1) ShareShare
ReportReport
Posted on by 275
When using this piece of code as a job i am getting error while updating my melting table from tagline table .
  public void UpdateJob()
  {
    BULKOLDTAGDESTROY BULKOLDTAGDESTROY;
    BULKOLDTAGDESTROYDETAIL BULKOLDTAGDESTROYDETAIL;
    INVENTJOURNALTRANS iNVENTJOURNALTRANS;
    INVENTDIM iNVENTDIM;
    MELTINGTABLE MELTINGTABLE;
   TAGLINES TAGLINES;
    int updateCount = 0;

    ttsbegin;
    
    while select forUpdate MELTINGTABLE
        join iNVENTDIM where MELTINGTABLE.BATCHID == iNVENTDIM.INVENTBATCHID
        join iNVENTJOURNALTRANS where iNVENTDIM.INVENTDIMID == iNVENTJOURNALTRANS.INVENTDIMID
        join BULKOLDTAGDESTROY where iNVENTJOURNALTRANS.JOURNALID == BULKOLDTAGDESTROY.JOURNALID
        join BULKOLDTAGDESTROYDETAIL where BULKOLDTAGDESTROY.BULKTAGDESTROYNO == BULKOLDTAGDESTROYDETAIL.BULKTAGDESTROYNO
        notExists join TAGLINES where BULKOLDTAGDESTROYDETAIL.TAGNO == TAGLINES.TAGNO
            && MELTINGTABLE.INPUTITEMID == TAGLINES.ITEMID
            && TAGLINES.TRANSFINEWEIGHT != 0.00
            && TAGLINES.NetwtDeduction != 0.00
    {
    
      if (MELTINGTABLE && TAGLINES)
      {
        MELTINGTABLE.TRANSFINEWEIGHTNEW = TAGLINES.TRANSFINEWEIGHT;
        MELTINGTABLE.NetwtDeduction = TAGLINES.NetwtDeduction;
        MELTINGTABLE.update();
        updateCount++;
      }
    }
    ttscommit;
    info(strFmt("Updated %1 records in MELTINGTABLE.", updateCount));
  }

I am gettign error :An update conflict occurred due to another user process deleting the record or changing one or more fields in the record. 
I also tried marking tagline as null after the while loop but then i don't get value from the while select statement to update in melting table
purpose : i want to update my melting table with tagline table on daily basis in scheduled time frame thats why i need this job to be running perfectly.

Thanks for the help!!
I have the same question (0)
  • Martin Dráb Profile Picture
    240,288 Most Valuable Professional on at
    I guess you're trying to update the same MeltingTable record for the second time, which is wrong. Please debug your code to see whether it's the case. When you confirm the cause, we can talk about how to fix your logic.
     
    (Moved from D365 general forum.)
  • Suggested answer
    Waed Ayyad Profile Picture
    9,212 Super User 2026 Season 2 on at
    Hi,
     
    Add meltingTable.reread(); at the beginning of the if condition body.
     
     if (MELTINGTABLE && TAGLINES)
          {
            MELTINGTABLE.reread();
            MELTINGTABLE.TRANSFINEWEIGHTNEW = TAGLINES.TRANSFINEWEIGHT;
            MELTINGTABLE.NetwtDeduction = TAGLINES.NetwtDeduction;
            MELTINGTABLE.update();
            updateCount++;
          }

    Thanks,
    Waed Ayyad
    If this helped, please mark it as "Verified" for others facing the same issue
     
     
  • Suggested answer
    Sourav Mazumdar Profile Picture
    42 on at
    Hi Ayushaman,
     
    You can try putting the ttsbegin and ttscommit just across the update() method instead of whole while loop. 
     
  • Ayushaman Profile Picture
    275 on at
    Hi @Sourav Mazumdar

    I already tried Putting inside  if loop rather than whole while loop but it will throws error.
     
     
    Thanks,
    Ayushaman
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    26,811 Super User 2026 Season 1 on at
    Hi,
     
    You must add reread method before updating the record.
    MELTINGTABLE.reread();
     
     
    Best regards,
    Mohamed Amine MAHMOUDI
  • Ayushaman Profile Picture
    275 on at
    Hi @ Mohamed Amine/ @Waed Ayyad 
     
    I tried using `{MELTINGTABLE.reread();}` as suggested, and it's working fine. However, there's an issue with the updating process.
    For instance, when updating records where `MELTINGTABLE.BatchId` is 'LD0013320042', there are ten associated `TAGLINES.tag_no` entries.
    Out of these, only four have values for `TAGLINES.transfineweight` and `TAGLINES.netwtdeduction`.
    These four specific records should be updated in the `MELTINGTABLE`.
    Currently, all ten `TAGLINES.tag_no` records in the `MELTINGTABLE` are being updated with the last value in the loop.
    If the last value for `transfineweight` in `TAGLINES` is 16, all ten records in `MELTINGTABLE` are updated with 16, instead of their respective values.

    Feel free to ping me back if you have any queries to help me resolve this issue .
     
    Thanks for the help 
     
  • Waed Ayyad Profile Picture
    9,212 Super User 2026 Season 2 on at
    Hi,
     
    Did you try my suggestion? 
     
    Thanks,
    Waed Ayyad

     
  • Ayushaman Profile Picture
    275 on at
    Hi Waed !
     
    Thanks for the assistance ! Yes, I tried that and that issue is resolved  but the error that i mentioned in my previous reply is not yet resolved. 

    Thanks,
    Ayushaman
  • Martin Dráb Profile Picture
    240,288 Most Valuable Professional on at
    Your description is very confusing. For example, you're saying that all ten `TAGLINES.tag_no` records in the `MELTINGTABLE` are being updated, but MeltingTable doesn't contain TagLines records.
     
    You seem to be trying to say that you have multiple TagLines records to a single MeltingTable record and that your logic updates the MeltingTable record with TransFineWeightNew and NetwtDeduction from the last TagLines records. That's true; your code keeps overwriting the same MeltingTable record and the final values are the ones from the last TagLines record. This logical error can't be fixed by mere reread().
     
    You need to decide what you want to put to the MeltingTable record. Do you want to somehow summarize values from those four TagLines records and store the calculated values in MeltingTable?
  • Ayushaman Profile Picture
    275 on at
    Hi Martin !
     
    I apologize for confusing you guys with my description. What you are saying is perfectly accurate for the requirement. I also got last minute update on it right now only. i want to sum up the transfinewt from the tagline table and update it on meltingtable.transfineweightnew. same for netwtdeduciton also.  and update it on melting table against Itemid. 

    Feel free to ping me back if you have any queries to help me resolve this issue.
     
    Thanks,
    Ayushaman

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 July Top 10 Community Leaders

These are the community rock stars!

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 284 Super User 2026 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 258 Most Valuable Professional

#3
Anton Venter Profile Picture

Anton Venter 228 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans