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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Unrelate all Many-to-M...
Power Apps
Answered

Unrelate all Many-to-Many relationships at once

(0) ShareShare
ReportReport
Posted on by

Hello,

 

There is an Instruments table and there is an Many-to-Many relationship Categories. When editing the Instrument form, Relate() works as expected.

 

 

Set(
 varInstrumentRecord,
 LookUp(Instruments, Id=varInstrumentFormItem.Id)
);

ForAll(
 CategoriesValue.SelectedItems,
 Relate(varInstrumentRecord.Categories , ThisRecord)
);

 

 

But if I want to Unrelate() all old records before creating new ones, I get an error: This function cannot operate on same data source that is used in ForAll.

 

 

ForAll(
 varInstrumentFormItem.Categories As LoopItem,
 Unrelate(varInstrumentRecord.Categories, LoopItem)
);

 

 

How to Unrelate() all records at once?

P.S. If I urelate one record

Unrelate(varInstrumentRecord.Categories, First(varInstrumentFormItem.Categories))

everything goes well.

Categories:
I have the same question (0)
  • Verified answer
    v-xiaochen-msft Profile Picture
    on at

    Hi @Anonymous ,

     

    Please try the showColumns() function in the first parameter of forall function.

    Something like this:

    ForAll(
     ShowColumns(varInstrumentFormItem.Categories,"<GUID Field>") As LoopItem,
     Unrelate(varInstrumentRecord.Categories, LookUp(Second table,GUID Field= LoopItem.GUID Field))
    );

     

    Best Regards,

    Wearsky

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard