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

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

Cannot edit a record in *. The record has never been selected.

(0) ShareShare
ReportReport
Posted on by 50

private void processCounting()
{

    int nomor, no, angka, NC3, NC4, NC5, NC6, NC7, NC8, NC9,
        NC10, NC11, NC12, NC13, NC14, NC15, NC16, NC17, NC18,
        NC19, NC20, NC21;

    while select pibCount
        group by NoBuktiPIB, KodeBarang, RecId
        where pibCount.createdBy == CurUserId()
    {
        //JUMLAH BARANG
        select count(KodeBarang) from pibCount2
        where pibCount2.NoBuktiPIB == pibCount.NoBuktiPIB
        && pibCount2.RecId == pibCount.RecId
        && pibCount2.createdBy == CurUserId();
        nomor = any2int(pibCount2.KodeBarang);
        //UPDATE JUMLAH BARANG
        ttsBegin;
            select forUpdate pibUpdate
        where pibUpdate.createdBy == curUserId()
        && pibUpdate.NoBuktiPIB == pibCount.NoBuktiPIB
        && pibUpdate.KodeBarang == pibCount.KodeBarang
        && pibUpdate.RecId == pibCount.RecId;
        EU_TBL_KITEPIBtmp.clear();
        EU_TBL_KITEPIBtmp.JumlahBarang = nomor;
        EU_TBL_KITEPIBtmp.doUpdate();
        ttsCommit;

What happen with this record never been selected ?
pastedimage1591591940608v1.png

this the variable code :

EU_TBL_KITEPIBtmp   EU_TBL_KITEPIBtmp,EU_TBL_KITEPIBtmp2,EU_TBL_KITEPIBtmp3,EU_TBL_KITEPIBtmp4,
                    pibCount, pibUpdate, pibCount2, pibCount3, pibCount4, pibCount5, pibCount6,
                    pibCount7, pibCount8, pibCount9, pibCount10, pibCount11, pibCount12,
                    pibCount13, pibCount14, pibCount15, pibCount16, pibCount17, pibCount18,
                    pibCount19, pibCount20, pibCount21, pibUpdate3, pibUpdate4, pibUpdate5,
                    pibUpdate6, pibUpdate7, pibUpdate8, pibUpdate9, pibUpdate10, pibUpdate11,
                    pibUpdate12, pibUpdate13, pibUpdate14, pibUpdate15, pibUpdate16, pibUpdate17,
                    pibUpdate18, pibUpdate19, pibUpdate20, pibUpdate21;



pastedimage1591591790550v1.png

in my debbuger its already selected, already add clear buffer. what i missed ?

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,884 Most Valuable Professional on at

    Your code indeed never selects EU_TBL_KITEPIBtmp.

    The debugger shows that the buffer called pibUpdate is populated, which is irrelevant if your problem is about EU_TBL_KITEPIBtmp and not pibUpdate.

    By the way, do you think that variable names like pibUpdate3, pibUpdate4 etc, describe the intent of these variables? Don't forget that you and your colleagues will need to read and understand the code and such names will make it very difficult.

  • Ardhi A Rahman Profile Picture
    50 on at

    thanks martin for the answer. but i need to know that i can select new table with new variable, so the main variable(the first) is not selected.

    but when the process of report is done. and then i selected it for updating with new variable table.

    the first select filled - select that table with new variable - updating the value


    this the variable:

    EU_TBL_KITEPIBtmp       EU_TBL_KITEPIBtmp,EU_TBL_KITEPIBtmp2,EU_TBL_KITEPIBtmp3,EU_TBL_KITEPIBtmp4,
                            pibCount, pibUpdate, pibCount2, pibCount3, pibCount4, pibCount5, pibCount6,
                            pibCount7, pibCount8, pibCount9, pibCount10, pibCount11, pibCount12,
                            pibCount13, pibCount14, pibCount15, pibCount16, pibCount17, pibCount18,
                            pibCount19, pibCount20, pibCount21, pibUpdate3, pibUpdate4, pibUpdate5,
                            pibUpdate6, pibUpdate7, pibUpdate8, pibUpdate9, pibUpdate10, pibUpdate11,
                            pibUpdate12, pibUpdate13, pibUpdate14, pibUpdate15, pibUpdate16, pibUpdate17,
                            pibUpdate18, pibUpdate19, pibUpdate20, pibUpdate21;

  • Martin Dráb Profile Picture
    237,884 Most Valuable Professional on at

    I'm sorry, but I don't understand your requirement. Could you give us a concrete example of what you're trying to achieve, please?

    Also, can you please tell us why you're using so many variables with names differing just by an index? We should be able to suggest a better design (easier to write, read and maintain), such as using a collection class.

  • Verified answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    A general solution for avoiding the error "record has never been selected" is to check that you have a record at hand before trying to update.

    So, before calling update on a record, check that the buffer has a RecId.

    About this specific situation, it's not clear what you are trying to do and therefore it's not possible to suggest detailed solution.

  • ergun sahin Profile Picture
    8,826 Moderator on at

    Hi Ardhi,

    You have defined that table, but you never selected;

           EU_TBL_KITEPIBtmp.clear();

           select firstOnly EU_TBL_KITEPIBtmp;//(ofcourse with where clause)

           // OR

           EU_TBL_KITEPIBtmp = pibUpdate;//I cant see your table

           EU_TBL_KITEPIBtmp.JumlahBarang = nomor;

           EU_TBL_KITEPIBtmp.doUpdate();

  • Verified answer
    Xusheng Profile Picture
    on at

    This issue should caused by EU_TBL_KITEPIBtmp.doUpdate().  Why you select forupdate pibUpdate, but use EU_TBL_KITEPIBtmp to update.

    pastedimage1591608218653v1.png

    Suggest change EU_TBL_KITEPIBtmp to pibUpdate. Hope this can help you.

  • Verified answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    Also, normally it's good to call update() instead of doUpdate() since otherwise any custom logic in the update() method is not called. And also for cross-references it's better if you call update, then it's possible to find this code later if you want to find all classes that update your table.

  • Ardhi A Rahman Profile Picture
    50 on at
    [quote]

    A general solution for avoiding the error "record has never been selected" is to check that you have a record at hand before trying to update.

    So, before calling update on a record, check that the buffer has a RecId.

    About this specific situation, it's not clear what you are trying to do and therefore it's not possible to suggest detailed solution.

    [/quote]

    thanks Nikolaos for reply, thanks for that information. but in my debugger that already detected the recid. but when i already include where clause with recid in it, it dont get the recid.

  • Ardhi A Rahman Profile Picture
    50 on at
    [quote user="ergun sahin"]

    Hi Ardhi,

    You have defined that table, but you never selected;

           EU_TBL_KITEPIBtmp.clear();

           select firstOnly EU_TBL_KITEPIBtmp;//(ofcourse with where clause)

           // OR

           EU_TBL_KITEPIBtmp = pibUpdate;//I cant see your table

           EU_TBL_KITEPIBtmp.JumlahBarang = nomor;

           EU_TBL_KITEPIBtmp.doUpdate();

    [/quote]

    thanks ergun for reply. i always did that code for another project. but just in my case here it didnt want to processed. i think i should create new table so i wouldnt use update() anymore

  • Ardhi A Rahman Profile Picture
    50 on at
    [quote user="Xusheng"]

    This issue should caused by EU_TBL_KITEPIBtmp.doUpdate().  Why you select forupdate pibUpdate, but use EU_TBL_KITEPIBtmp to update.

    pastedimage1591608218653v1.png

    Suggest change EU_TBL_KITEPIBtmp to pibUpdate. Hope this can help you.

    [/quote]

    thanks xusheng for reply. but you know sometimes we had to use newest variable so our main variable is not clash with that our new data. i always do that and works. but now i dont know why. but i think i should create new table and use insert() rather than update() for newbie like me hahaha

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 565 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 450 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans