Email: info@zenconix.com

Gets a username from SharePoint’s User profile service



Visit Site:

Overview

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",
headers: requestHeaders,
success: onSuccess,
error: onError
});
function onSuccess(data, request) {
var Logg = data.d;
userLoginName = Logg.Title;
}
function onError(error) {
alert("error");
}
return userLoginName;
}
[/code]

Features

Specifications

Preview

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



Visit Site:

Overview

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) {
console.log(JSON.stringify(data));
UserData= data.d.results;
},
error: function (err) {
console.log(JSON.stringify(err));
}
});
return UserData;
}
[/code]

Features

Specifications

Preview

Get selected element Id from Task List



Visit Site:

Overview

“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, wherein I wants to have Id of the ListItem from task list in client side scripting (JQuery).

Following is the code to get id of the ListItem of Task List.

[code language=”css”]
$(document).on("click", "#idHomePageEditItem", function () {
$("#Hero-WPQ2").next().next().next().children("tbody").children().each(function () {
if ($(this).hasClass("s4-itm-selected")) {
var selectedRecordId = $(this).children().eq(1).children().children().children().children().attr("liid");
alert(selectedRecordId );
}
}
}
[/code]

SelectItemFromTasklist

Features

Specifications

Preview

This form can not be rendered.



Visit Site:

Overview

I am working with Workflow in SharePoint 2013, I got unexpected error today while creating association form.

Error was,

workflowIssue

Solution:

After searching it on internet I got to know that “State Services” was not started. So I have started it from central admin

.stateService

 

And now forms are rendering

afterResolve

 

Features

Specifications

Preview

Error occurred in deployment step ‘Activate Features’: System.TimeoutException- while deploying SharePoint 2013 workflows



Visit Site:

Overview

While deploying workflow an error occured, that

Error occurred in deployment step ‘Activate Features’: System.TimeoutException

When I see in output window the explaination was

Error occurred in deployment step ‘Activate Features’: System.TimeoutException: The HTTP request has timed out after 20000 milliseconds. —> System.Net.WebException: The request was aborted: The request was cance

 

After searching it I got to know that “Service Bus Gateway” and “Service Bus Message Broker” services should be Started

services

So go to Run -> services.msc, it will open services page where you will find this service (if you have configured Workflow Manager in your machine )  start the services and reset iis

resetIIS

Deploy the workflow. It will run.

 

Features

Specifications

Preview

Workflow not completed, Canceled automatically



Visit Site:

Overview

Workflow Canceled automaticaly

After completing configuration of the workflow, I have created simple test workflow, but workflow shows an error, that “Error Occured”

and when I see the workflow status, It shows that workflow canceled, I confused and added 2-3 new items in list, still same error.

Then I also tried for another lists and applied workflow, but same issues. Workflow canceled with big error.

Error was something like this

RequestorId: 55c6990b-c4a6-352c-4a5b-449fc1aecac4. Details: System.ApplicationException: HTTP 401 {“x-ms-diagnostics”:[“3001000;reason=\”There has been an error authenticating the request.\”;category=\”invalid_client\””],”SPRequestGuid”:[“55c6990b-c4a6-352c-4a5b-449fc1aecac4″],”request-id”:[“55c6990b-c4a6-352c-4a5b-449fc1aecac4″],”X-FRAME-OPTIONS”:[“SAMEORIGIN”],”SPRequestDuration”:[“61″],”SPIisLatency”:[“1″],”Server”:[“Microsoft-IIS\/8.0″],”WWW-Authenticate”:[“Bearer realm=\”61e7a76b-024e-40d5-9185-2887a044d7cc\”,client_id=\”00000003-0000-0ff1-ce00-000000000000\”,trusted_issuers=\”00000005-0000-0000-c000-000000000000@*,00000003-0000-0ff1-ce00-000000000000@61e7a76b-024e-40d5-9185-2887a044d7cc\””,”Negotiate”,”NTLM”],”X-Powered-By”:[“ASP.NET”],”MicrosoftSharePointTeamServices”:[“15.0.0.4420″],”X-Content-Type-Options”:[“nosniff”],”X-MS-InvokeApp”:[“1; RequireReadOnly”],”Date”:

 

After little search about error, I got to know that , User profile synchronization service should started.

In my case it was not configured and not started.

user profile sync config

Start the service

user profile sync started

Also keep in mind that , The user by whom you are logged is available in User Profile list.

and you have to do full synchronization of User Profile Application.

My workflows are running now.

Reference  : http://anujabhojani.blogspot.in/2014/02/workflow-gets-canceled-automatically.html

 

 

 

Features

Specifications

Preview

Show Model Dialog in SharePoint 2013



Visit Site:

Overview

SP.UI.ModelDialog Class

This Represents a modal dialog.

SP.UI.ModalDialog

SP.UI.ModelDialog.showWaitScreenSize(title, message, callbackFunc, height, width) Method

This displays a wait screen dialog that has a Cancel button using the specified parameters.

var value = SP.UI.ModalDialog.showWaitScreenSize(title, message, callbackFunc, height, width);

Parameters

titleThe title of the wait screen dialog.

messageThe message that is shown in the wait screen dialog.

callbackFuncThe callback function that runs when the wait screen dialog is closed.

height:  The height of the wait screen dialog.

widthThe width of the wait screen dialog.

Returns

A modal dialog with the specified parameters.

Remark

This method displays a wait screen dialog that can be closed manually. The callback function specified by the callbackFuncparameter will run when the modal dialog closes.

Function can be written as

     function waitWithClose(){            
                    SP.UI.ModalDialog.showWaitScreenSize("Title" ," Message");  
             }

waitWIthClose

SP.UI.ModelDialog.showWaitScreenWithNoClose(title, message, height, width) Method

This displays a wait screen dialog that does not have a Cancel button using the specified parameters.

 

var value = SP.UI.ModalDialog.showWaitScreenWithNoClose(title, message, height, width);

Parameters

titleThe title of the wait screen dialog.

message: The message that is shown in the wait screen dialog.

height: The height of the wait screen dialog.

width: The width of the wait screen dialog.

Returns 

A modal dialog with the specified parameters.

Remark

This method opens a wait screen dialog that cannot be closed manually.

Function can be written as

  function showWaitWithNoClose()        {
          SP.UI.ModalDialog.showWaitScreenWithNoClose("Title" ,"Please wait this is body");        
}
waitWithNoClose


Features

Specifications

Preview

Show notifications in SharePoint 2013



Visit Site:

Overview

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  = '';
}

Features

Specifications

Preview

Show status messages in SharePoint



Visit Site:

Overview

SP.UI Namespace

For showing Notifications and Status messages we are going to use SP.UI Namespace. Namespace provides types and members for working with the user interface in Microsoft SharePoint Foundation. This namespace includes members to work with status messages, notifications, and dialogs.

SP.UI.Status Class

This class provides methods for managing status messages.

SP.UI.Status

This provides some methods as

SP.UI.Status.addStatus(strTitle, strHTML, atBegining) Method

This method adds status message on the page

var value = SP.UI.Status.addStatus(strTitle, strHtml, atBegining);

Parameters

strTitleThe title of the status message.

strHtmlThe contents of the status message.

atBeginingSpecifies whether the status message will appear at the beginning of the list.

* where strHtml and atBegining are optional

Returns

string : The ID of the status message.

Function can be written as

function addStatus() {
    statusId = SP.UI.Status.addStatus("Hello World!");       
    }
SP.UI.Status.appendStatus(sid, strTitle, strHTML) Method

This method appends text on an existing status message.

var value = SP.UI.Status.appendStatus(sid, strTitle, strHtml);

Parameters

sid: The ID of the status message.

strTitle: The title of the status message.

strHtml: The contents of the status message

Returns

String : The ID of the status message.

SP.UI.Status.removeAllStatus(hide) Method

This method removes all status messages from the page.

SP.UI.Status.removeAllStatus(hide);

Parameters

hideSpecifies that the status messages should be hidden.

* where parameter hide is optional

Function can be written as

 function RemoveAllStatus() {
        SP.UI.Status.removeAllStatus(true);
}
SP.UI.Status.removeStatus(sid) Method

This method removes the specified status message.

 

SP.UI.Status.removeStatus(sid);

Parameter

sidThe ID of the status message to remove.

Function can be written as

 function RemoveLastStatus() {
    SP.UI.Status.removeStatus(statusId);
    statusId = ' ';
}
SP.UI.Status.setStatusPriColor(sid, strColor) Method

This method Sets the priority color of the specified status message.

 

SP.UI.Status.setStatusPriColor(sid, strColor);

Parameters

sid: The ID of the status message.

strColorThe color to set for the status message. The following table lists the values and their priority.

Value Priority
Red Very Important
Yellow Important
Green Success
Blue Information

 

Function can be written as 

  • For success status
  1.   function successStatus() {
         statusId = SP.UI.Status.addStatus("Data Save successfully!");
         SP.UI.Status.setStatusPriColor(statusId, 'green');
     }

    successStatus

    • For error/ very important status
      function errorStatus() {  
          statusId = SP.UI.Status.addStatus("Something goes wrong!");    
         SP.UI.Status.setStatusPriColor(statusId, 'red'); 
     }

    errorStatus

    • For important status
      function importantStatus() {
                  statusId = SP.UI.Status.addStatus("this is very much important!");
                  SP.UI.Status.setStatusPriColor(statusId, 'yellow'); 
        }

    importantStatus

  2. For information status
     function informationStatus() {
             statusId = SP.UI.Status.addStatus("this is information!");
              SP.UI.Status.setStatusPriColor(statusId, 'blue');
   }
importantStatus

SP.UI.Status.updateStatus(sid, strHtml) Method

This method updates the specified status message.

SP.UI.Status.updateStatus(sid, strHtml);

Parameters

sid: The ID of the status to update.

strHtml: The new status message.

 

Features

Specifications

Preview