cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
RichardK
Level: Powered On

Default values from Sharepoint list

Generated powerapp from sharepoint list. Creating a new entry works fine but the few fields (two Choice, one date and one Number) that have default values in SP have no initialised value. I can set the default value of the number field directly and Today() for the date in Powerapp (not ideal as that duplicates the SP logic) but I can't put a text value in for lookup fields (The property expects record values, but this rule produces incompatible [Text|Number] values.)

 

Is there a way to get the SP defaults as would be expected?

2 REPLIES 2
Power Apps Staff rgruian
Power Apps Staff

Re: Default values from Sharepoint list

Please use the Defaults() function to produce a record consisting of default values for that data source.

https://powerapps.microsoft.com/en-us/tutorials/function-defaults/

 

Lookup fields are actually record (complex) values in PowerApps. You can think of them as partial rows from a second/foreign list, with as many values as needed to uniquely identify the target row(s). To see what those record values could/should be, please collect a row of data from your SP list into a collection, and inspect that collection's schema in the Collections tab.

 

    testButton1.OnSelect = Collect(tempCol, First(MySharepointList))

 

Inspecting the collection will reveal what is needed for your lookup values: most likely a record with '@odata.type', 'id', and 'title' fields.

 

 

Radu Gruian [MSFT] ** PowerApps Staff
RichardK
Level: Powered On

Re: Default values from Sharepoint list

Thanks Radu; I can't see how to 'use the Defaults() function'.

 

The generated app has this code in the OnSelect action for the new record button on the home screen:

 

NewForm(EditForm1);Navigate(EditScreen1, ScreenTransition.None)

 

The NewForm() function is supposed to use the defaults values... and it appears to be doing so - however ...

 

The only default value set in the SharePoint list that comes through onto a new form are those with static values: a number or text. The Choice field values do not appear. BUT, these default values do come through when the record is saved. It allows a work around that by taking off the 'required' flag in SharePoint I can have the app fill in the defaults on save - but it's not ideal as I'd like them displayed on loading the new form.

Helpful resources

Announcements
thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (6,165)