Out of the Box

Sharepoint / InfoPath: Use a Multiple Line of Text field in a Calculated Column

I stumbled upon this by accident. Try to do this by adding a multiple line of text field to a calculated column in SharePoint and it will tell you that it cannot be done. But it can with the use of InfoPath and some trickery:

For this example I will call the field that will be the multiple line of text field “Holder”.

1. Create a single line of text field and name it what you will be naming your multiple line of text field.

2. Create you calculated column and add the field you just create to it.

3. Open the form in InfoPath.

4. Delete the Single Line of Text field you just create and the publish.

5. In InfoPath create a Multiple Line of Plain Text field and name it EXACTLY the same as your old Single Line of Text field and publish once more.

You are now done and whatever you put in your multiple line of text field will show up in your Calculated Column.

Check out this post to see an example of this process in action

 

Posted in InfoPath, SharePoint | Tagged , , | 2 Comments

Sharepoint / Sharepoint Desginer / InfoPath: Create a dynamic link that opens a particular InfoPath view in a SharePoint dialogue box with it’s own edit icon

I found that I needed to have 2 views in SharePoint that both had an Edit Icon but each icon need to point to a different InfoPath view. I wanted the item to pop up in the dialogue box just like the normal edit icon did.  I took a look at how SharePoint was encoding theirs and was able to mimic it. Below you will find the solution.

The first part of this solution requires us to trick SharePoint into allowing the use of a Multiple Line of Text field in a Calculated column. We need to do this because the URL string you will be using is way over the 255 character limit of a single line of text field and SharePoint will not let you just add a Multiple Line of Text field to Calculated column.

1. Create a single line of text field (I called mine “Link Holder“).

2. Create a Calculated column (I named mine Edit Item)
– Add the Single Line of Text field (Link Holder)  to the Formula
– Set the data type as Number (for some reason this is the only way to make it read as html)
– Click Ok

3. In SharePoint Designer make a workflow that puts together the html you would like using the Set Field to value action.

Ex. Set Link Holder to <a href=”[Encoded Absolute URL]/../Item/editifs.aspx?DefaultView=ViewName&amp;ID=[ID]” onclick=”EditItemWithCheckoutAlert(event, ‘[Encoded Absolute URL]/../Item/editifs.aspx?DefaultView=ViewName&amp;ID=[ID]‘, ‘0’, ”, ”, ‘1’);return false;” target=”_self”><img border=”0″ alt=”Edit” src=”/_layouts/images/edititem.gif”></a>

In the above example I am pulling the main part of the url from the Encoded Absolute URL field and also the current item’s ID. Notice that this happens twice. I have inserted the name of my view where it says ViewName. Please note that the view name is case sensitive.

Once you publish this workflow and run it on your item you will see the edit icon shows up in your Calculated Column field and, when clicked, it opens a dialogue to the correct View of your InfoPath form.

 

Posted in InfoPath, SharePoint, SharePoint Designer | Tagged , , , | Leave a comment

SharePoint Designer: Create a dynamic link to your item in a workflow email using Encoded Absolute URL.

A better way to put a url in an email to the current item. Use the Encoded Absolute URL field.

Before I would do something like this for the url of the link that I wanted to send someone to edit:
https://sharepoint.school.edu/sitename/list/Item/Editifs.aspx?IsDlg=2&defaultview=VIEW&ID=[ID]

Now I put the following:
[Encoded Absolute URL]/../Item/Editifs.aspx?IsDlg=2&defaultview=VIEW&ID=[ID]

Using Encoded Absolute URL puts in a url that looks like this:
https://sharepoint.school.edu/sitename/list/#_.000

The “#_.000” doesn’t take you anywhere which is why in the new url you see the “/../“.

Note that you can also put Displayifs.aspx or any other page you want at the end and the url will still work.

 

Posted in SharePoint, SharePoint Designer, Uncategorized | Tagged , | Leave a comment

Critical Error: Internet Explorer 11 and SharePoint 2010

When Microsoft updated Internet Explorer to 11 we started getting the following error on our forms:

” Object doesn’t support property or method ‘addEventListener’ ”

We found that the fix is to add the following java script to the bottom of the Master Pages right above the </body> tag:

<script language=”javascript”>
/* IE11 Fix for SP2010 */
if (typeof UserAgentInfo.strBrowser !== ‘undefined’ && !window.addEventListener) {
UserAgentInfo.strBrowser=1; } </script>

The master pages can be found and edited via SharePoint Designer.

Note: This does not work for Window 8 systems using Internet Explorer 11 for some reason.

Posted in SharePoint, SharePoint Designer | Tagged , , , | 3 Comments

SharePoint: Get a calendar event (.ics) from a list item.

I needed to send a calendar event in an email that a workflow generated and thankfully SharePoint offers a really easy way to do this through the url:
https://<site url>/_vti_bin/owssvr.dll?CS=109&Cmd=Display&List=<list ID>&CacheControl=1&ID=<ID>&Using=event.ics
Replace the <bold> areas with your own info and you are ready to go.

The list ID will look something like this: D386DD15-6767-47E2-9743-28B7A24C905D

It can be found in the url for list settings: List=%7BD386DD15-6767-47E2-9743-28B7A24C905D%7D

 

Posted in SharePoint | Tagged , , , , | 2 Comments

Infopath: Get User Profile Data into your form

I needed to populate a drop down list with all the departments in my university (this is a field that is part of the user profile data.) Through my searching I stumbled through the UserProfileService.asmx and could not easily figure it out. I finally stumbled on a post from the famous Laura Rogers that explained a super easy way to access the information I wanted by pulling in the User Information List. I will put the pertinent parts below and will give a link to her blog post that covers it more in depth.

I am going to assume that you know how to create data connection.
In this case you will create a data connection to a SharePoint library or list then click next.

You will put in the url to your site collection (https://www.yoursite.edu/siteCollectionName/.) Then click next

You will then see list of all the lists or libraries you can choose from. Scroll all the way to the bottom and you should see User Information List. Choose that and click next.

You can then choose the field you would like to bring in. I just needed the Department field and checked that checkbox.
There ya have it.

There is on caveat that is worth noting: “If they are a new user, they will not show in this list until they’ve actually visited a site in that site collection.” I believe that by giving permissions to All Authenticated Users covered this for me as every department was present and I know for a fact that someone from every department has not visited the site collection, though that may not be true as I have no way of testing that theory.

Here is the link to Laura’s post about this:
 User Information within InfoPath Forms

Posted in InfoPath, SharePoint | Tagged , , , | Leave a comment

InfoPath: Calculate Age based on Date of Birth date picker.

I needed to calculate the age of a person to run some validation rules on my form. This is how I did it:

  • Create a Date Picker field (I named mine Birth Date) and place it on the form.
  • Create a Number field (I named mine Age.) You don’t have to place it on the form, though you can initially to make sure it is working.
  • Put the following rules on the Birth Date field:

Rule 1

Condition:
None

Action:
Set a field’s Value

Field:
Age

Value (click the fx button):
(substring(today(), 1, 4) – substring(Birth Date, 1, 4)) – 1 * (translate(substring(today(), 6, 5), “-“, “”) < translate(substring(Birth Date, 6, 5), “-“, “”))

* Birth Date is the name of your Date picker field.

 

Rule 2

Condition:

Age  is less than 0  ( should look like Age>0 when you hit ok)

Action:

Set a field’s Value

Field:

Age

Value:

0

 

There ya have it. This should give you the correct calculation.

Posted in InfoPath, SharePoint | Tagged , , , | 2 Comments

InfoPath: Validate that form has an attachment

I have found that I often need to make sure that people attach a file before they can submit. InfoPath will not let you run a rule on attachment fields however there is a way around it:

  • Create a single line of text field to use as the validation field (name is something like Attachment Validation). This field is also going to be the title text for the attachments field.
  • Place it on your form and remove the borders and shading.
    – go into text box properties under the Display tab and set it to Read Only
    –  then go to the Data tab and set its Default Value to the word “Attachment“.
  • Place a validation rule on this field. The condition should be The Expression and the expression should read like this:
    count(../my:Attachments/attachmentURL) = 0

The expression basically counts the number of attachments and if it equals 0 then it will put the red dashed line around the word Attachment.

 

I found the solution on Max Morrow’s site:
http://maxmorrow.wordpress.com/2012/05/03/infopath-2010-validating-the-attachments-field/

Posted in InfoPath, SharePoint | Tagged , , , | Leave a comment

SharePoint – InfoPath: Validate attachment URL for special characters

I did a ton of searching for this and could only find 1 solution. With this solution, if you have special characters in your file name and hit submit a warning pops up and tells you that  you have special characters in your file name. It will not let you submit the form until that is fixed.

The solution is as follows:

Create an InfoPath form the way you usually would.

In SharePoint, place an InfoPath form web part into a web part page.

Add a Content Editor web part and place the following JavaScript inside the html part of it.

You will need to replace the bolded id below with your own. That text is the id for your submit button. In most browsers you can right click on the submit button and click inspect element to find it. It is will read something like this: <input style=”text-align:center” onclick=”return (Button.OnClick(this, event));” onfocus=”return (Button.OnFocus(this, event));” id=”ctl…

———————————————————————————————————————————————————————————————————-

<script type=”text/javascript” src=”https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js”></script>
<script type=”text/javascript”>
$(document).ready(function(){
$(“input[id=’ctl00_m_g_ed36b5b8_a7c8_45d8_a19a_ac7017df0aff_FormControl0_V1_I1_B3‘]”).live(“mousedown”, function()
{

spans = $(‘li[scriptclass=”SharePointFileAttachmentContainer”]’).find(‘span[id^=”ctl00_m”]’).find(‘span’);
spans.each(function(){
// alert( $(this).text() );
specialcharecter($(this).text());

});
function specialcharecter(FileName)
{
var iChars = “!`@#$%^&*()+=’;,/{}|\”:<>?~”;
// var data = document.getElementById(“txtCallSign”).value;
var data = FileName;

for (var i = 0; i < data.length; i++)
{
if (iChars.indexOf(data.charAt(i)) != -1)
{
alert (“Attached file has special characters (ex. & # $ %). \nThese are not allowed.“);
// document.getElementById(“txtCallSign”).value = “”;
return false;
}
}
}

});
});
</script>​​​​

———————————————————————————————————————————————————————————————————-

The bolded area above next to “alert” is the text that will display upon submit if there are special characters in the file name.

Here is the link to the answered post in which I found the solution:
http://social.msdn.microsoft.com/Forums/sharepoint/pt-BR/c9ebf3fc-062c-4ad6-9d0d-fde440e0edff/sharepoint-info-path-form-attachment-file-name-should-not-contain-special-character-

Posted in InfoPath, SharePoint | Tagged , , | Leave a comment

SharePoint: Duplicate or Copy a Page

I created a web part page added a list view and then added content web part and created some CSS tweaks to the page. I then wanted to use those same tweaks but to a different view of the list. I needed to duplicate the page. SharePoint does not offer an easy way to do this. First I tried downloading the page, renaming it and re-uploading it. The re-uploaded page didn’t keep my web parts. This is how I did it:

Click on Site Actions

Click on Site Settings

Under Site Administration click on Content and structure.

You can now see a file structure of your site.

Click on the document collection that your page is in.

Check the check box beside the page you want to duplicate.

Click on Actions

Click on Copy…

Copy your page to another document library ( it wont let you copy to the same library).

Rename it and copy the renamed file back.

You have now duplicated the page!

Posted in SharePoint | Tagged | 7 Comments