Query and filter on related columns

Hi everyone!

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.

CU!

/Niax

Advertisements

Multiple submits

Hi everyone!

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.

CU!

/Niax


Add a button to a repeating table to copy row data

Hi everyone!

I will show you how to add a button to a repeating table and be able to copy information from that row to other fields.

Create a list in SharePoint and name it Location with three columns, Title, Region and City.

Add a data connection to your form to receive information from this list in SharePoint. Now when you have your repeating table as a secondary source, highlight it and drag it to your form.

Put your cursor somewhere in the column for ID, right click and choose DeleteColumns, now you only have the Title, Region and City columns left.

Now put the cursor somewhere in the City column, right click and choose Insert – Columns to the right.

It should now look like this

Now add a button in the field next to the City field.

Add three Text Box fields somewhere in your form and name them MyTitle, MyRegion and MyCity.

Highlight the button and click Manage Rules in the ribbon. Create a new Action rule to set a field’s value. It should look like this.

The Value is built by adding the function current(), then a slash “/” and lastly, add the field Title from your secondary source Location.

Repeat this step twice so that you get a value for each of your three fields. You should now have three actions in your rule, like this.

That’s it, this is how it could look.

CU

/Niax

 


Need a link to create a new document from an Office template?

Hi everyone!

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:

<script type="text/javascript" src="/_layouts/jquery.min.js"></script>
<script type="text/javascript">
$( function () {
$("a[href$='.dot'], a[href$='.dotx'], a[href$='.xlt'], a[href$='.xltx']").attr("onclick", "").click( function () {
saveLocation = $(this).attr("href").split("/").slice(0, -2).join("/")
createNewDocumentWithProgID(window.location.protocol + '//' + window.location.host + $(this).attr("href"), window.location.protocol + '//' + window.location.host + saveLocation, 'SharePoint.OpenDocuments', false)
return false
})
})
</script>

and this is my modified one with a hard coded save location:

<script type="text/javascript" src="/Style%20Library/Scripts/jquery-1.4.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("a[href$='.dot'], a[href$='.dotx'], a[href$='.xlt'], a[href$='.xltx']").attr("onclick", "").click( function () {
createNewDocumentWithProgID(window.location.protocol + '//' + window.location.host + $(this).attr("href"), makeAbsUrl('http://MyIntranet/sitename/sitename/librar%20name'), 'SharePoint.OpenDocuments', false)
return false
})
})
</script>

Here is another one that prompts to save the document in the logged in users local Document library.

<script type="text/javascript">
$(document).ready(function(){
$("a[href$='.dot'], a[href$='.dotx'], a[href$='.xlt'], a[href$='.xltx']").attr("onclick", "").click( function () {
createNewDocumentWithProgID(window.location.protocol + '//' + window.location.host + $(this).attr("href"),'C:\Users\{login}\Documents' , 'SharePoint.OpenDocuments', false)
return false
})
})
</script>

As always when we are working with jQuery you have to make sure that you reference the location of that .js-file

CU

/Niax


Validation in InfoPath

Hi everyone!

Due to a discussion in a thread at Microsoft Forum, I decided to create a post about a couple of ways to handle validation in InfoPath.

The two ways I will show you are these:

  • Disable a button until all questions are answered.
  • Showing a message if a question is missed.

This is the how the form looks like.

As you can see we have a couple of questions to answer and then we can move on to the next view to continue with more questions. To stop the user from being able to go to the next view we could disable the button, this is how.

First click on the button Next view, and then on Manage Rules in the ribbon.

Now for the button Next view create a Formatting rule called DisableButton, that looks like this.

Now the button can’t be used until Question1 and Question2 is answered. Use Prereview to make sure it works.

Ok, so now lets move over of how to show a message if the user missed to answer a question. First you have to delete the rule from the previous example.

These are the fields in the form.

First of all, above the button I have placed the field called Message, and it is formatted like this.

No border, read only and with the same color as the rest of the cell, this way it’s invisible until a message is written to it.

As before, choose Manage Rules for the button Next view, this time create two Action rules.

The first rule I name Message_Blank and this rule looks like this.

As you can see I use the action Set a field’s value and the only thing we do here is to set the field Message to nothing/blank. You should not add the apostrophes, InfoPath will do that for you, just leave the field blank.

Now we need to create one more rule to show the message. Let’s call it Message_Error, it’s the same kind of rule with a few differences and it looks like this.

As you can see we I have a condition, the message is not blank, but actually holds the text we would like to show the user. And last but not least, I have check marked Don’t run remaining rules… That is because the last rule this button should have is to switch view, but not if this rules condition is met.

This is how it will look like if the user trys to move on before all questions are answered.

That’s it!

Try it in preview to make sure you done it the right way.

CU!

/Niax


Add customizable information to a library page

Hi everyone!

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:

<asp:content contentplaceholderid="PlaceHolderAdditionalPageHead" runat="server">
 <SharePoint:RssLink runat="server"/>
<script type="text/<span class=">// <![CDATA[
javascript</span>" src="/sitename/Shared%20documents/jquery-1.6.2.min.js">
// ]]></script>
<script type="text/javascript">
 $(document).ready(function() {
 $("#success").load("/sitename/sitename/SitePages/content.aspx #MyDiv",
 function(response, status, xhr) {
 if (status == "error") {
 var msg = "Page is missing: ";
 $("#error").html(msg + xhr.status + " " + xhr.statusText);
 }
 });
});
</script>
</asp:content>

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?

CU!

/Niax


Open an InfoPath form in a dialog

Hi everyone!

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:
<div> <a href="javascript:{ SP.UI.ModalDialog.OpenPopUpPage('/sitename/_layouts/FormServer.aspx?XsnLocation=/sitename/library/forms/template.xsn&OpenIn=browser&SaveLocation=/sitename/library', null, 1000); };">Open form</a></div>
  • Replace sitename and library with the ones in your environment.
  • Click Save and OK in the web part and try it out!

Thats it!

/Niax