cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
skylitedave
Level 10

Ability to set a default value for a Sharepoint Choice field mapped to DataCard in a PowerApps Form

Ability to set a default value for a SharePoint choice field mapped into a datacard within a PowerApps form.

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Ability to set a default value for a Sharepoint Choice field mapped to DataCard in a PowerApps F

PowerApps doesn't set the SharePoint defaults in the UI. There is a workaround and since choice column is a complex field type it is going to look a little different. Try setting the Default property of the DataCard for your choice field to something like this:

 

If(SharePointForm1.Mode = New, {'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
   Id:0,
  Value:"Orange"}, 
ThisItem.TestChoice)

In this example the default value is only being set if it is a new item and "Orange" is the default value I wanted to set.



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly.
If you thought this post was helpful, please give it a Thumbs Up.
27 REPLIES 27
Super User
Super User

Re: Ability to set a default value for a Sharepoint Choice field mapped to DataCard in a PowerApps F

PowerApps doesn't set the SharePoint defaults in the UI. There is a workaround and since choice column is a complex field type it is going to look a little different. Try setting the Default property of the DataCard for your choice field to something like this:

 

If(SharePointForm1.Mode = New, {'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
   Id:0,
  Value:"Orange"}, 
ThisItem.TestChoice)

In this example the default value is only being set if it is a new item and "Orange" is the default value I wanted to set.



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly.
If you thought this post was helpful, please give it a Thumbs Up.
skylitedave
Level 10

Re: Ability to set a default value for a Sharepoint Choice field mapped to DataCard in a PowerApps F

Thx

 

I actualy just came up with a similar solution (using Parent.Default.Value for the ID) but there is a hitch...

 

This works to set the default of the Lookup field created when you add the Choice field

 

      If( Project_Detail_XRM_1.Mode = FormMode.New,

         { '@odata.type' : "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
            Id : Parent.Default.Value,
            Value: "None"},

      ThisItem.ParentP)

 

Where "None" is the default and a valid entry for the choice field in SharePoint ....

 

This issue is the user must still SELECT a value from the lookup on the form.  If you try and just save without actually selecting an item from the lookup then the form throws and error ( and this is not a required field on the form) ... 

 

Again, I can get the default to show up in the lookup in the new form,  but the user must select an item from that lookup field ( choice field) since the Update in the card holding the lookup (choice field)  is asking for "Lookup.Selected" .... you follow...  

 

Do you know what needs to be put into the update of the Card holding the lookup associated with this choice field if the default is set using the technique above and the user never updates it via selecting the dropdown in that lookup field..  meaning they just accept the default entry using the technique above without selectingthe lookup dropdown...  This is the problem...

 

Thx!

 

 

 

 

 

Super User
Super User

Re: Ability to set a default value for a Sharepoint Choice field mapped to DataCard in a PowerApps F

I am using the code example I posted and I am able to save a new form without ever selecting the choice field and when the form is saves the choice field gets saved with the default "Orange"..



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly.
If you thought this post was helpful, please give it a Thumbs Up.
skylitedave
Level 10

Re: Ability to set a default value for a Sharepoint Choice field mapped to DataCard in a PowerApps F

Update Smiley Happy

 

I just tried your approach and using the ID set to 0 makes this work!  Here is the code ( as you said...)

 

   If( Project_Detail_XRM_1.Mode = FormMode.New,

     {'@odata.type' : "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
     Id : 0,
    Value: "None"},

   ThisItem.ParentP)

 

Where "None" is the default i want in the lookup (choice field) in Powerapps when a new form is created

 

For anyone stuggling with this....

 

Put this code into the dropdown default property within the card and then keep the update of the card as the dropdown_in_the_card.selected and the user does not need to pick anything in the choice list and the default works....

 

Just make sure to supply a valid default ( "None" im my case) in the formula above ( a value that is entered as a choice in the SharePoint field definition).

 

YAY!!!! and thx

 

I have been playing with this for a day to try and get it to work... many thx! 

 

 

skylitedave
Level 10

Re: Ability to set a default value for a Sharepoint Choice field mapped to DataCard in a PowerApps F

just to clarify

 

Put this code into the dropdown default property of the dropdown field within the card and then keep the update of the card as the dropdown_in_the_card.selected and the user does not need to pick anything in the choice list and the default works...

 

This is greast.. have not seen this posted elsewhere and it is needed Smiley Happy

 

Thx again..  will mark as the solution!

Zorro26632
Level: Power Up

Re: Ability to set a default value for a Sharepoint Choice field mapped to DataCard in a PowerApps F

I have been struggling with this same issue, and I need more clarification: very sorry.

 

There is the DataCard, and there is the DataCardValue. I have not changed the default in the DataCardValue which refers to the Parent.Default. If I put the above code into the Default of the DataCard, then I see the default information. But when I do a SubmitForm the default is not being written to SharePoint, which is the same issue as listed earlier in the thread.

 

What am I missing?

 

 

skylitedave
Level 10

Re: Ability to set a default value for a Sharepoint Choice field mapped to DataCard in a PowerApps F

I am guessing there is something missing in the Update Property of the datacard since the default choice is displaying properly.  Inspect the update  property of the datacard and make sure you are setting update to be to the selected value of the dropdown control within the datacard.

 

Let me know if this solves your issue

wnzn
Level 8

Re: Ability to set a default value for a Sharepoint Choice field mapped to DataCard in a PowerApps F

Just wanted to add: if you start from a SharePoint choice field and have that auto populated on your form, PowerApps chooses combo box as control. Then you'll have to set the default value with the same code but in the "DefaultSelectedItems" field, not the "Default" field.

viciouschloe
Level: Power Up

Re: Ability to set a default value for a Sharepoint Choice field mapped to DataCard in a PowerApps F

I'm having the same issue.  The code works right, everything seems set right including the card update field.  When I save, it saves the record, but not a value in this column.  Smiley Sad  Very frustrating.  This type of thing seems like it shoudl be easier.