Home > MS CRM 2011, MS crm 2013, MS CRM 2015 > Set User Default view using REST API

Set User Default view using REST API

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 {

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: