Showing posts with label CRM 2011. Show all posts
Showing posts with label CRM 2011. Show all posts

Tuesday, November 8, 2016

Set Focus on a control in CRM 2011

How to set focus on a control in CRM 2011 using Javascript


Option 1:
var control = Xrm.Page.ui.controls.get("AttributeName");
control.setFocus();

Option 2:

In some situations we need to show the alert to end user and then set the focus on the field where validation takes place, in this case setting focus directly on that fails so simply set the focus to a different field on the same tab first and then reassign the focus to the field from which the OnChange() event was called like so:


Xrm.Page.getControl("AnyFieldFromSameTab").setFocus(true);
Xrm.Page.getControl("TheFieldYouReallyWantToFocus").setFocus(true);


Monday, October 19, 2015

Change Tab Order in CRM

Default tab order in CRM is top to bottom, if we want to change it and suppose we have lots of field in form then use below function and call it on OnLoad().


TabOrderLefttoRight: function () {
for (var i = 0; i < Xrm.Page.ui.controls.getLength() ; i++) {
var control = Xrm.Page.ui.controls.get(i);
var element = document.getElementById(control.getName());
if (element.tabIndex && element.tabIndex != "0") {
if (element.className == 'ms-crm-Hidden-NoBehavior')
continue;
if (element.tagName == 'A') {
if (element.className != 'ms-crm-InlineTabHeaderText')
continue;
}
element.tabIndex = 1000 + (i * 10);
}
}
},

Wednesday, September 23, 2015

Remove Option Set Value at Runtime in CRM

function removeOptionSetValue(attributeName, value, index) {
 debugger;
var attrName = attributeName;
if (index != undefined && index != null) {
attrName = attrName + index;
index += 1;
}
else {
index = 1;
}
var attrControl = Xrm.Page.getControl(attrName);
if (attrControl != null) {
try {
attrControl.removeOption(value);
removeOptionSetValue(attributeName, value, index);
} catch (e) {}
}
}


function RemoveOptions()
{
removeOptionSetValue("optionsetName",value, null);
}

Thursday, July 17, 2014

Disable / Enable form fields through JavaScript

There are many scenarios where we need to disable all fields/controls on an Entity form. Here I am showing different ways to handle it through JavaScript.

function disableFields() {
var attributes = Xrm.Page.data.entity.attributes.get();
for (var i in attributes) {
Xrm.Page.getControl(attributes[i].getName()).setDisabled(true);
Xrm.Page.getControl(“statuscode”).setDisabled(false);
}
}
function enableFields(){
var attributes = Xrm.Page.data.entity.attributes.get();
for (var i in attributes){
Xrm.Page.getControl(attributes[i].getName()).setDisabled(false);
}
}

  • Enable / Disable a field

Xrm.Page.getControl(“fieldname”).setDisabled(false);

  • Enable / Disable a Section

function sectiondisable (sectionname, disablestatus)
{
var ctrlName = Xrm.Page.ui.controls.get();
for(var i in ctrlName) {
var ctrl = ctrlName[i];
var ctrlSection = ctrl.getParent().getName();
if (ctrlSection == sectionname) {
ctrl.setDisabled(disablestatus);
}
}

  • Enable / Disable a Tab

function tabdisable (tabname, disablestatus)
{
          var tab = Xrm.Page.ui.tabs.get(tabname);
 if (tab == null)
alert("Error: The tab: " + tabname + " is not on the form");
 else {
     var tabsections =  tab.sections.get();
     for (var i in tabsections) {
     var secname = tabsections[i].getName();
     sectiondisable(secname, disablestatus);
              }
                 }
}


Wednesday, July 16, 2014

Secure Vs. Unsecure Configuration

How to pass parameters to plug in
Secured vs. Unsecured
Below are key differentiation between Secured and Unsecured data configuration
  • Access
  1.   Data passed through “Unsecure” section is PUBLIC (i.e., It can be read by any user in CRM).
  2. Only users with “System Administrator” role have access to the data passed through “Secure” configuration section
  • Storage
  1. “Unsecure” config data will be stored along with the Plugin ‘Step’ registration information (i.e., In SdkMessageProcessingStep entity)
  2. “Secure” config data will be stored in a separate entity named “SdkMessageProcessingStepSecureConfig
  3. Only “System Administrator” has Read access on this entity, hence only users with ‘Sys Admin’ role can access this data
  4. Both “Secured & Unsecured” configuration data stored as “Plain text” in DB
  • Outlook Sync
  1. “Unsecured” configuration data is downloaded to the user’s computer when they go offline making it Unsecure
  2. “Secured” configuration data is NOT downloaded to User’s Computer when they go Offline
   
       How to read Configuration data in Plug-in
  1. When we register plug-in step, there is a field when we can specify some configuration parameters for the plugin execution as below:

  2. Then in constructor of plugin class we will get the configuration value which we can use later in the execution method:

In quick watch we can check all the configuration parameters as below:

  • ·          Note :- If you want to read “Secure” configuration in the plug-in code, either change the  user context in plugin registration as “CRM administrator ” or Impersonate to “CRM Administrator” role user in the code.

Find & Advance Find Search

Find perform a search on an attribute for which it is defined.

Advanced Find perform search on the conditions and the attributes for which user customizes or runs it.

Normal Find in faster as it looks for one attributes and matches with that and returns the result whereas Advanced Find searches for all the attributes and conditions while parsing through the records.

Find is applicable on only active records and it finds only on 2 or 3 column which we have defined in the find view and even it returns any those column which is there in the view but advanced find is applicable to all the records and it finds all the columns and even it returns all the column and filter criteria can be on any column.

Find is faster than Advanced Find.

Saturday, July 12, 2014

Append & AppendTo Privileges

What is 'Append' and 'Append To' privilege in MSCRM? Give one example of it?

Ans: 'Append' and 'Append To' privileges works together. 'Append To' privilege will allow other entities to get attached with the entity. 'Append' privilege will allow the entity to attach the records to the entity with 'Append To' privilege. 

Ex:-
Let us say that you want to attach a note to a case then note entity should have 'Append' access right and case entity should have 'Append To' access right.

Let us take one more example to understand this. Suppose you have two custom entities called 'TestCustomEntity1' and 'TestCustomEntity2'. You want to attach the 'TestCustomeEntity2' records to 'TestCustomEntity1'records. For this you need to have 'Append' access right on 'TestCustomEntity1' entity and 'Append To' access right on 'TestCustomEntity2'.

Now guess will I be able to attach the records? 
Answer is " NO" because we need to create a 1:N relationship between 'TestCustomEntity1' and 'TestCustomEntity2'. Now the user who has above mentioned access right in his security role will only be able to add 'TestCustomEntity2' records to 'TestCustomEntity1'.


Solutions in CRM 2011

Dynamics CRM 2011 Solution Packages (“solutions”, for short) are packages of customization that allow you to build and maintain Dynamics CRM/xRM applications, and to move them from one organization to another. In fact, not only are they the best practice approach to moving customization from one CRM organization to another; but short of re-creating every customization from scratch they are the ONLY way to move customization. So there really is no option not to use them: unless you want to manually recreate every customization any time you provision a new organization, you must use solutions in Dynamics CRM 2011.

     A solution is originally created within the context of a Dynamics CRM organization. It’s important to distinguish between the organization a solution is originally created in, and a different organization it gets imported to. I’ll refer to the first one as the “Developer” or “Publisher” organization. Any custom functionality a solution provides (custom entities, workflows, form script, plug-ins, etc.) can be exported as part of a single unit. This unit is referred to as the solution package, and consists of a zipped up collection of XML files. When exporting a solution package from the organization it was developed in, there are two options: you can export a “Managed Solution”, or an “Unmanaged Solution”.

Managed solutions have the following features:
·        When imported to a different organization (you might refer to this as the “Consumer” organization) all of the customization are automatically published.
·        They can be uninstalled. Uninstalling a managed solution is a clean and complete uninstall: that is, all of a managed solution’s components are removed from the Target organization when the managed solution is deleted.
·        They can selectively expose components for customization in the consumer organization.    This is specified in the developer organization, where solution components can be specified as customizable or non-customizable. Customizable solution components of a managed solution are fully exposed and customizable in the consumer organization.
·        Versioning is built in to the managed solution architecture. For example, if “Solution A, version 1″ is imported, and subsequently “Solution A, version 2″ is imported, Dynamics CRM will recognize version 2 as a new version of the same solution and import/publish just the new features.
    They cannot be modified in or exported from a consumer organization.

Unmanaged solutions have the following features:
·        When imported into a consumer organization, their components must be published.
·        They cannot be uninstalled. (Any of their custom components can be deleted, but this must be done one at a time, unlike the one-click uninstall for a managed solution.)
·        They can be modified in or exported from a consumer organization, either as an unmanaged solution or a managed solution.

The last bullet-points in both sections may be confusing at first: it seems a little odd at first that you can import a managed solution you’ve created yourself and cannot modify the solution package in the target organization, but it’s true: while you can modify customizable components of a managed solution, you cannot modify the solution package itself, except for in the original (developer/publisher) organization. On the other hand, unmanaged solutions can be further modified in any way in the consumer organization, OR exported from it, either as a managed or unmanaged solution. That’s what unmanaged solutions are for.
Generally speaking, you can say the following:
·        If you’re a commercial software developer, or an enterprise developer/customizer, you will probably use managed solutions to distribute your CRM 2011 customizations: they give you clean uninstall capability, versioning with automatic upgrades, and the ability to selectively lock down components.
·        If you just want to move your customizations from one CRM 2011 organization to another, and don’t want any restrictions on what you can do with them in the target/consumer organization, that’s what unmanaged solutions are for.