cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

how to save a selected value from the Canvas app to the look up field in the SharePoint list?

Dear all, 

 

I have created a lookup column (name: Testing2) in the SharePoint list that looks for values in the other SharePoint list. This lookup column field was added to the Canvas app, and I modified its Items function to depend on another field's value:

 

 

 

(Items = 
Sort(
Filter(
AdditionalSPList,
Factory = cmb_Name.Selected.Result
).Material,
Ascending
)

 

 

 

The update function was unchanged: DataCardValue14.Selected


With this configuration, the selected item in the Canvas app field is not saved to the SharePoint. If leave Items function unmodified (original Items function is = Choices([@'MT'].Testing2), then the selected item is uploaded correctly.


Could someone please if it is possible to filter Items in the canvas app field and save the selected item to the SharePoint lookup column and how?

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@Anonymous 
If testing2 is a lookup column, then when you use Choices on that column for your items, you are really getting a table returned from that which has records with two columns - the Id of the record in the lookup list and the value of the record column from the lookup list.

When you give the formula you show to the Item, it will return a table with a single column called Material.  When you go to update, then record schemas will not match and you will not get anything saved.

 

So, your formula also will not include the Id of the record...which is needed, so changing the Update of the datacard alone will not be helpful.

 

You can either change your Items formula to the following:

ForAll(
    Sort(
        Filter(AdditionalSPList,
            Factory = cmb_Name.Selected.Result
        ),
        Material
     ),
     {Value: Material,
      Id : ID
     }
)

Note: this will return a table of records with a Value and Id (what is needed for a lookup column)

No other changes are needed.

 

OR, you can change the Items property to:

Sort(
     Filter(AdditionalSPList,
         Factory = cmb_Name.Selected.Result
     ),
     Material
)

and then change your Update formula on the datacard to:

{
    Value: DataCardValue14.Selected.Material,
    Id : DataCardValue14.Selected.ID
}

This will provide a record with the correct schema for the lookup column.

 

I hope this is helpful for you.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

1 REPLY 1
RandyHayes
Super User
Super User

@Anonymous 
If testing2 is a lookup column, then when you use Choices on that column for your items, you are really getting a table returned from that which has records with two columns - the Id of the record in the lookup list and the value of the record column from the lookup list.

When you give the formula you show to the Item, it will return a table with a single column called Material.  When you go to update, then record schemas will not match and you will not get anything saved.

 

So, your formula also will not include the Id of the record...which is needed, so changing the Update of the datacard alone will not be helpful.

 

You can either change your Items formula to the following:

ForAll(
    Sort(
        Filter(AdditionalSPList,
            Factory = cmb_Name.Selected.Result
        ),
        Material
     ),
     {Value: Material,
      Id : ID
     }
)

Note: this will return a table of records with a Value and Id (what is needed for a lookup column)

No other changes are needed.

 

OR, you can change the Items property to:

Sort(
     Filter(AdditionalSPList,
         Factory = cmb_Name.Selected.Result
     ),
     Material
)

and then change your Update formula on the datacard to:

{
    Value: DataCardValue14.Selected.Material,
    Id : DataCardValue14.Selected.ID
}

This will provide a record with the correct schema for the lookup column.

 

I hope this is helpful for you.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

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.

<
Users online (4,163)