Category Archives: SharePoint Designer

SharePoint Designer

How to change SharePoint button display text

Changing the text for a button within SharePoint can be done through JQuery. Some of the requests I’ve had require this to say ‘Send’, ‘Submit’, ‘Cancel Request’ & ‘Back’.

To begin with, open the form you want this change made, for me, I’d like this on the NewForm. The below form is a copy of the new form that I’ve created in SharePoint Designer.

Buttontext

Edit the NewForm page and add a Script Editor Web Part. Copy the code below and paste in the script editor Web Part.  If you’d like the save value to be something other than save, make sure you change the part where I’ve written ‘Send’.

<script>
$(document).ready(function()
{
$(“input[value$=’Save’]”).attr(‘value’, “Send”);
});
</script>

Buttontext2

Save the changes and stop editing the page. Go back into the NewForm (New Item) page and check the changes.

Buttontext3

You can also edit the form in SharePoint Designer and place the code on the form that way.

Hide Edit form & Display form columns based on another column

Over the past few months I’ve been asked whether it’s possible to hide columns based on the value of another column and whether it’s a fast and easy change, the answer is basically yes.

If you have a custom Display or Edit Form, you can manipulate the columns slightly to hide an irrelevant column. Take a look at the screenshots below of my SharePoint list and SharePoint Designer Form.

To begin with I have a list with just 4 columns. As you will notice two of the columns only relate to iPhone and therefore are useless if the phone is a Samsung.

HideColumnsInForm1

The way to hide the columns is through SharePoint Designer, edit the form in advanced mode and scroll down to your columns. The only modification that is required is to add <xsl:if test=”<COLUMN-NAME> = ‘COLUMN-RESULT'”> before the <tr> as well as after the </tr> as shown below.
HideColumnsInForm2(code isn’t lined up, sorry about that!)

The end results when I click on each item from my list are below.

 

 

HideColumnsInForm3 HideColumnsInForm4

Unfortunately this isn’t possible on the New Form as this would require it to be dynamic to which mine isn’t.

 

An alternative way of doing this is to use to code here: https://github.com/kitmenke/sputility, copy the jquery & sputility to a SharePoint Library and reference as below. This is ideal as the form is dynamic and to me, easier to work with. Credit goes to kitmenke!

***edit the form from within SharePoint (edit page) & insert a script editor webpart to paste the below in***

<script src=”https://sharepoint.com/tst/training/SiteAssets/jquery.js”></script>
<script src=”https://sharepoint.com/tst/training/SiteAssets/sputility.min.js”></script>

<script>
$(document).ready(function () {

var cityField = SPUtility.GetSPField(‘City’);

var showOrHideField = function() {
var cityFieldValue = cityField.GetValue();

if(cityFieldValue === ‘London’) {
SPUtility.HideSPField(‘PostCode’);
}
else {
SPUtility.ShowSPField(‘PostCode’);
}
};

showOrHideField();

$(cityField.Dropdown).on(‘change’, showOrHideField);
});
</script>

Workflow Approval Process

In recent months I’ve created many approval workflows for many different scenarios. In this post I will provide a step by step guide of how to create a basic approval workflow.

To start with I have a simple list, which has 3 approvers.
ApprovalWorkflow1
Stage 1

To start this workflow, open SharePoint designer, navigate to your list and create a new 2013 workflow. As per the screenshot below, in the ribbon select ‘local variables’, click add & input the name of the approver, I’ve done this three times due to three approvers (one for each approver).
ApprovalWorkflow2
Within the first stage of your workflow, click Actions in the ribbon and select ‘Set Workflow Variable’.

ApprovalWorkflow3

Fill out the details as follows:

In the top section:

Data Source: Select your list
Field from source: Select the column in your list
Return field as: Display Name

 

In the bottom section:

Field: Select the column in your list (same as Field from source)
Value: Press the fx and set the data source, field from source & return field as the above

Your variable should look something similar to the below.

ApprovalWorkflow4
When you click OK to close the ‘Lookup for String’ window, you will be greeted by the message below, just press Yes to this.
ApprovalWorkflow5

The last part for the first stage is to set the name of the stage, log to history list & then Transition to stage. To log what we’ve done to the history list, click ‘Action’ and select ‘Log to History List’. The reason this is done is for finding where in the workflow it gets to if any errors appear when ran. In order to transition to another stage, you will need to create another stage. This can be achieved by clicking the stage button in the ribbon (next to action).

If the above has been followed correctly, your workflow will look similar to the below.
ApprovalWorkflow6

 

Stage 2

I tend to keep the approval stage separate from everything else, which is the reason behind stages.

The first part of this stage is to create the task process.

  1. Select ‘Action’ in the ribbon, then ‘Start a task process’.
    ApprovalWorkflow7
  2. Click the ‘these users’ hyperlink for the window to open.
  3. Click the ellipses for Participants.
  4. Double click ‘Workflow Lookup for a User’
  5. Data Source: Workflow Variables and Parameters
    Field from source: Variable: Approval 1
    Return field as: Email Address
  6. Repeat steps 4 & 5 for the Approval 2 & Approval 3 Variable.
    ApprovalWorkflow8

Once complete, click OK and close the task process windows. Now create two more stages, name these ‘Approved’ & ‘Rejected’. Within the approval process stage, right click the Transition to stage area and choose ‘If any value equals value’. Click the fx for the first value and put

Data Source: Workflow Variables and Parameters
Field from source: Variable: Outcome
Return field as: ***Blank***

Now click the second value and choose approved. Within the IF statement, right click and choose go to stage, choose Approved, below the Else, do the same and choose rejected.

The end result will look like the below.
ApprovalWorkflow9

Stage 3 & 4

Stage 3 & 4 are similar to each other. The only real difference would be one is rejected and one is approved. Usually, once an item is approved or rejected, an email is sent out to the user who created the item to let them know it’s been approved however I shan’t go into detail on that. To finish the workflow, add an action of ‘Log to History List’ in both Approved & Rejected stages. On the Transition to stage, right click and choose go to stage, click the drop down and choose End of Workflow, this is for both the stages.

The end result is below. If you’d like to keep the user updated as to where in the approval this is, it may be ideal to use the ‘Set Workflow Status’ within the Actions in the ribbon. Alternatively, the workflow uses the Stage name for a status.

ApprovalWorkflow10

Changing the name of a list or library URL

When working with workflows I’ve realised that it’s best for my list URLs to have no spaces and therefore began to look for a useful solution rather than deleting the list and recreating. Fortunately, this can be done in SharePoint Designer.

  1. Within SharePoint Designer, navigate to ‘All Files’, then Lists. If it’s a library, these should be in the ‘All Files’ folder.
  2. Right click your list and choose ‘Rename’. This renames the list as well as the URL. The same happens for Libraries.
    NameChange1

The outcome is below, before and after…

namechange3namechange2

Change where the logo link points to

Within SharePoint, the top left corner there is a logo which usually points to the homepage, read further to determine how to change this.

  1. Open SharePoint Designer and navigate to the Master Pages section.
  2. Edit the Seattle.Master master page in advanced mode.
  3. Search for <SharePoint:SPSimpleSiteLink>
  4. Replace

    <SharePoint:SPSimpleSiteLink CssClass=”ms-siteicon-a” runat=”server” id=”onetidProjectPropertyTitleGraphic”

    <SharePoint:SiteLogoImage CssClass=”ms-siteicon-img” name=”onetidHeadbnnr0″ id=”onetidHeadbnnr2″

    </SharePoint:SPSimpleSiteLink>

    with

    <SharePoint:SPLinkButton NavigateUrl=”your url here” runat=”server” id=”onetidProjectPropertyTitleGraphic”

    <SharePoint:SiteLogoImage CssClass=”ms-siteicon-img” name=”onetidHeadbnnr0″ id=”onetidHeadbnnr2″

    </SharePoint:SPLinkButton>

    The only changes is the parts in bold

So the end result will look similar to this…

logochange

Please note – the edits I’ve done were against the .html page, if you do yours against the .master page, it will look slightly different to this however, the code that needs to be changed still applies.

Cascading Dropdowns – how it’s done

If you’ve Googled Cascading Dropdowns you will realise there are various ways of doing this. Due to my background not being a developer of any sort the easiest solution to me was some short code. I’ve explained below the steps for creating this.

  1. Create 3 lists (or more depending on how many cascading levels you require), you don’t need to rename the title column, we can use as is.
  2. Create your master list that has all these drop downs in.
  3. Using the three lists, populate your data, I’ve used mobile networks and their offerings.
    Mobile
  4. Within each list, use a lookup to the previous list and insert the data as required, review the screenshot above for example.
  5. Using your master list, add look-ups to all three different columns and order as required.
  6. Open SharePoint Designer and navigate to your list, create a new ‘NewItem’ form & a new ‘EditForm’.
  7. Edit the forms in advanced mode and search for ‘PlaceHolderAdditionalPageHead’.
  8. In this section is where you will paste the following code.
    ___________________________________________________________________________________________________
    <script src=”https://code.jquery.com/jquery-1.11.3.min.js”></script>
    <script src=”https://cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/2014.02/jquery.SPServices-2014.02.js”></script><script type=”text/javascript”>

    $(document).ready(function () {

    $().SPServices.SPCascadeDropdowns({
    relationshipList: “Mobile”,
    relationshipListParentColumn: “MobileNetwork”,
    relationshipListChildColumn: “Title”,
    parentColumn: “Mobile Network”,
    childColumn: “Mobile”,
    debug:true
    });

    $().SPServices.SPCascadeDropdowns({
    relationshipList: “Colour”,
    relationshipListParentColumn: “Mobile”,
    relationshipListChildColumn: “Title”,
    parentColumn: “Mobile”,
    childColumn: “Colour”,
    debug:true
    });

    });
    </script>

    ___________________________________________________________________________________________________

    newformcode

  9. Modify the code slightly to reference your own lists & columns within the lists, save and close. If this was done on the New Item form, do the exact same for the edit form.
  10. Open the list in SharePoint and viola!
    cascadingnewformsp

There are a few different ways of doing this that doesn’t require modification of the forms however, for my own benefits I chose the forms to add this code to.

Breadcrumbs for SharePoint 2013

By default SharePoint 2013 doesn’t have breadcrumbs which was a useful feature to navigate back in your SharePoint site. Luckily, this feature hasn’t been removed, instead this has been hidden within the master page. To activate this, follow the steps below.

  1. Within SharePoint Designer navigate to the Master Pages section.
  2. Right click the seattle.master master page and copy, paste this in the open space below to create a new master page then rename this.
    breadcrumbs2
  3. Right click your new master page and edit in advanced mode. Press Ctrl F and find ‘breadcrumb’, following the highlighted parts in the screenshot below, delete the  – style=”display:none;” and change the Visible=”false” to true, your results should look like the second screenshot below.
    breadcrumbscodebreadcrumbscode2
  4. Lastly, add the code below just before the closing </div>
    <script type=”text/javascript”>

    document.getElementById(“GlobalBreadCrumbNavPopout-anchor”).innerHTML='<img style=”border-width:0;position:absolute;left:-215px !important;top:-120px !important;” alt=”Navigate Up” src=”/_layouts/15/images/spcommon.png?rev=27″>’;

    </script>
    breadcrumbscode3

If however you have the Site Collection Feature ‘SharePoint Server Publishing Infrastructure’ and site feature ‘SharePoint Server Publishing’ activated, you will need to make these changes to the html version instead.

Modifying New Item form to delete/rearrange columns

Another request I’ve had is to hide columns on the new item form which in my case required the use of SharePoint Designer again. Details below.

  1. Within SharePoint Designer navigate to your list, create a new item form and edit in advanced mode (right click to edit in advanced mode).
    editformeditinadvancedmode
  2. Search for your column name and highlight the code within the <tr></tr>, this can then be re-arranged in order or deleted as per the below, save the form and preview in browser.
    newformremovecolumn

Prevent users from editing a column

A recent request I had was to prevent users from editing a column once the item had been created. This had to be done in SharePoint Designer, sure you can get around this with the quick edit option in SharePoint however, in my list quick edit was turned off to prevent this.

  1. Open SharePoint Designer and navigate to the list, create a new edit form and edit in advanced mode.
  2. Look for your column name and find the control mode within the SharePoint:FormField line. You will notice the ControlMode is usually set to ControlMode=”Edit”, change this to ControlMode=”Display”, save the form and check SharePoint for the results.<td width=”400px” valign=”top” class=”ms-formbody”>
    <SharePoint:FormField runat=”server” id=”ff6{$Pos}” ControlMode=”Display” FieldName=”DueDate” __designer:bind=”{ddwrt:DataBind(‘u’,concat(‘ff6′,$Pos),’Value’,’ValueChanged’,’ID’,ddwrt:EscapeDelims(string(@ID)),’@DueDate’)}”/>
    <SharePoint:FieldDescription runat=”server” id=”ff6description{$Pos}” FieldName=”DueDate” ControlMode=”Edit”/>
    </td>

    The end result is shown below, this is the edit form in SharePoint.
    DueDate

Hide Lists or Libraries from Site Contents page

In the Site Contents page, there can be many lists, libraries or other apps. While searching for a specific item this can be difficult if there are over 50 apps on the screen, some lists may just be used for back end results such as look-ups. So hiding lists and libraries that aren’t being used is simple, alternatively you could just Ctrl F the page and search your for your list. This change requires SharePoint Designer.

  1. Open SharePoint Designer and navigate to your list or library. On the information page, under settings is a tick box for “Hide from browser”, once ticked this will no longer show in SharePoint.
    HideFromBrowser

    Unfortunately, if you are wanting to unhide this, it will no longer display in the lists and libraries in SharePoint Designer (SPD). You will be required to go to the ‘All Files’ object and choose lists, this will then show the list that’s hidden. Find your list, right click and go properties, then remove the check box to hide the list.