Set default value for lookup parameter in Lightswitch

I’ve begun developing an IT Inventory project within Visual Studio Lightswitch, both for use and to learn the product so that I can use it on a new line-of-business application for my company.
While working through this, I came across the need to set a default value for a parameter and I struggled for a long time to find the answer.

 

Luckily there are great resources like Stackoverflow, which has given me an answer in less than 24 hours!

My full question (and the answer) can be found here: http://stackoverflow.com/questions/13710308/set-default-value-for-parameter-in-lightswitch but below is a little background on what I’m trying to do.

 

There are multiple “Companies” to which our assets can be assigned, but 90% of the assets belong to CompanyA. When opening my default screen that displays the list of inventory items, I want it to default to CompanyA, with an option to change it afterwards.

So I’ve created a Query on my data source, assigned a parameter, and then added the proper data objects within the screen to provide the filter. It was trying to set a default for that parameter which was causing me problems.

 

I’m actually quite impressed by LightSwitch; it has enabled me to build this Inventory application in less than a week’s worth of time. There have been some quirks to work around, and you’ll want to be sure that you have a final decision on what type of data source you’re using (SQL vs RIA Service in my case) before proceeding with lots of work since you can’t change the screen’s data source later.

I bring this up because I started using two SQL data sources which are separate databases but have a join. LightSwitch makes this a ‘virtual join’ and thus doesn’t allow you to make queries and filters on the second data source. I’ve since converted to a RIA Service and am now redeveloping the application.

 

 

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.