Skip to main content

Notifications

Community site session details

Community site session details

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

"the record has never been selected" after Join/Group by

(0) ShareShare
ReportReport
Posted on by

Hi Teams,

I would like to update the field of a record in table A after joining with another table B on which I want to apply Group by on its ID.

I tried to run the following code but it throws me an error "Cannot edit a record in tableA. The record has never been selected":

where select forupdate tableA group by tabAid, Dimension[5]
join tableB group by tabBid, Dimension[5]
where tableA.tabAid == tableB.tabBid && tableB.Dimension[5] != "" && tableA.Dimension[5]
{
    if(tableA.Dimension[5] != lines.Dimension[5])
    {
        ttsbegin;
        tableA.Dimension[5] = tableB.Dimension[5];
        tableA.update()
        ttscommit;
    }
}

I think it should be caused by the usage of Group By clause on tableA but if I remove it, on the if check, the tableA.Dimension[5 is empty.

Please someone help me.

Thanks in advance.

  • CU19081013-0 Profile Picture
    on at
    RE: "the record has never been selected" after Join/Group by

    Thanks, it works

  • Verified answer
    Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: "the record has never been selected" after Join/Group by

    You can do the other way around -

    while select firstOnly Dimension[5] from tableB
        join  forupdate tableA
            where tableA.tabAid == tableB.tabBid && 
                  tableB.Dimension[5] != ""      && 
                  tableA.Dimension[5] != ""
    {
        if(tableA.Dimension[5] != lines.Dimension[5])
        {
            ttsbegin;
            tableA.Dimension[5] = tableB.Dimension[5];
            tableA.update()
            ttscommit;
        }
    }

  • CU19081013-0 Profile Picture
    on at
    RE: "the record has never been selected" after Join/Group by

    It doesn't work because it takes more than 1 record from tableB

  • Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: "the record has never been selected" after Join/Group by

    You can try the firstonly clause in that case and check if that works for you.

    while select forupdate tableA
        join firstOnly Dimension[5] from tableB 
            where tableA.tabAid == tableB.tabBid && 
                  tableB.Dimension[5] != ""      && 
                  tableA.Dimension[5] != ""
    {
        if(tableA.Dimension[5] != lines.Dimension[5])
        {
            ttsbegin;
            tableA.Dimension[5] = tableB.Dimension[5];
            tableA.update()
            ttscommit;
        }
    }

  • CU19081013-0 Profile Picture
    on at
    RE: "the record has never been selected" after Join/Group by

    Hi Gunjan,

    exact, I need to update the Dimension[5] value in table A with the first matching record in table B (the first one that have same id and different initial Dimension[5])

  • Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: "the record has never been selected" after Join/Group by

    Hi Mancio13,

    In case there are multiple records in table B corresponding to a single record in tableA, do you need to update the Dimension[5] value in table A with the first matching record in table B?

  • CU19081013-0 Profile Picture
    on at
    RE: "the record has never been selected" after Join/Group by

    Hi Gunjan,

    I'm using Group by on TableB because there I have multiple records with same Dimension[5] referencing a single record from table A. I tried to delete the first Group By on tableA but then it doesn't select anything from A.

    For the first statement, I made a transcription error.

  • Verified answer
    Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: "the record has never been selected" after Join/Group by

    Hi Mancio13,

    The error is being caused by the "Group by" clause. Why are you trying to do a group by when you are trying to update the Dimension[5] value?

    Also, your first statement doesn't look correct. It should be "while select" instead of 'where select"

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,135 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,871 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans