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!
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 found this blog post the other day and you can’t imagine the thrill I felt 🙂
This is something I have wanted to be able to do so many times and didn’t know how to, now I do and I want you to do as well.
As you can see (and read in the blog post) the saveLocation is set from where the template is located. I did a little change to route the save location to a place I decided. I also added a little change to wait until the page is loaded before the function is executed, always a good thing to do.
This is the original code:
and this is my modified one with a hard coded save location:
Here is another one that prompts to save the document in the logged in users local Document library.
As always when we are working with jQuery you have to make sure that you reference the location of that .js-file
As you know when you add a web part to a library page, like Allitems.aspx or a page of a custom view that you’ve made, the ribbon gets wacky. That’s because it doesn’t know which web part it should have its focus on.
So what could we do if we really want some information, let’s say above the library web part?
And the information should be able to edit in an easy manner without using SharePoint Designer (SPD).
In this example I have a top site and underneath this I have some sub sites that are created from a site template I made. The things we are going to do now is made to that template so it could be reused.
First of all we have to edit the page’s code a bit, so bring up the page in your favorite editing tool SPD!
Find where the web part zone for the library begins and add two DIV’s right before it starts, like this:
PlaceHolderMain" runat="server"> <div id="success"></div> <div id="error"></div> <WebPartPages:WebPartZone runat="server" FrameType="None" ID="Main" Title="loc:Main">
As you can see I have added two DIV’s right after PlaceHolderMain with the ID’s of success and error. Don’t close this page, we are coming back here real soon.
What we are going to do now is to add some content to the success DIV.
First we need to have some content, right?
On the top site, let’s create a new Web Part Page, call it content.aspx and choose Full Page, Vertical.
Add a Content Editor to the page, click inside it, choose to Edit HTML Source…
…and paste this code:
</pre> <div id="<span class=">MyDiv"></div> <pre> The content within this DIV will be shown above the document library. <div> <ol> <li>To think about...</li> <li>And this as well...</li> </ol></div></div>
Ok, so now we have som content and as you can see the content is kept inside a DIV with the ID of MyDiv.
Now we are going back to the first page (where we have the library and added the two DIV’s) to add this information to the success DIV.
Let’s add som jQuery!
Find AdditionalPageHeader and add this code:
As you can see, first I have a reference to my jQuery file, you should replace the URL so that it corresponds to your environment.
Then in the next section we are loading the content in MyDiv into the DIV with the ID of success.
Now we are done!
Save all pages and try it, it should look something like this:
This way you can create new sites from this site template and just by editing the Content Editors in the page content.aspx you could update the contents on all sites.
Isn’t that nice?