cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Erec
Frequent Visitor

Powerapps saving combo box default value (no user selection made)

Hi

 

In my Powerapp I am setting the default value of a combo box to a global variable within the app. This is working ok, however, when I save the record it does not save and no error message is returned. The form continues as if the record saved correctly.

 

My question is. How to correctly set the value of the combo box so that when not changed by the user and saved. It saves?

 

To set the default value, I am setting the DataCard default to:

{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.lsTSDetails",
  id:0,
  Value:Text(varMainID)}

The update of the datacard is set to:

DataCardValue5.Selected

 

I have set the combobox defaultSelectedItems to:

{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.lsTSDetails",
  id:0,
  Value:Text(varMainID)}

 

I have looked around the forums and cannot find a solution that works relating to the Saving of the default value.

 

Any help appreciated.

 

Thanks

8 REPLIES 8
v-micsh-msft
Community Support
Community Support

Would you please share more details about the field that the Combo Box control bound with, is it a Lookup, Choice or Person or group type?

 

The '@odata.type' would vary based on the data field you are working with.

And I have never experienced with a value for 

"'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.lsTSDetails"

 

It would be much appreciated if you could share more details for this field type, I will then test it and share the results back.

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Micahel

 

Yes the field defined in the SharePoint list is a Lookup field.

 

A little background.

I have an app where I am capturing main details for the data (varying fields) and also detail items/transactions that are linked to the main details. I save the main details first via the standard SubmitForm and then store the Last id into a variable. On the details form I have a combo field of type lookup that lists all the id values. I never want the user to enter this value. I want to default it and then save it with no user interaction. Despite the value being shown in the combo box it does not save unless if you click on it and select it.

 

Thanks

 

EREC

Erec
Frequent Visitor

Hi Michael

 

Did you have the opportunity to see if you were able to replicate my issue and resolve?

 

Do you need any additional information?

 

Thanks

Eickhel
Most Valuable Professional
Most Valuable Professional

Hey,

 

as @v-micsh-msft said, I've neved seen that odata.type, for LookUps I use this:

 

For defaultSelectedItems should be:

Text(varMainID)

 

And for the update of the datacard you should use:

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

 

 Let me know how it goes...

Erec
Frequent Visitor

Hi

 

I have tried to implement your suggestion. The DefaultSelectedItems requires that the value passed is a Table value. VarMainID is of type numeric. So i tried a couple of combinations using:

 

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

in the DefaultSelectedItems replacing value with Text(VarMainID) and changing the Update of the DataCard to your suggestion without any success.

 

Is there a different approach I should use to achieve objective? The only way i can currently think of is to use one table to store the data oppose to splitting into two tables. It would be nice to know a solution to the original problem, if there is one?

 

Thanks

Eickhel
Most Valuable Professional
Most Valuable Professional

Please give me more info on the global variable "VarMainID". Is this the Id of an existing record in the LookUp?

 

Let's try a different approach, asumming this information:

 

List: TravelExpenses

LookUpField: ReceiptType

 

Combo Box: ReceiptTypeCombo

Items: Choices( TravelExpenses.ReceiptType )

DefaultSelectedItems: TravelExpenses.ReceiptType

 

DataCard:

Update: ReceiptTypeCombo.Selected

 

When do you want to use this default "VarMainID"? I guess only on new records?

I ran into this, too. I have a singe item Combo Box control set up. When I round-trip data, if the user doesn't change the value during the edit, it saves an empty record.

 

 I was using this to set the DefaultSelectedItems:

[ThisItem.myDataField]

With my DataCard Update:

ComboBox1.Selected.Result

It took me a while, but I realized these are obviously different. DefaultSelectedItem(s - plural) is certainly not ComboBox1.Selected (not plural) lol.. 

 

I first came up with:

First(ComboBox1.SelectedItems).Result

Which let me get the SelectedItems from the table format into text. However, again, if I didn't interact with the Combo Box, this was blank.

 

The only way (I could come up with) to get the present value was at the the Data Card, and basically ignore the Combo Box:

ThisItem.myDataField

Which took me down a crazy rabbit hole of nested If() And() functions for the Update:

If(
    And(
	!IsBlank(ThisItem.myDataField),
	IsBlank(ComboBox1.SearchText),
	IsBlank(ComboBox1.Selected.Result)
    ),
    ThisItem.myDataField,
    And(
	!IsBlank(ComboBox1.SearchText),
	IsBlank(ComboBox1.Selected.Result)
    ),
    ComboBox1.SearchText,
    ComboBox1.Selected.Result
)

This allows me to have the present value already selected on my Combo Box, and re-save the record without any changes. Or I can select a different value, or type a new one completely. The only thing I can't do with this is clear the value, for my needs this wouldn't be an option anyway once it was set. 

Luckily I am working with a single item ComboBox, I can't imagine trying to do this with multiple. LOL

ewfefwef
Advocate II
Advocate II

Same issue after following this great article on how to do this 

https://jobs.collab365.community/powerapps-and-related-lists/

 

Everything works unless the user doesn't select the dropdown.

So the default value is not working and you this scenario you want to hide the drop down and always have it use the default.

According to article, you should use 

DataCard : Default

{
ID : varParentItem.ID,
Value : varParentItem.ID
}

But it doesn't worked, tried many ways around this. Microsoft need to make this simple feature easier.

 

So need a solution to link 2 sharepoint lists.

Expense Report and

Expense Items.

One simple 1 to many relationship

Helpful resources

Announcements

Celebrating the May Super User of the Month: Laurens Martens

  @LaurensM  is an exceptional contributor to the Power Platform Community. Super Users like Laurens inspire others through their example, encouragement, and active participation. We are excited to celebrated Laurens as our Super User of the Month for May 2024.   Consistent Engagement:  He consistently engages with the community by answering forum questions, sharing insights, and providing solutions. Laurens dedication helps other users find answers and overcome challenges.   Community Expertise: As a Super User, Laurens plays a crucial role in maintaining a knowledge sharing environment. Always ensuring a positive experience for everyone.   Leadership: He shares valuable insights on community growth, engagement, and future trends. Their contributions help shape the Power Platform Community.   Congratulations, Laurens Martens, for your outstanding work! Keep inspiring others and making a difference in the community!   Keep up the fantastic work!        

Check out the Copilot Studio Cookbook today!

We are excited to announce our new Copilot Cookbook Gallery in the Copilot Studio Community. We can't wait for you to share your expertise and your experience!    Join us for an amazing opportunity where you'll be one of the first to contribute to the Copilot Cookbook—your ultimate guide to mastering Microsoft Copilot. Whether you're seeking inspiration or grappling with a challenge while crafting apps, you probably already know that Copilot Cookbook is your reliable assistant, offering a wealth of tips and tricks at your fingertips--and we want you to add your expertise. What can you "cook" up?   Click this link to get started: https://aka.ms/CS_Copilot_Cookbook_Gallery   Don't miss out on this exclusive opportunity to be one of the first in the Community to share your app creation journey with Copilot. We'll be announcing a Cookbook Challenge very soon and want to make sure you one of the first "cooks" in the kitchen.   Don't miss your moment--start submitting in the Copilot Cookbook Gallery today!     Thank you,  Engagement Team

Announcing Power Apps Copilot Cookbook Gallery

We are excited to share that the all-new Copilot Cookbook Gallery for Power Apps is now available in the Power Apps Community, full of tips and tricks on how to best use Microsoft Copilot as you develop and create in Power Apps. The new Copilot Cookbook is your go-to resource when you need inspiration--or when you're stuck--and aren't sure how to best partner with Copilot while creating apps.   Whether you're looking for the best prompts or just want to know about responsible AI use, visit Copilot Cookbook for regular updates you can rely on--while also serving up some of your greatest tips and tricks for the Community. Check Out the new Copilot Cookbook for Power Apps today: Copilot Cookbook - Power Platform Community.  We can't wait to see what you "cook" up!      

Tuesday Tip | How to Report Spam in Our Community

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   Today's Tip: How to Report Spam in Our Community We strive to maintain a professional and helpful community, and part of that effort involves keeping our platform free of spam. If you encounter a post that you believe is spam, please follow these steps to report it: Locate the Post: Find the post in question within the community.Kebab Menu: Click on the "Kebab" menu | 3 Dots, on the top right of the post.Report Inappropriate Content: Select "Report Inappropriate Content" from the menu.Submit Report: Fill out any necessary details on the form and submit your report.   Our community team will review the report and take appropriate action to ensure our community remains a valuable resource for everyone.   Thank you for helping us keep the community clean and useful!

Community Roundup: A Look Back at Our Last 10 Tuesday Tips

As we continue to grow and learn together, it's important to reflect on the valuable insights we've shared. For today's #TuesdayTip, we're excited to take a moment to look back at the last 10 tips we've shared in case you missed any or want to revisit them. Thanks for your incredible support for this series--we're so glad it was able to help so many of you navigate your community experience!   Getting Started in the Community An overview of everything you need to know about navigating the community on one page!  Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Community Ranks and YOU Have you ever wondered how your fellow community members ascend the ranks within our community? We explain everything about ranks and how to achieve points so you can climb up in the rankings! Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Powering Up Your Community Profile Your Community User Profile is how the Community knows you--so it's essential that it works the way you need it to! From changing your username to updating contact information, this Knowledge Base Article is your best resource for powering up your profile. Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Community Blogs--A Great Place to Start There's so much you'll discover in the Community Blogs, and we hope you'll check them out today!  Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Unlocking Community Achievements and Earning Badges Across the Communities, you'll see badges on users profile that recognize and reward their engagement and contributions. Check out some details on Community badges--and find out more in the detailed link at the end of the article! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Blogging in the Community Interested in blogging? Everything you need to know on writing blogs in our four communities! Get started blogging across the Power Platform communities today! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Subscriptions & Notifications We don't want you to miss a thing in the community! Read all about how to subscribe to sections of our forums and how to setup your notifications! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Getting Started with Private Messages & Macros Do you want to enhance your communication in the Community and streamline your interactions? One of the best ways to do this is to ensure you are using Private Messaging--and the ever-handy macros that are available to you as a Community member! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Community User Groups Learn everything about being part of, starting, or leading a User Group in the Power Platform Community. Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Update Your Community Profile Today! Keep your community profile up to date which is essential for staying connected and engaged with the community. Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Thank you for being an integral part of our journey.   Here's to many more Tuesday Tips as we pave the way for a brighter, more connected future! As always, watch the News & Announcements for the next set of tips, coming soon!

Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp  

Top Solution Authors
Top Kudoed Authors
Users online (6,160)