It’s been a long time since the last post, but sometimes one has to take care of things like the family. Ok, so now when that is done we could start having some fun again 🙂
I would like to start with a small and quick one.
Let’s say you have a drop down (field2) in your form that lists objects from a list in SharePoint. The list has got two columns, Title and Number.
The value for the drop down is set to Number and the Display name is set to Title.
Then you need to set another field (field3) in your form to the value of the chosen object,.
Set the Value of field3 to be same as field2
that’s when you will see that the number of the object will have lots of trailing zeros.
An easy way to get rid of these zeros is to insert a formula in front of the field2 value of sum.
this way the zeros will be gone.
I would like to show you how to work with lookup columns between lists when you i.eg. would like to summarize the amount of orders that a sales person have made.
So we have a list called “Sales persons” with five columns, “Name”, “Region”, “Office”, “Sales ID” and “TotalAmount”.
We also have a list called “Sales orders” with three columns, “Product”, “Amount” and “Sales ID”.
In this list the column “Sales ID” is a lookup column to “Sales ID” in “Sales person”.
We also have a data connection to retrieve these three fields from “Sales orders”.
When we open a form for a sales person we want to see the total amount of orders that’s been made by that person. When we first look at this it looks quite simple. The “TotalAmount” should be the sum of “Amount” where “Sales ID” equals “Sales ID”, right?
The problem here is when we work with lookup columns it is not actually the value of the look up that is brought to your repeating table by your data connection, it is in fact the “ID” of the item in that list.
So to filter which amounts to summarize we should do like this:
The “TotalAmount” should be the sum of “Amount” where “ID” equals “Sales ID”.
Now when we open the form of a sales person, we could see the total amount that person has sold for.
Hope this helps someone!
You all know the great thing with InfoPath, how easy it is to work with cascading drop-downs. I would like to share one more thing with you in this area, how you could show different images depending on your choice in the drop-down.
I will very shortly describe how to set up cascading drop-downs, the main thing here is to give you the way to show the different images.
The drop-downs (2) is received from a SharePoint list with three columns “Tillverkare”, “Modell” and “Bild” (that is Manufacturer, Model and Picture, in english).
The configuration of the first drop-down looks like this.
The second drop-downs configuration looks like this.
Notice the lower circle, the next picture will show what to do when you press the button of the upper circle.
- Press the button to choose from your secondary data source
- A difference from the first drop-down is that you need to add a filter, so press the button “Filter data…”
- Add a filter where you say that Tillverkare (Main data source) is equal to Tillverkare (second data source)
Ok, so now lets move on to how to make this true for an image as well.
My list in SharePoint also has a third column called “Bild” (picture in english) and we want this picture to be changed depending on what Modell we choose.
Now lets add a Picture control to your form and open the properties of the picture.
You will see a default XPath to the picture control it self. Press the button to the right of the XPath and point to your secondary data source and your picture column. Now, as you see where the cross is, we would have wanted a button to add a filter, but it’s gone 😦
Instead we will use the filter from drop-down 2 as I will show you in a minute. For now, highlight your picture column in your data source and press OK. Also notice that you should set the picture to be Read only.
Open the properties of the second drop-down and copy the the part of the XPath that holds the filter.
[xdXDocument:get-DOM()/dfs:myFields/dfs:dataFields/my:SharePointListItem_RW/my:Tillverkare = d:Tillverkare]
Add this at the end of the XPath for the picture control and replace “Tillverkare” with “Modell”. Now you have a filter for you picture control as well.
To avoid having to see the picture controls icon in the form when no “Modell” is choosen, put a formatting rule on it that has the condition “when Modell is blank” hide this control.
When you publish this form you will probobly get an error that looks like this.
But go ahead and publish anyway and you will see that it works.
For a full blog post about setting up the cascading drop-downs you should read this blog post at Koobar’s Point.
I hope this helps someone sometime…
I want to give you a way to filter a repeating table with the help of a drop down.
Let’s say you have a list with with a column called Requests and one column that is called Defects. You could have multiple defects for a request and now you only want to show thoose defects for the request you have choosen.
First add a data connection to receive these three columns from your list.
On your form, add a drop down and configure it like this.
Now add this secondary data source as a repeating table to your form and delete those columns you don’t need to show in the form. Deleting them from the form doesn’t mean that you delete them from the data source, they will still be there if you need them. Afterwards it could look like this.
Let us add the rule to the repeating table that will do the trick.
Highlight the repeating table and click the button Manage rules in the ribbon. Add a new Formatting rule that looks like this.
The condition says: When”Request” in the secondary data source “is not equal to” the “MainRequest” in the main data source.
Now when you test the form you will be able to see only those defects that belongs to the request you choose.
I thought I would give you a way to handle multiple submits in a form. Lets say you have a form that should be filled by both students and ordinary attendees. There are some fields that are specific to the students like name of school and name of education and for the attendee we might have fields like title and name of company. When they make the submit we want to make sure all required fields are filled, but only the required fields for that kind of person.
First of all the person should make a decision if he is a student or an attendee, the form could look like this.
When the person clicks one of the buttons a field named listener is set to Attendee or Student. This decides which fields (or sections) that are displayed on the form. To handle the submit and validation of fields I have two submit buttons that looks the same but have different rules applied to them. They are both hidden if listener is blank or is set to the other buttons value.
Here is how it looks in design mode where both submit buttons can be seen and you also can see the message that is thrown if not all required fields are filled.
I think it’s a pretty easy way to accomplish what I was looking for and should be pretty simple for any one to use as well.
I would like to share with you how you could open a form in a dialog in SharePoint.
- Add a Form web part on a page of your choise.
- Replace the code with this:
- Replace sitename and library with the ones in your environment.
- Click Save and OK in the web part and try it out!