Setting SharePoint New Form’s User Field using JSLink

When creating a new item in NewForm.aspx, we can add a custom JSLink script to the form web part to automatically pre-populate user fields, either defaulting to the current user or picking up another user through the REST API.

The script below sets one user field (Owner) to the currently logged in user, and another user field (Approver) to a specific user based on email.

Continue reading

Updating Site Icon URL in SharePoint Online

By default, the SharePoint site icon on the top left of the default master pages will redirect users to the landing page of the current site they are in.

sharepoint-site-icon

However, it’s sometimes useful for that site icon to be used to redirect back to the site collection home page instead.

We can do this with a bit of JavaScript. Assuming you already have a JS file (global.js in the example below) that is embedded as a User Custom Action, the following code should update the site icon’s URL on all pages: Continue reading