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 :
Microsoft Dynamics CRM (Archived)

Transfer personal views to system views

(0) ShareShare
ReportReport
Posted on by

Is there any easy way to transfer personal views to system views. Or is there a tool that does that can do this?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Arun Vinoth Profile Picture
    11,615 Moderator on at
    RE: Transfer personal views to system views

    try this managed solution - dreamingincrm.com/.../

  • Verified answer
    Faisal Fiaz Profile Picture
    75 on at
    RE: Transfer personal views to system views

    We have migrated personal views, charts and dashboards from CRM 2013 to Dynamics 365 using a console application. Two things were different in our case; one because of different AD(Azure) UserIds were different in source and destination environments., other was objecttypecode of custom entities. We created 2 temporary tables in the application to do one to one mapping between users and objecttypecodes. Basically we are getting data from these three tables in source system:-

    1. UserQueryBase for Personal Views

    2. UserFormBase for Dashboards

    3. UserQueryVisualizationBase for Charts

    We can get this information from source system and after correcting objecttypecodes we can create views/charts/dashboards in destination system. As I had access to SQL server of CRM2013 therefore I used following queries for getting views info:-

    "SELECT UserQueryId AS 'ViewId', Name AS 'ViewName', OwnerId AS 'ViewOwnerId', OwnerIdName AS 'ViewOwner', FetchXml AS 'FetchXML', LayoutXml, ReturnedTypeCode, Description, CreatedOn, StateCode FROM dbo.UserQuery WHERE     (CreatedOn > CONVERT(DATETIME, '2012-04-13 10:15:26', 102)) AND (StateCode = 0) ORDER BY CreatedOn";

    To get the sharing info I used following query:-

    "SELECT dbo.UserQuery.UserQueryId AS 'ViewId', dbo.UserQuery.OwnerIdName, dbo.UserQuery.Name AS 'ViewName', dbo.UserQuery.OwnerId AS 'ViewOwnerId', dbo.UserQuery.OwnerIdName AS 'ViewOwner', dbo.SystemUser.SystemUserId AS 'SharedWithUserId', dbo.SystemUser.FullName AS 'SharedWithUser', dbo.Team.TeamId AS 'SharedWithTeamId', dbo.Team.Name AS 'SharedWithTeam', dbo.UserQuery.FetchXml AS 'FetchXML', dbo.UserQuery.LayoutXml, dbo.UserQuery.ReturnedTypeCode, dbo.UserQuery.Description, dbo.PrincipalObjectAccess.AccessRightsMask as 'AccessRightsMask', dbo.UserQuery.CreatedOn FROM dbo.PrincipalObjectAccess RIGHT OUTER JOIN dbo.UserQuery ON dbo.PrincipalObjectAccess.ObjectId = dbo.UserQuery.UserQueryId LEFT OUTER JOIN dbo.SystemUser ON dbo.PrincipalObjectAccess.PrincipalId = dbo.SystemUser.SystemUserId LEFT OUTER JOIN dbo.Team ON dbo.PrincipalObjectAccess.PrincipalId = dbo.Team.TeamId where dbo.PrincipalObjectAccess.AccessRightsMask is not null ORDER BY dbo.UserQuery.Name"

    Now for creating view in destination system I used following method:-

                   object viewName = viewrow["ViewName"];

                   if (viewName != DBNull.Value)

                   {

                       newViewName = (string)viewrow["ViewName"];

                   }

                   System.String layoutXml = (string)viewrow["LayoutXml"];

                   System.String fetchXml = (string)viewrow["FetchXML"];

                   int currentOTC = (int)viewrow["ReturnedTypeCode"];

                   int newOTC = getNewCode(OTCResultData, currentOTC);

                   string OTCEntity = getEntityName(oldTypeCodeData, currentOTC);

                   if (newOTC != 0)

                   {

                       layoutXml = layoutXml.Replace(currentOTC.ToString(), newOTC.ToString());

                   }

     

                   string newViewDesc = string.Empty;

                   object valueDescription = viewrow["Description"];

                   if (valueDescription != DBNull.Value)

                   {

                       newViewDesc = (string)viewrow["Description"];

                   }

                   UserQuery sq = new UserQuery

                   {

                       Name = newViewName,

                       Description = newViewDesc,

                       ReturnedTypeCode = OTCEntity,

                       FetchXml = fetchXml,

                       LayoutXml = layoutXml,

                       QueryType = 0

                   };

                   _customViewId = service.Create(sq);

    After creating the view I used the second query to get sharing info. Based on the data in source system were shared using following code:-

    Guid ShareWithId = Guid.Empty;

                                               string shareUserName = string.Empty;

     

                                               ShareWithId = (Guid)sharerow["SharedWithUserId"];

                                               shareUserName = (string)sharerow["SharedWithUser"];

                                               DataRow[] getNewShareWithGuid = ResultData.Select("old_ID = '" + ShareWithId + "'");

                                               object shareUser = getNewShareWithGuid[0].Field<object>("new_ID");

                                               if (shareUser != null)

                                               {

                                                   Guid shareUserId = getNewShareWithGuid[0].Field<Guid>("new_ID");

                                                    string shareUserEntity = getNewShareWithGuid[0].Field<string>("Entity");

                                                   var grantAccessRequest = new GrantAccessRequest

                                                  {

     

                                                       PrincipalAccess = new PrincipalAccess

                                                       {

                                                           AccessMask = AccessMaskValue,

                                                            Principal = new EntityReference(shareUserEntity, shareUserId)

                                                       },

                                                       Target = new EntityReference(UserQuery.EntityLogicalName, veiwId)

                                                   };

                                                   service.Execute(grantAccessRequest);

                                                   Console.WriteLine("Successfully shared with " + shareUserName);

                                                   CreateLog("Successfully shared with " + shareUserName);

                                               }

                                               else

                                               {

                                                   Console.WriteLine("MISSING USER IN ONLINE : " + (string)sharerow["SharedWithUser"].ToString());

                                                   CreateLog("ERROR: User Missing in Online Environment : " + shareUserName);

     

                                               }

    Following method will give you privileges based on Accessmask:-

    public static AccessRights getAccessMask(int MaskValue)

           {

               AccessRights statement;

               switch (MaskValue)

               {

                   case 1:

                       statement = AccessRights.ReadAccess;

                       break;

                   case 3:

                       statement = AccessRights.ReadAccess | AccessRights.WriteAccess;

                       break;

                   case 65539:

                       statement = AccessRights.ReadAccess | AccessRights.WriteAccess | AccessRights.DeleteAccess;

                       break;

                   case 524291:

                       statement = AccessRights.ReadAccess | AccessRights.WriteAccess | AccessRights.AssignAccess;

                       break;

                   case 589827:

                       statement = AccessRights.ReadAccess | AccessRights.WriteAccess | AccessRights.DeleteAccess | AccessRights.AssignAccess;

                       break;

                   case 262145:

                       statement = AccessRights.ReadAccess | AccessRights.ShareAccess;

                       break;

                   case 262147:

                       statement = AccessRights.ReadAccess | AccessRights.WriteAccess | AccessRights.ShareAccess;

                       break;

                    case 327683:

                       statement = AccessRights.ReadAccess | AccessRights.WriteAccess | AccessRights.DeleteAccess | AccessRights.ShareAccess;

                       break;

                   case 786435:

                       statement = AccessRights.ReadAccess | AccessRights.WriteAccess | AccessRights.ShareAccess | AccessRights.AssignAccess;

                       break;

                   case 851971:

                       statement = AccessRights.ReadAccess | AccessRights.WriteAccess | AccessRights.DeleteAccess | AccessRights.ShareAccess | AccessRights.AssignAccess;

                       break;

                   default:

                       statement = AccessRights.ReadAccess;

                       break;

               }

               return statement;

           }

     

    And the last job was to assign the view to actual owner:-

                                           var requestAssign = new AssignRequest

                                           {

                                                Assignee = new EntityReference(userEntity, OwnerId),

                                               Target = new EntityReference(UserQuery.EntityLogicalName, veiwId)

                                           };

                                           service.Execute(requestAssign);

     

    If any one finds any issue I can be accessed at faisalfiaz@yahoo.com

  • Verified answer
    Community Member Profile Picture
    on at
    RE: Transfer personal views to system views

    What I did was the following:

    Prerequisites: XrmToolbox, FetchXML Builder, View Designer, View Layout Replicator. You can all download them in the Plugin store

    snip_5F00_20160624124253.png

    1. Create a new systemview in the entity, call it ABC, save it and publish the entity
    2. Start Advanced View in CRM and open your (saved) personal view, and press 'download FetchXML'. Save the XML to disk
    3. Start the View Designer in XrmToolbox and open the view 'ABC'
    4. Press 'Edit Query', this will open the view with FetchXML Builder
    5. Press 'Edit XML' (FetchXML Builder) and paste the XML you downloaded in step 2
    6. Press 'Return FetchXML', which will open View Designer again
    7. Save and Publish
    8. Open 'View Layout Replicator' in XrmToolbox, select your personal view and save it to 'ABC'. Publish the entity
    9. Rename the view in CRM to its final name

    Suc6

    Martin
    You want more help? ask me: martin@flores.nl

  • Suggested answer
    Deepesh161 Profile Picture
    6,317 on at
    RE: Transfer personal views to system views

    userobjectmigration.codeplex.com

  • Community Member Profile Picture
    on at
    RE: Transfer personal views to system views

    Thanks Guido! I've downloaded the solution extender and have selected the views and exported. However, when I import them back in using the tool it imports them as user views. Do I need to modify the XML before using the tool to import back in as system views?

  • Suggested answer
    Guido Preite Profile Picture
    54,084 Moderator on at
    RE: Transfer personal views to system views

    There is Solution Extender

    here the post about: http://mscrmtools.blogspot.com/2012/06/new-tool-solution-extender-for.html

    Download: solutionextender.codeplex.com

  • Community Member Profile Picture
    on at
    RE: Transfer personal views to system views

    I thought that was to transfer views from one orgnaization to another. I do not see an option to transfer a personal view in one organization to a system view in the same organization.

  • Deepesh161 Profile Picture
    6,317 on at
    RE: Transfer personal views to system views

    View Transfer tool in XRMtoolbox

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Aric Levin - MVP Profile Picture

Aric Levin - MVP 2 Moderator

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#3
MA-04060624-0 Profile Picture

MA-04060624-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans