Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Updating one record in a table

(1) ShareShare
ReportReport
Posted on by Microsoft Employee

 any body can help in below case  using code unit 

 created  the function recordvalidation()  where 

VCMS_EXP_TRA and VCMS_EXP_TRA1 referring the same table 

 Enty no. is primary key

/////////////////////////////////////////////////

LOCAL recordvalidation()
VCMS_EXP_TRA.RESET;
IF VCMS_EXP_TRA.FINDFIRST THEN
REPEAT
VCMS_EXP_TRA1.SETRANGE(EntryNo,VCMS_EXP_TRA.EntryNo);
IF VCMS_EXP_TRA1.FINDFIRST THEN
BEGIN
VCMS_EXP_TRA1.GenJour:= TRUE;
VCMS_EXP_TRA1.MODIFY;
END;
UNTIL VCMS_EXP_TRA.NEXT=0;

///////////////////////////////////////////

while nobody accessing this table.
getting below erro.

Microsoft Dynamics NAV
---------------------------

Another user has modified the record for this CMS_EXP_TRA after you retrieved it from the database.

Enter your changes again in the updated window, or start the interrupted activity again.

Identification fields and values:

EntryNo='200'
---------------------------
OK
---------------------------

*This post is locked for comments

  • RE: Updating one record in a table

    Try this one for update record

    Documentation()

    OnRun()

    ExcelBufer.RESET;

    ExcelBufer.DELETEALL;

    GenSetup.GET;

    //xlApp.Workbooks.OpenText(FileName,1257,1,1,1,TRUE,FALSE,FALSE,FALSE,FALSE,TRUE,'|');

    ExcelBufer.OpenBook('setsystempath.xlsx','customer');

    ExcelBufer.ReadSheet;

    ExcelBufer.RESET;

    IF ExcelBufer.FINDSET THEN BEGIN

     REPEAT

       SrNo := 0;

       IF OldRowNo <> ExcelBufer."Row No." THEN BEGIN

         ExcelBufer2.RESET;

         ExcelBufer2.SETRANGE("Row No.",ExcelBufer."Row No.");

         IF ExcelBufer2.FINDSET THEN BEGIN

           REPEAT

             SrNo += 1;

             IF SrNo = 1 THEN BEGIN

               Cust.RESET;

               Cust.SETRANGE("No.",ExcelBufer2."Cell Value as Text");

               IF Cust.FINDFIRST THEN BEGIN

                 Cust.INIT;

                 Cust."No." := ExcelBufer2."Cell Value as Text";

               END;

             END;

             IF SrNo = 2 THEN BEGIN

               IF ExcelBufer2."Cell Value as Text" <> '' THEN BEGIN

                 Cust.Name := ExcelBufer2."Cell Value as Text";

                 Cust.MODIFY;

               END;

             END;

           

            IF   Cust."Gen. Bus. Posting Group" ='' THEN BEGIN

                 Cust."Gen. Bus. Posting Group" :='NACIONAL';

                 Cust.MODIFY;

            END;

            IF  Cust."VAT Bus. Posting Group" ='' THEN BEGIN

                Cust."VAT Bus. Posting Group" :='NAC CLIENT';

                Cust.MODIFY;

            END;

            IF  Cust."Customer Posting Group" ='' THEN BEGIN

                Cust."Customer Posting Group" :='01NACIONAL';

                Cust.MODIFY;

            END;

            IF  Cust."Payment Method Code" ='' THEN BEGIN

                Cust."Payment Method Code" :='04';

                Cust.MODIFY;

            END;

            IF  Cust."Payment Terms Code" ='' THEN BEGIN

                Cust."Payment Terms Code" :='30D';

                Cust.MODIFY;

            END;

         UNTIL ExcelBufer2.NEXT = 0;

         END;

         OldRowNo := ExcelBufer."Row No.";

       END;

     UNTIL ExcelBufer.NEXT = 0;

    END;

    ExcelBufer.RESET;

    ExcelBufer.DELETEALL;

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Updating one record in a table

    thanks .

    it is functioning perfectly.

  • Suggested answer
    CDsilva Profile Picture
    CDsilva 4,184 on at
    RE: Updating one record in a table

    Try only this VCMS_EXP_TRA.MODIFYALL(GenJour,TRUE);

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Updating one record in a table

    thanks

    updated the same . it executed without updating the field value.

     VCMS_EXP_TRA.RESET;                  

     IF VCMS_EXP_TRA.FINDFIRST THEN BEGIN

      VCMS_EXP_TRA.MODIFYALL(GenJour,TRUE);

       END;    

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Updating one record in a table

    Ok Thanks.

    now it executing successfully without any error

    but it is not updating  the record   GenJour.

     VCMS_EXP_TRA.RESET;                  

     IF VCMS_EXP_TRA.FINDFIRST THEN BEGIN

      VCMS_EXP_TRA.MODIFYALL(GenJour,TRUE);

       END;    

  • Suggested answer
    Stefano Demiliani Profile Picture
    Stefano Demiliani 37,162 Most Valuable Professional on at
    RE: Updating one record in a table

    The REPEAT loop is unuseful. MODIFYALL works on all record (accordingly to filters) massively.

  • Suggested answer
    CDsilva Profile Picture
    CDsilva 4,184 on at
    RE: Updating one record in a table

    hi,

    You dont need the Repeat statement.

    // The result of this statement:  

    CustomerRec.MODIFYALL("Statistics Group", 2);  

    // is equivalent to:  

    IF CustomerRec.FIND('-') THEN  

     REPEAT  

       CustomerRec."Statistics Group" := 2;  

       CustomerRec.MODIFY;  

     UNTIL CustomerRec.NEXT = 0;  

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Updating one record in a table

    I have modified the same code but it is showing the same error

    VCMS_EXP_TRA.RESET;                  

     IF VCMS_EXP_TRA.FINDFIRST THEN

       REPEAT

         VCMS_EXP_TRA.MODIFYALL(GenJour,TRUE);

        UNTIL VCMS_EXP_TRA.NEXT=0;  

  • Suggested answer
    Stefano Demiliani Profile Picture
    Stefano Demiliani 37,162 Most Valuable Professional on at
    RE: Updating one record in a table

    Not so clear what you're trying to do. You're looping through VCMS_EXP_TRA record for modifying themself.

    If you want to modify the GenJour field of all the VCMS_EXP_TRA records you can do directly this:

    VCMS_EXP_TRA.MODIFYALL(GenJour,TRUE);

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,489 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans