I developed a Custom Form and at the form workflow I sent an email to the director to approve or reject user's request via link that opens the Director view of the form

The form have 4 views: Employee, Director, IT and Access Denied View

Now when the director receive the email and open the link, the SharePoint asks for her username and password at the active directory.

I Wanna validated if the interned username is equal to the value of the field (Director username) of the form. If so, I wanna open the view and if NOT I wanna open anther view (Access Denied View).

How to do so ?

1 Answer 1


if you have a directors list:

replace a link in the email to link to page with a script:

use client object model js (by SP.js)

function getViewByPermissions() {
    var clientContext = SP.ClientContext.get_current()
    var list = clientContext.get_web(),get_lists().getByTitle("Directors");
    CamlQuery camlQuery = new CamlQuery();
    camlQuery.set_viewXml("<View>" +
                           "<Query>" +
                            "<Where>" +
                             "<Eq>" +
                              "<FieldRef Name='Name' />" +
                              "<Value Type='Text'>" + username + " </Value>" +
                             "</Eq>" +
                            "</Where>" +
                           "</Query>" +
    this.myList = list.getItems(camlQuery);
    clientContext.ExecuteQueryAsync(onQuerySucceeded, onQueryFailed)

function onQuerySucceeded()
    var count = this.myList.get_count();
    if(count == undefined || count == 0)
       location.href = //Access Denied View
    else //if(count > 0)
        location.href = //Director View

function onQueryFailed()
    location.href = //Access Denied View


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.