cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Gorilla_8
Impactful Individual
Impactful Individual

UPDATE BY PATCH IS NOT WORKING WITH LOOKUP COLUMN, TEXT, NUMBER

I got this code on my edit item to update a SharePoint list:

Patch(
    MySharePointList;
    LookUp(
        MySharePointList;
        ID = GalleryWithTheItems.Selected.ID
    );
    {
        LookUpColumn1: {
            '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference";
            Id: MyvarIDFromTheGalleryWithTheItems.ID;
           
            Value: DropDownWithTheChoiceLookUpColumn1.Selected.Result;
            LookUpColumn2: {
                '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference";
                Id: MyvarIDFromTheGalleryWithTheItems.ID;
                
                Value: DropDownWithTheChoiceLookUpColumn2.Selected.Value
            }
        ;ColumnWithText: TextInputUmaLinhaGerenteComercial.Text}
    }
)

 

On my "GalleryWithTheItems" I have this code:

 

Set(varMode;"Edit");;Set(MyvarIDFromTheGalleryWithTheItems;ThisItem);;Navigate(ScreenToEditItems)

 

On my dropdown I have this on Items:

Distinct( ListCollection;Title)

And the Value : 

Result


On my default: 

If(varMode="Edit";GalleryWithTheItems.Selected.LookUpColumn1.Value;"1")


I dont why powerapps dont update the item on SharePoint list.


14 REPLIES 14
WarrenBelz
Super User
Super User

@Gorilla_8 ,

Still using Lookup columns I see - please serious consider simply writing to Text fields - it is much easier and you do not need those columns unless you are using them directly in SharePoint in Data Sheet views. However in answer to your question, you need something like this

Patch(
   MySharePointList;
   {ID:GalleryWithTheItems.Selected.ID};
   {
      LookUpColumn1: 
      {
         Value: DropDownWithTheChoiceLookUpColumn1.Selected.Result;
         Id: 
         LookUp(
            ListCollection;
            Title = DropDownWithTheChoiceLookUpColumn1.Selected.Result
         ).ID
      },
      LookUpColumn2: 
      {
         Value: DropDownWithTheChoiceLookUpColumn2.Selected.Value;
         Id: 
            LookUp(
               ListCollection;
               YourOtherField = DropDownWithTheChoiceLookUpColumn2.Selected.Value
         ).ID
      }
   )
)

You need to reference the field looked up in ListCollection in both cases to "get the ID back". Before coming back, please try to understand the concept of what I have posted otherwise you will continue to struggle with this column type if you continue using them (I have not used them for many years).

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Gorilla_8
Impactful Individual
Impactful Individual

@WarrenBelz 

 

Thank for the help again.

 

I got this error: "...form have 'parlyclose' waited 'curlyclose' "

I got a search, and I understand your code, but when I got apply on my side:

"Id" doesn't exist, and show me to put "ID" instead, and after the "  Title = DropDownWithTheChoiceLookUpColumn1.Selected.Result ", I got those errors:

 

Gorilla_8_0-1632673223999.png

 

Gorilla_8_1-1632673259906.png

 

Gorilla_8_2-1632673283671.png

 

Gorilla_8_3-1632673344879.png

 

 

 

 

@Gorilla_8 ,

This is a Lookup column you are patching? If so Id has to exist. Also look at the code now (a slight mis-type before, but I thought you might pick this up). Can you please post (in formatted text) the actual code you are using.

Gorilla_8
Impactful Individual
Impactful Individual

@WarrenBelz 

 

No problem, here:

Patch(
   Temp_IntDeMercado_MercadoConsumo;
   {ID: GaleriaMercadoConsumo.Selected.ID};
   {
      Estado: 
      {
         Value: DropdownEstado.Selected.Result;
         Id: 
         LookUp(
            ListMCONS;
            Estado.Id = DropdownEstado.Selected.Result
         ).ID
      };
      Cidade: 
      {
         Value: DropdownCidade.Selected.Value;
         Id: 
            LookUp(
               ListMCONS;
               Cidade = DropdownCidade.Selected.Value
         ).ID
      }
   )
)

 

The column "estado" and "cidade" is a lookup column, I know he got a "Id", that's I dont get it..

 

He says the "Patch" got invalid arguments

@Gorilla_8 ,

Why are you looking up the Id? You need to look up the field in ListMCONS that matches the drop-down, so if it is Estado, you just need

Estado = DropdownEstado.Selected.Result

You will continue to have issues with this column type unless you either stop using it (which I recommend) or take some time to understand how it works.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

Gorilla_8
Impactful Individual
Impactful Individual

@WarrenBelz 

 

I got this code, and it's getting no error, but not updating the list

 

Patch(
    Temp_IntDeMercado_MercadoConsumo;
    {ID: GaleriaMercadoConsumo.Selected.ID};
    {
        Estado: {
            Value: DropdownEstado.Selected.Result;
            Id: LookUp(
                ListMCONS;
                Estado.Value = DropdownEstado.Selected.Result
            ).ID
        };
        Cidade: {
            Value: DropdownCidade.Selected.Município;
            Id: LookUp(
                ListMCONS;
                Cidade.Value = DropdownCidade.Selected.Município
            ).ID
        }
    }
)

 

@Gorilla_8 ,

Do you understand what this code is trying to do? You need to lookup the "other" list that is being looked up in SharePoint (is this ListMONS?) for the field (which must be Text, so .Value cannot be correct) and simply get the ID of that item. I urge you again to consider not using this field type - you simply do not need to do it.

Gorilla_8
Impactful Individual
Impactful Individual

@WarrenBelz 

 

Yeah, but if try with  result, didn't work 

@Gorilla_8 ,

If you are looking up the same list and that is being looked up in SharePoint in the Lookup field and get the ID of that item, the Patch back to the field should work. However why are you continuing to use Estado.Value = DropdownEstado.Selected.Result ? Are you not looking up a Text field here ?

 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

Power Platform release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Top Solution Authors
Users online (3,325)