Wednesday, March 9, 2016

Form Types in MSCRM

Hi,

Get Form Type in MSCRM
Javascript to Get Form Type

Xrm.Page.ui.getFormType()

Below is the Form Types in MSCRM
Form Type
Value
Undefined
0
Create
1
Update
2
Read Only
3
Disabled
4
Quick Create (Deprecated)
5
Bulk Edit
6
Read Optimized (Deprecated)
11



Set Focus in MSCRM for a New Field.

Hi,

In CRM there is a new feature to set Focus to Particular Field. Use the below Javascript to achive the same.


Xrm.Page.ui.controls.get("AttributeName").setFocus();

Regards,
Ram


Set Default Dashoard MSCRM C#

Hi,

Please find the code below for setting Default Dashboard while Associating Role to Particular User





EntityCollection loaddashboards = GetDashboardGuid(dashboardname);
Entity roles = new Entity("usersettings");
roles.Attributes["systemuserid"] = UserID;
roles.Attributes["defaultdashboardid"] = loaddashboards.Entities[0].Attributes["formid"];
orgService.Update(roles);


private EntityCollection GetDashboardGuid(string name)
        {
            QueryExpression qry = new QueryExpression("systemform");
            qry.ColumnSet.AddColumns("name", "formid");
            qry.Criteria.AddCondition(new ConditionExpression("name", ConditionOperator.Equal, name));
            EntityCollection loaddashboards = orgService.RetrieveMultiple(qry);
            return loaddashboards;
        }

Friday, March 4, 2016

What's New Permission Issue

Hi,

If what’s new shows error likeYou do not have permissions to see this view. Contact a system administrator.

For fixing the issue, we need to give privileges on1) At least User level Read rights on Filter 2) Organization level Read rights on Post Configuration




Create Access Teams in c#

Hi,


Create Access Team Template based on c# code.


Entity teamtemplate = new Entity("teamtemplate");
teamtemplate.Attributes["teamtemplatename"] = TeamName;
teamtemplate.Attributes["teamtemplateid"] = TeamGuid;
teamtemplate.Attributes["defaultaccessrightsmask"] = Convert.ToInt32(accessRights);
teamtemplate.Attributes["objecttypecode"] = typecode;

orgService.Create(teamtemplate);

Deactivate CRM Forms

Hi,

Deactivate CRM Forms.

Create an XML File and name it as SystemForm

XML FILE:

Pass formname and Objecttypecode in seperation of Comma

<?xml version="1.0" encoding="utf-8" ?>
<systemform>
  <form>account,1</form>
  <form>contact,2</form>
  <form>campaign,4400</form>
  <form>Campaign Activity,4402</form>
  <form>Contract,1010</form>
  <form>Contract Detail,1011</form>
  <form>Email,4202</form>
  <form>Appointment,4201</form>
  <form>Wizard,4201</form>
  <form>Email Server Profile,9605</form>
  <form>Fax,4204</form>
  <form>letter,4207</form>
  <form>Phone Call,4210</form>
  <form>Team,9</form>
  <form>Task,4212</form>
  <form>Sales Literature,1038</form>
  <form>Wizard,4202</form>
  <form>User,8</form>
  </systemform>


C# Code: 

var appSettings = ConfigurationSettings.AppSettings;
                XmlDocument systemform = new XmlDocument();
                systemform.Load(@"SystemForm.xml");
                int n;

                foreach (XmlNode node in systemform.DocumentElement.ChildNodes)
                {
                    string[] formnode = node.InnerText.Split(',');
                    bool isNumeric = int.TryParse(formnode[1], out n);
                    if (isNumeric)
                    {
                        QueryExpression deactivateForms = new QueryExpression(appSettings["EntityForms"]);
                        deactivateForms.ColumnSet = new ColumnSet(true);
                        deactivateForms.Criteria.AddCondition(new ConditionExpression(appSettings["FormName"], ConditionOperator.Equal, formnode[0].ToString()));
                        deactivateForms.Criteria.AddCondition(new ConditionExpression(appSettings["FormAttribute"], ConditionOperator.Equal, Convert.ToInt32(formnode[1].ToString()))); // Entity Object type code               
                        EntityCollection getDeactivatedfroms = orgService.RetrieveMultiple(deactivateForms);
                        foreach (Entity finaldeactivation in getDeactivatedfroms.Entities)
                        {
                            Entity newentity = new Entity(appSettings["EntityForms"]);
                            newentity[appSettings["FormAttribute"]] = finaldeactivation.Attributes[appSettings["FormAttribute"]];
                            newentity[appSettings["FormActivationState"]] = new OptionSetValue(Int32.Parse(appSettings["FormInActive"]));
                            newentity[appSettings["FormId"]] = finaldeactivation.Attributes[appSettings["FormId"]];
                            orgService.Update(newentity);
                        }
                    }
                    else
                    {
                        MessageBox.Show(formnode[1] + "is not Valid For Form Deactivation");

                    }

User belongs to Different Business Unit than a Role

Hi,
Today I got a scenario to create a User and assign Security Role to a User.
While associating Role to the Team am getting following error
“User belongs to Different Business Unit than a Role”

Resolution:

After creating user check the Business Unit of the User and Pass the Business Unit to the Query Expression and the Result of Role associate to the User

QueryExpression role = new QueryExpression("role") { ColumnSet = new ColumnSet(true) };
                    role.Criteria.AddCondition(new ConditionExpression("name", ConditionOperator.Equal, "Activity Feeds"));
                    role.Criteria.AddCondition(new ConditionExpression("businessunitid", ConditionOperator.Equal, businessunitid));
                    EntityCollection roleActivity = orgService.RetrieveMultiple(role);


How to Run Microsoft Flow for Every one Month

Introduction: In this Blog we will see how to Run Microsoft Flow for Every one Month. Implementation Steps:   1. Navigate to  https://make.p...