Kashif Nizam Qureshi


Leave a comment

People Picker PDP of PWA by Using Script

Use the following script to enable custom field to become people picker.
//Set the following to be an array of fields you would like to change into a people-picker
var targetFields = [‘Project Sponsor’];
//var targetFields = [‘Field 1’, ‘Field 2’];

//safely load JQuery
if (typeof jQuery == ‘undefined’) {
var s = document.createElement(“script”);
s.src = ‘//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js’;
if (s.addEventListener) {
s.addEventListener(“load”, function () { myJQueryCode() }, false);
} else if (s.readyState) {
s.onreadystatechange = function () { myJQueryCode() };
}
document.getElementsByTagName(‘head’)[0].appendChild(s);
} else {
myJQueryCode();
}

function myJQueryCode() {
$(document).ready(function () {
var scriptRoot = _spPageContextInfo.siteAbsoluteUrl + ‘/_layouts/15/’;

$.when(
$.getScript(scriptRoot + “clienttemplates.js”),
$.getScript(scriptRoot + “clientforms.js”),
$.getScript(scriptRoot + “clientpeoplepicker.js”),
$.getScript(scriptRoot + “autofill.js”)
)
.done(function () {
window.console && console.log(‘Scripts loaded’);
renderPeoplePickers();
})
.fail(function (message) {
window.console && console.error(‘Loading scripts failed: ‘ + message);
});
});
}

function renderPeoplePickers() {
for (fieldIndex = 0; fieldIndex < targetFields.length; fieldIndex++) {
$(“input[type=’text’][title='” + targetFields[fieldIndex] + “‘]”).each(function () {
this.style.color = “green”;
renderPeoplePicker(this);
window.console && console.log(‘PeoplePicker rendered: ‘ + targetFields[fieldIndex]);
});
}
}

function renderPeoplePicker(targetInput) {
var divPeoplePicker = document.createElement(‘div’);
var idPeoplePicker = targetInput.id + ‘_PeoplePicker’;
var targetValue = $(targetInput).attr(‘value’);

divPeoplePicker.id = idPeoplePicker;
$(targetInput).parent().append(divPeoplePicker);

initializePeoplePicker(idPeoplePicker);
var newPeoplePicker = this.SPClientPeoplePicker.SPClientPeoplePickerDict[idPeoplePicker + ‘_TopSpan’];
$(targetInput).hide();

if (typeof targetValue !== “undefined”) {
newPeoplePicker.AddUnresolvedUser({
Key: targetValue,
DisplayText: targetValue
}, true);
}

newPeoplePicker.OnControlResolvedUserChanged = function () {
if (this.TotalUserCount > 0) {
//we have a resolved user
var resolvedUser = this.GetAllUserInfo()[0];

//Set the underlying field value
$(‘input#’ + (this.TopLevelElementId.split(“_PeoplePicker_TopSpan”)[0])).attr(‘value’, resolvedUser.DisplayText);

//If value has changed then mark the PDP dirty to enable save
//Thankyou to Martin Laukkanen (nearbaseline.com) for this fix!
if ($(‘input#’ + (this.TopLevelElementId.split(“_PeoplePicker_TopSpan”)[0])).attr(‘origvalue’) !== $(‘input#’ + (this.TopLevelElementId.split(“_PeoplePicker_TopSpan”)[0])).attr(‘value’)) {
WPDPParts[0].IsDirty = true;
}
} else {
//we have nothing – so clear out the target field
$(‘input#’ + (this.TopLevelElementId.split(“_PeoplePicker_TopSpan”)[0])).attr(‘value’, ”);
}
}

}

// Render and initialize the client-side People Picker.
function initializePeoplePicker(peoplePickerElementId, defaultValue) {

var users;
if ((defaultValue != undefined) && (defaultValue != “”)) {
users = new Array(1);
var defaultUser = new Object();
defaultUser.AutoFillDisplayText = defaultValue;
defaultUser.AutoFillKey = defaultValue;
//defaultUser.Description = user.get_email();
defaultUser.DisplayText = defaultValue;
defaultUser.EntityType = “User”;
defaultUser.IsResolved = false;
defaultUser.Key = defaultValue;
defaultUser.Resolved = false;
users[0] = defaultUser;
} else {
users = null;
}

// Create a schema to store picker properties, and set the properties.
var schema = {};
schema[‘PrincipalAccountType’] = ‘User’;
//schema[‘PrincipalAccountType’] = ‘User,DL,SecGroup,SPGroup’;
schema[‘SearchPrincipalSource’] = 15;
schema[‘ResolvePrincipalSource’] = 15;
schema[‘AllowMultipleValues’] = false;
schema[‘MaximumEntitySuggestions’] = 50;
schema[‘Width’] = ‘360px’;

// Render and initialize the picker.
// Pass the ID of the DOM element that contains the picker, an array of initial
// PickerEntity objects to set the picker value, and a schema that defines
// picker properties.
this.SPClientPeoplePicker_InitStandaloneControlWrapper(peoplePickerElementId, users, schema);
}


Leave a comment

An unhandled exception occurred during the execution of the workflow instance

Error:

RequestorId: a6721745-8c82-cf39-0000-000000000000. Details: An unhandled exception occurred during the execution of the workflow instance. Exception details: System.ApplicationException: HTTP 404 {“Transfer-Encoding”:[“chunked”],”X-SharePointHealthScore”:[“0″],”SPClientServiceRequestDuration”:[“1443″],”SPRequestGuid”:[“a6721745-8c82-cf39-8e70-854ddb459a48″],”request-id”:[“a6721745-8c82-cf39-8e70-854ddb459a48″],”X-FRAME-OPTIONS”:[“SAMEORIGIN”],”MicrosoftSharePointTeamServices”:[“15.0.0.4569″],”X-Content-Type-Options”:[“nosniff”],”X-MS-InvokeApp”:[“1; RequireReadOnly”],”Cache-Control”:[“max-age=0, private”],”Date”:[“Fri, 06 May 2016 15:11:16 GMT”],”Server”:[“Microsoft-IIS\/8.5″],”X-AspNet-Version”:[“4.0.30319″],”X-Powered-By”:[“ASP.NET”]} at Microsoft.Activities.Hosting.Runtime.Subroutine.SubroutineChild.Execute(CodeActivityContext context) at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

Cause:

In an SPD workflow, list item was being updated where it was unable to find the item.

Resolution:

This error seems to be very common and can occure for many reasons. In my case, one of the list’s item was being updated based on title. The item with that title was not there as it was changed and hence this error. So I changes the update to query based on ID rather than name.


Leave a comment

Passing SSRS Parameter Through URL To Report Viewer SharePoint Mode

Following URL is being used to access a page where a Report Viewer web part is placed. Note the URL contains report parameter as well. This won’t work unless we connect the web part with Query String (URL) Filter web part as shown below.

https://itepm.tecomgroup.ae/PWA/Dashboards/Executive%20Summary%20Dashboard.aspx?ProjUid=9ff4a5f7-70e0-e511-80de-005056831a69&ProjectName=Hyperion%20HFM%20Implementation

ssrs


Leave a comment

Passing Parameter to SSRS Reports Through URL

Following is an example of one report being accessed via URL with one paramater as a querystring. Notice rp: is being used just before actual paramater, also parameter is case-sensitive.

http://Server/pwa/ProjectBICenter/_layouts/15/ReportServer/RSViewerPage.aspx?rv:RelativeReportUrl=/PWA/ProjectBICenter/SSRS%20Reports/Project%20Charter%20Preview.rdl&rp:projectuid=9ff4a5f7-70e0-e511-80de-005056831a69


Leave a comment

Enabling Remote Error for SSRS Reporting Service

https://msdn.microsoft.com/en-us/library/aa337165.aspx

Enable Remote errors for a Reporting Services Service Application
For a SharePoint mode report server installed with SQL Server 2012 or a newer version of Reporting Services, enable the service application setting Enable remote errors. The setting can be configured for each Reporting Services service application.
In SharePoint Central Administration, click Manage service applications in the Application Management group.
Find your Reporting Services service application and click the name of your service application.
Click System Settings.
Click Enable Remote Errors in the Security section.
Click OK.

Enable Remote Errors for a SharePoint Site
For a SharePoint mode report server installed with a version of Reporting Services prior to SQL Server 2012, enable the site setting Enable remote errors in local mode.
In Site Actions click Site Settings for the site you want to modify.
Click Reporting Services Site Settings in the Reporting Services group.
Click Enable remote errors in local mode.
Click OK


Leave a comment

Removing Unnecessary Permission Level Project Server

PWA sync with SharePoint groups, in order to give permission to users to access sites (PWA and/or Project Site). By default users have delete and other unnecessary permissions. Best way is to remove it from Permission Level using task scheduler as PWA revert back permission level whenever you update user’s group. To view whole list of base permission click here.

Following code applies permissions to Project Manager permission level defined in base permissions.


$site=Get-SPSite http://Server/PWA

$web=$site.RootWeb

$contributePermissionLevel=$web.RoleDefinitions["Project Managers (Microsoft Project Web App)"]

$contributePermissionLevel.BasePermissions="ViewListItems, OpenItems, ViewVersions, ManagePersonalViews, ViewFormPages, Open, ViewPages, CreateSSCSite, BrowseDirectories, BrowseUserInfo, AddDelPrivateWebParts, UpdatePersonalWebParts, UseClientIntegration, UseRemoteAPIs, CreateAlerts, EditMyUserInfo"

$contributePermissionLevel.Update()

$web.Dispose()

$site.Dispose()

Follow

Get every new post delivered to your Inbox.