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.
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.
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

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (4,359)