Tuesday, September 15, 2015

Locked File in SharePoint

Locks on files appear when you are using a client application to edit the file. This is normal and expected.


This is not the same as a check-out. You can find more information about this on the following link:
http://www.novolocus.com/2012/07/25/sharepoint-check-out-vs-lock/


Sometimes the lock goes away after around 10 mn after you close the client application.
If this was not the case, then you could use this tool to release this lock:
http://think4code.blogspot.pt/2012/07/sharepoint-2010-file-is-locked-for.html


Download tool: https://spunlockfiles.codeplex.com/

Tuesday, July 7, 2015

Creating a Stoplight Color Coded Status in a SharePoint List

Link to Article


Creating a Stoplight Color Coded Status in a SharePoint List
Recently I was tasked with creating a report for our PMO that showed information about all of our current projects and a stoplight status indicator on whether the project was on track or not. After doing some research online, I found out that I could create a calculated field based on a status and display a colored circle that will help executives quickly view the status of each project. I have created a tutorial to show the steps, so that you can create your own colored status field in SharePoint.
In our case we used the following status codes:
  • Green = Project is on track
  • Yellow = Project is falling behind
  • Red = Project is behind
  • Purple = Project is on hold
Important Note: For the calculated field to work, you will need to make sure that your Status field contains a number, because we will base the color selected on this number. See the Status column in the screen cap in step #1 below.
  1. Navigate to List Tools -> List -> List Settings.
    SharePoint List Settings
  2. Click on Columns -> Create Column.
  3. Enter the Column Name, select Calculated as the field Type.
    SharePoint Calculated Column
  4. Enter in the following Formula and click the OK button.
    Note: that the formula is selecting the 1st character of the value in the Status Column “LEFT(Status,1)“. If the number in your status field is in a different location you may have to adjust the formula a little to get the correct result. The number in the status column is then used in the CHOOSE() function to determine which color should be used. In our example if the number is 1 then it will be green, if the number is 2 the color will be orange and so on.
    SharePoint Calculated Field Formula
  5. ="<DIV style='font-weight:bold; font-size:24px; font-size:24px; color:"&CHOOSE(LEFT(Status,1),"green","orange","red","purple")&";'>•</DIV>"



  6. You will notice that our Stoplight column displays the HTML code we entered in the Formula field rather than actually displaying our colored circles. This is because we still have one more setting to change…
    SharePoint Unformated HTML
  7. Navigate to Site Actions -> Edit Page and click the Add A Web Part link.
    Site Actions Edit Page
  8. Select the Content Editor Web Part from the Media and Content Category and click the Add button.
    SharePoint Content Editor Web Part
  9. On the Content Editor Web Part click the link that says Click here to add new content, and then click HTML -> Edit HTML Source.
    SharePoint Edit HTML Source
  10. Paste in the following code into the HTML Source and click OK.
  11. <script type="text/javascript">
    /* Text to HTML - version 2.1.1 */
    function TextToHTML(NodeSet, HTMLregexp) {
    var CellContent = "";
    var i=0;
    while (i < NodeSet.length){
    try {
    CellContent = NodeSet[i].innerText || NodeSet[i].textContent;
    if (HTMLregexp.test(CellContent)) {NodeSet[i].innerHTML = CellContent;}
    }
    catch(err){}
    i=i+1;
    }
    }
    // List views
    var regexpTD = new RegExp("^\\s*<([a-zA-Z]*)(.|\\s)*/\\1?>\\s*$");
    TextToHTML(document.getElementsByTagName("TD"),regexpTD);
    </script>

  12. Drag the Content Editor Web Part to position below your Project Status Report.
  13. Navigate to Page -> Stop Editing to save your changes.
    SharePoint Page Stop Editing
  14. And you now have a colored status indicator for your report using a Calculated Field based on the Status of your projects!SharePoint Final Result

Monday, June 29, 2015

InfoPath 2010 : How to get the user’s name to appear in the form

Original Article found here
Infopath 2010 : How to get a user’s name or account to appear in the form
If you need to create an InfoPath form with the user’s name or account appear in a form, InfoPath has a way to connect to SharePoint’s UserProfile service. This article will explain the process to set up a proper data connection in the InfoPath form and then display user names, accounts, emails etc.
If you want to return the Account ID value back to the form, InfoPath has a build-in functions to help retrieve that.
Add a field to you form, right click Textbox properties, go to Data tab, then click the Insert formula button in

You can select the username function to return the name of the person filling out the form.
This will likely return first initial and last name.

By adding a concatenation formula to the username you can modify it so it appears as an email.
Test the different functions in order to achieve your desired results.

Creating the Data Connection
The other way to get user’s information is through the UserProfile Services built in SharePoint.
In your InfoPath form, select the Data tab and then click ‘Data Connections’ button.
In the Data Connections dialog window click ‘Add’ which displays the Data Connection wizard.
Be sure the radio button ‘Receive data’ is selected and then click Next. Now the option to choose
is “Soap Web Service.” You need to specify the User Profile Service URL. The format of the URL is
something like:
http://yourwebserver/mysite/mysite2/_vti_bin/UserProfileService.asmx ?WSDL
Note: Be sure to call the User Profile Service from the same location as your Infopath form. So if your form
is located under mysite2, the make sure the URL points to that site.
Click next until you see the window below and then choose “GetUserProfileByName”

Click next till you get to the last window. Leave the checkbox selected for “Automatically retrieve data
when the form is open.” This way, the field will automatically load users name every time the form is
opened in a browser window. You should now have two data connections set up.

Retrieving the Data from User Profile Service
This section is where we pull it altogether. Back in the InfoPath main menu, select Data tab again and then
click “Form Load” button. The Rules panel will open. You need to add a rule to when the form load the query
the User Profile service. Select “New”, “Action” and then “Add” to run the action. The first action needed is
to Query for Data. Change the Data Connection to GetUserProfileByName. Click OK.

Now add a second Action. This time it will be to “Set a field’s value.” This is where all the magic happens. By calling the service and using a filter, you can display a user’s full name in a form field.
In the Rule’s Details dialog, select which field you want to display the name. In the Value section,
Select the Function button.

Click “Insert Field or Group” button and then “Show Advanced view” link on the bottom.

Change the Fields dropdown to “GetUserProfileByName” and then expand the tree view until you see “Value.”

Select the “Filter Data…” button and click “Add.” Here is where you need to specify filter conditions.
Change the first drop down to “Select a field or group” and then choose “Name” from the tree view.

Change middle dropdown to “Is equal to” and the select third dropdown to “Type in text” and add
the following text “PreferredName.” Click OK to close all your windows.

Before you publish to SharePoint, PREVIEW your form in InfoPath. Select Home tab and then Preview button. You should be able to see full name of the user.

Monday, April 13, 2015

SharePoint: Simple Sample Approach to Autonumber

Below is a formula for a quick and dirty autonumber for lists in SharePoint. There are a variety of ways to generate this field. Some solutions use workflow or external lists, but I prefer this method because of its simplicity.
Note: Because this solution depends on the record’s ID column, it generates the autonumber *after* a record has been added, so if you need the autonumber to appear in the “New..” form, this solution is not for you. My project, which required the Request Number to be in “WR-0000″ format, was fine with having it generated after the fact.
To create my Request Number, I created a new calculated column, named it Request Number and entered the following formula:
=CONCATENATE(“WR-“,REPT(0,4-LEN(ID+1)),ID+1)
This formula combines WR- with leading 0’s and the ID number that’s built into SharePoint lists. The output looks like so:
WR-0001
WR-0002
WR-0003
WR-0004


Article Link

Thursday, April 2, 2015

Performance Tuning

To enable and see Developer Debug tool on SharePoint pages.


http://www.wonderlaura.com/Lists/Posts/Post.aspx?ID=201


http://www.aptimize.com/Upload/docs/SharePoint-Performance-Optimization-10-Steps.pdf


http://www.toddklindt.com/blog/Lists/Posts/Post.aspx?ID=189


$dash =


[Microsoft.SharePoint.Administration.SPWebService]::ContentService.DeveloperDashboardSettings;


$dash.DisplayLevel = 'OnDemand';


$dash.TraceEnabled = $true;


$dash.Update()