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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / patch a collection in ...
Power Apps
Answered

patch a collection in a search box

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Goodnight all,

Please I'm also trying to patch a collection in a search box but it really doesn't finish;

My code:

 

If(
 !IsBlank(DataCardValue128),
 If(
 Form6.Mode = FormMode.New,
 ForAll(
 DemandeAchatActifCollection,
 Patch(
 DemandeAchatActif,
 Defaults(DemandeAchatActif),
 {
 ActifId:
 {
 '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
 Id:ActifCollectionId,
 Value:ActifCollection
 },
 DemandeAchatId:
 {
 Id: Form1_10.LastSubmit.DemandeAchatId,
 Value:Form1_10.LastSubmit.Code
 }
 }
 )
 );
 );
 Form6.Updates; NewForm(Form6)
);

 

the error is located here please:

 

 ActifId:
 {
 '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
 Id:ActifCollectionId,
 Value:ActifCollection
 },

 

Error message : the liste item could not be inserted or updated because invalid lookup values were found for the following fields in the list

 

Please help Me

 

Categories:
I have the same question (0)
  • v-jefferni Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

     

    The error message indicates that the value in the Patch function is not in the LookUp field, you need to confirm that in the collection ActifCollectionId and ActifCollection fields are containing the correct values. I am suspecting that whether ActifCollection is a field of the collection DemandeAchatActifCollection or not.

     

    Besides, you could try and modify the formula as below:

    If(
     !IsBlank(DataCardValue128),
     If(
     Form6.Mode = FormMode.New,
     ForAll(
     DemandeAchatActifCollection As DD,
     Patch(
     DemandeAchatActif,
     Defaults(DemandeAchatActif),
     {
     ActifId:
     {
     '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
     Id:DD.ActifCollectionId,
     Value:DD.ActifCollection
     },
     DemandeAchatId:
     {
     Id: Form1_10.LastSubmit.DemandeAchatId,
     Value:Form1_10.LastSubmit.Code
     }
     }
     )
     );
     );
     Form6.Updates; NewForm(Form6)
    );

     

    Hope this helps.

     

    Best regards,

    Community Support Team _ Jeffer Ni
    If this post helps, then please consider Accept it as the solution to help the other members find it.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @v-jefferni 

    i just added your code but i have practically the same error and everything seems to be correct i am really lost

    If(
     !IsBlank(DataCardValue128),
     If(
     Form6.Mode = FormMode.New,
     ForAll(
     DemandeAchatActifCollection As DD,
     Patch(
     DemandeAchatActif,
     Defaults(DemandeAchatActif),
     {
     ActifId:
     {
     '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
     Id:DD.ActifCollectionId,
     Value:DD.ActifCollection
     },
     DemandeAchatId:
     {
     Id: Form1_10.LastSubmit.DemandeAchatId,
     Value:Form1_10.LastSubmit.Code
     }
     }
     )
     );
     );
     Form6.Updates; NewForm(Form6)
    );

    My collection: 

    Collect(DemandeAchatActifCollection, {ActifCollection:DataCardValue128.Selected.Value, ActifCollectionId: CountRows(DemandeAchatActifCollection)+1})
    
    
     

    Hardy299_0-1629790951493.png

    Error message : 

    The Requested operation is invalid. Server response: DemanAchatActif failed: the could Item not be inserted or updated because invaalid Lookup values were found for the following fields in the list :[ActifId].ClientRequestid...............

  • Verified answer
    v-jefferni Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

     

    Just noticed that you are patching a collection rather than a list. Please try another method using LookUp function to populate a record from the destination list of the LookUp column:

    If(
     !IsBlank(DataCardValue128),
     If(
     Form6.Mode = FormMode.New,
     ForAll(
     DemandeAchatActifCollection As DD,
     Patch(
     DemandeAchatActif,
     Defaults(DemandeAchatActif),
     {
     ActifId:
     LookUp(Choices(List.LookUpColumnName), Value = DD.ActifCollection)
     ,
     DemandeAchatId:
     {
     Id: Form1_10.LastSubmit.DemandeAchatId,
     Value:Form1_10.LastSubmit.Code
     }
     }
     )
     );
     );
     Form6.Updates; NewForm(Form6)
    );

     

    Hope this helps.

     

    Best regards,

    Community Support Team _ Jeffer Ni
    If this post helps, then please consider Accept it as the solution to help the other members find it.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @v-jefferni *

    it works perfectly my brother
    Thank you so much

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 356 Most Valuable Professional

#2
11manish Profile Picture

11manish 225 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 211

Last 30 days Overall leaderboard