Tag Archives: Libraries

Libraries

How to create a button in SharePoint 2013

So there are a few ways of creating custom buttons in SharePoint however, I like my buttons to be noticeable so I tend not to use the standard button however, I’ve shown below how to create buttons using basicbutton, Bootstrap & CSS.

Buttons1

Basic Button:

Button2

<input type=button onClick=”parent.location=’http://sharepoint-oc/'” value=’Click Here!’>

CSS Button:

Button4

<style>
.link {
background-color: #6666FF;
color: white;
padding: 12px 25px;
text-align: center;
text-decoration: none;
display: inline-block;
}

.link:hover {
background-color: #C1C1FF;
}
</style>
<a href=”http://sharepoint-oc/” class=”link”>Click Here!</a>

Bootstrap Button:

Button3

<button type=”button” onclick=”parent.location=’http://sharepoint-oc'” class=”btn btn-primary btn-lg”>Click Here!</button>

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.

Create a hyper-link to open in a new window

I get a fair amount of requests to open links in a new window, or just to create hyper-links on lists & libraries. Although this may become obvious for some people, it doesn’t for other newbies in SharePoint. I generally use the ‘Hyperlink with formatting and constraints for publishing’ column. Unfortunately this doesn’t show in the lists/libraries as an option when creating a column. This column has to be done at site level which can be found at Site Settings -> Site Columns (Under Web Designer Galleries).

To create a new column click ‘Create’ and fill in the name of the field and remember to select the correct type of column, screenshot below.

Hyperlink1

Save the column and return to your list.

Within your list go to List settings, towards the bottom of the page select ‘Add from existing site columns’ and you will be presented with the below. Find the column you’ve just created and click add, then click OK.

Hyperlink2

In your list create a new item and click ‘click to add a new hyperlink’, you will then see the fields that require filling out.

Hyperlink3

And lastly, the end result…

Hyperlink4

Reasons for Workflows failing

As I work with workflows I’ll be updating this post as I come across reasons as to why workflows fail to run.


1. Workflow History List Permissions

I’ve recently completed a lengthy approval workflow to which kept failing if an end user created the item, any user in the owners group worked correctly. The users had edit access on the list as well as the tasks list.

I noticed it kept failing at the start of the workflow as I have ‘log to history list’ to help understand where in the workflow I am in case of errors like this, as well as having statuses. I knew for sure users had full edit permissions on the two lists I created however, I didn’t think to check the Workflow History list permissions.

When having ‘log to history list’, users need to be able to edit that list in order for the workflow to log the item to the list which was my issue. I wasn’t using the default members group to group these users, I created my own groups which is why they never had access to that list, giving users access to that list made the approval work as expected.

As the history list is hidden, the easiest way to find this is to type in your SharePoint URL and add /lists/workflow%20history to the end.

https://sharepoint.com/tst/training/lists/workflow%20history

An alternative is to look in SharePoint Designer.
2. TBC

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>

Set Focus on Content on a SharePoint page

Within SharePoint there is a small button in the top right which focuses on the content. Basically it hides the top navigation and quick launch.

For my own purposes I required this to be the default as I was creating a display page. The following code below helped achieve this, it’s also worth noting that the Focus button can still be pressed if the user would like to view the navigation/quick launch.

The code below is not my own, this was through Technet forum replies.

<script type=”text/javascript”>
function pageLoad()
{
$(document).ready(function(){
$(“body”).addClass(“ms-fullscreenmode”);
$(“#fullscreenmode”).css(“display”, “none”);
$(“#exitfullscreenmode”).css(“display”, “”);
});
}
</script>

Another way…

<script>
_spBodyOnLoadFunctionNames.push(“HideBrandingsuite”);
function HideBrandingsuite()
{
SetFullScreenMode(true);
}

</script>

 

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

How to put the Managed Metadata navigation to the top of the quick launch

There could be a number of reasons as to why this may be useful, my reason being is the quick launch navigation as it is, is rather packed and therefore trying to use this functionality requires a lot of scrolling down every time. Fortunately you can place some script on the page to push the Metadata navigation to the top of the quick launch, code courtesy of Steve Borgwordt.

Within your list, edit the page and insert a Script editor webpart (Found in Media and Content under the Categories section). Add the following code below.

<script src=”https://code.jquery.com/jquery-latest.min.js” type=”text/javascript”></script>

<script>

$(document).ready(function () {

$(‘.ms-tv-box’).remove().prependTo($(‘.ms-core-sideNavBox-removeLeftMargin’));

});

</script>

MetadataNavigation

If you are unable to view the Metadata navigation settings, check the site features to confirm the ‘Metadata Navigation and Filtering’ feature is activated.

Site Permissions – “Sorry, you don’t have access to this page”

Recently I had an issue where a site owner could not access the Site Permissions, List or Library permissions. This was due to an Owner of the site collection removing the permissions for everyone accidentally and then a site collection admin adding them back in. The downside to this is that the owners group is no longer associated to the Access Requests List. The Access Request setting can be turned on or off, the option for Access Request Settings is then in the ribbon under Site Settings – Site Permissions. The resolution to this is to follow the Microsoft KB article here however, the alternate fix would be to just turn access requests off, although this wouldn’t be everyone’s ideal solution.

The Microsoft KB article is also below should the link ever change.

SOLUTION

To resolve this issue, users must be either site collection administrators or be members of the Owners group for the site. The Owners group must also have permissions to access the Access Requests list. Use the following solutions as appropriate for your specific configuration.

Site collection administrator

If an affected user should be a site collection administrator, go to the following Microsoft website for more information about how to manage administrators for your sites:

Add the user to the Owners group for the site

If the user should be a site owner, you must add the user to the Owners group for the site. To do this, follow these steps:

  1. As a user who can change site permissions, browse to the affected site or site collection. Click the gear icon for the Settings menu, and then click Site settings.
  2. Click Site permissions.
  3. Click the Owners group for the site.
  4. Click New.
  5. In the Share dialog box, enter the user account of the user who you want to add to the group. Then, click Share.
  6. Test to verify that the user can now access the list and approve or decline requests.

Make sure that the Owners group has permissions to the Access Requests list

If the Owners group is changed or was removed from the Access requests list, you must add the Owners group permissions for the list. You must also make sure that the affected user is included in the Owners list. To do this, follow these steps:

  1. As a user who has the Manage Permissions Permission Level on the affected site and who also has access to the Access Requests list (for example, a Site Collection administrator), browse to the Access Requests list in Internet Explorer.
  2. Press F12 to open the F12 Developer Tools window.
  3. Click the Network tab, and then press F5 to enable network traffic capturing.
  4. Refresh the Access Requests page in Internet Explorer. After the page has loaded, press Shift+F5 to stop capturing network traffic.
  5. In the Developer Tools window, double-click the first result in the URL list. This URL ends in “pendingreq.aspx.”
  6. In the Developer Tools window, click Request body.
  7. In the search box, type pagelistid:, and then press Enter.Note The search highlights the pageListId text.
  8. Copy the GUID that follows the pageListId. The GUID will be between an opening brace ( { ) character and a closing brace ( } ) character as follows:
    {GUID}

    Note Include the opening and closing brace characters when you copy the GUID. This GUID is the identifier for the SharePoint Online Access Requests list for your organization.

  9. In the browser address bar, enter https://<URL<URL of affected site or site collection>/_layouts/15/ListEdit.aspx?List=<{GUID}>, and then press Enter.Note In this address, <URL of affected site or site collection> represents the URL for the site collection in which you want to change the access requests (for example, https://contoso.sharepoint.com). And <{GUID}> represents the GUID that you copied in step 8.
  10. On the Settings page, click Permissions for this list.
  11. Make sure that the Owners group for the site is included in the list of permissions for the Access Requests list. If the Owners group for the site collection does not exist, click Grant Permissions, enter the name of the Owners group for the site in the Share dialog box, and then click Share.
  12. Follow the steps in the “Add the user to the Owners group for the site” section to make sure that the user is included in the Owners group.

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