Email: info@zenconix.com

Show notifications in SharePoint 2013

Published on: 07/30/14 3:24 PM

Category:SharePoint 2013 SP.UI Tags:

SP.UI.Notify Class

This provides methods for managing notification alerts.

SP.UI.Notify

SP.UI.Notify.addNotification(strHtml, bSticky) Method

This method adds a notification to the page. By default, notifications appear for five seconds.

var value = SP.UI.Notify.addNotification(strHtml, bSticky);

Parameters

strHtmlThe message inside the notification.

bStickySpecifies whether the notification stays on the page until removed.

Returns:

String : Id of the notification was added on the page

 

Following function will add notification on the page

var notifyId= '' ;
function AddNotification() {
    notifyId = SP.UI.Notify.addNotification("Hello World!", true);
}
showNotification

SP.UI.Notify.removeNotification(nId) Method

This method will removes the specified notification from the page.

SP.UI.Notify.removeNotification(nid);

Parameters

nIdThe notification to remove from the page.

For remove the notification

function RemoveNotification() {
    SP.UI.Notify.removeNotification(notifyId);
    notifyId  = '';
}


Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

Gets a username from SharePoint’s User profile service

Here is script of “How to get username from user id from Active directory”   [code language=”css”] // get user name from id function getUserFromId(userid) { // var userid = _spPageContextInfo.userId; var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/getuserbyid(" + userid + ")"; var requestHeaders = { "accept": "application/json;odata=verbose" }; $.ajax({ url: requestUri, async: false, contentType: "application/json;odata=verbose", […]

Get the User ID of Active Directory name in SharePoint by Javascript

How to get User Id from Site User if you have User’s active directory name [code language=”css”] //Get the id of user from AD name. function getADNameId(adName) { var UserData; $.ajax({ url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/SiteUsers?$Select=Id,Title&$filter=Title eq ‘" + adName + "’", type: "GET", async: false, headers: { "accept": "application/json;odata=verbose", "content-type": "application/json;odata=verbose" }, success: function (data) { […]

Get selected element Id from Task List

“Very BAD practices !!!”  Sometimes situation comes that you don’t have any other options but you have to work on it and get work done. If this situation comes then you are just searching for any possible solution (many times you know that it is wrong approch to do so…).  I have come across the situation, […]