web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Blogs / Aeon Nexus CRM / Set User Default view using...

Set User Default view using REST API

Royal King Profile Picture Royal King 27,686

I had a requirement to update users default view based on their role  programmatically in Bulk  and thought sharing this info that may be helpful for someone

Below script will update users Account entity default view to “Active Accounts”

You need to pass  Entity Typecode,ViewID, Language Code

var entity = {};
entity.PersonalizationSettings = “<DefaultGridViews> <DefaultGridView> <EntityTypeCode>1</EntityTypeCode> <ChildEntityName></ChildEntityName> <QueueId></QueueId> <ViewId>{00000000-0000-0000-00AA-000010001002}</ViewId> <ViewType>1039</ViewType> </DefaultGridView> </DefaultGridViews>”;

var req = new XMLHttpRequest();
req.open(“POST”, encodeURI(Xrm.Page.context.getClientUrl() + “/XRMServices/2011/OrganizationData.svc/UserSettingsSet(guid’3472C864-F9EC-4FB4-8C35-CFD630ED0696‘)”), true);
req.setRequestHeader(“Accept”, “application/json”);
req.setRequestHeader(“Content-Type”, “application/json; charset=utf-8″);
req.setRequestHeader(“X-HTTP-Method”, “MERGE”);
req.onreadystatechange = function () {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 204 || this.status == 1223) {
alert(“Updated”); //Success – No Return Data – Do Something
}
else {
alert(this.statusText);
}
}
};
req.send(JSON.stringify(entity));



This was originally posted here.

Comments

*This post is locked for comments