Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

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

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 ?

  • Suggested answer
    Xusheng Profile Picture
    Xusheng on at
    RE: Cannot edit a record in *. The record has never been selected.

    Thanks for your reply. And I am glad to see you had find the RCA now. :)

    Can you help mark it as verified if the answer is helpful.

  • Ardhi A Rahman Profile Picture
    Ardhi A Rahman 50 on at
    RE: Cannot edit a record in *. The record has never been selected.
    [quote]

    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.

    [/quote]

    thanks nikolaos for reply,

    i want to try create new table with insert() method. so it will clear the case with newbie method hahaha 

    and get those datas with EU_TBL_KITEPIBtmp where clause joining with pibUpdate

    will find soon for the definition about it thanks

  • Ardhi A Rahman Profile Picture
    Ardhi A Rahman 50 on at
    RE: Cannot edit a record in *. The record has never been selected.
    [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

  • Ardhi A Rahman Profile Picture
    Ardhi A Rahman 50 on at
    RE: Cannot edit a record in *. The record has never been selected.
    [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
    Ardhi A Rahman 50 on at
    RE: Cannot edit a record in *. The record has never been selected.
    [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.

  • Verified answer
    nmaenpaa Profile Picture
    nmaenpaa 101,146 on at
    RE: Cannot edit a record in *. The record has never been selected.

    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.

  • Verified answer
    Xusheng Profile Picture
    Xusheng on at
    RE: Cannot edit a record in *. The record has never been selected.

    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.

  • ergun sahin Profile Picture
    ergun sahin 8,812 Super User on at
    RE: Cannot edit a record in *. The record has never been selected.

    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
    nmaenpaa Profile Picture
    nmaenpaa 101,146 on at
    RE: Cannot edit a record in *. The record has never been selected.

    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.

  • Martin Dráb Profile Picture
    Martin Dráb 224,741 Super User on at
    RE: Cannot edit a record in *. The record has never been selected.

    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.

Helpful resources

Quick Links

Can you answer this forum question?

You could make someone's day!

Community Newsletter - May 2024

Kudos to our community stars!

Community Spotlight of the Month

Kudos to Mohamed Amine Mahmoudi!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 283,663 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 224,741 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,146

Featured topics

Product updates

Dynamics 365 release plans