Wednesday, 14 August 2013

Showing only selected Tab on the MS CRM 2011 Form

When you open any form it loads all the tabs on the form.Suppose you want to display the selected tab on the form at a time.Here is a JavaScript function to hide the other tabs.This function can be called on the Form OnLoad and TabStateChange events.

1.JavaScript Function:

function ToggleTabDisplayState(name) {
 
    var currentTab = Xrm.Page.ui.tabs.get(name);
    if (currentTab != null && currentTab.getDisplayState() == "expanded") {
        var currentTabId = currentTab._control.get_id();
        var tabs = Xrm.Page.ui.tabs.get();
        for (var i in tabs) {
            var tab = tabs[i];
            var tabId = tab._control.get_id();
            if (tabId != currentTabId) {
                if (tab.getDisplayState() == "expanded") {
                    tab.setDisplayState("collapsed");
                }
                document.getElementById(tabId).style.display = "none";
            }
        }
    }
}
2.Before Calling the Function :
Form shows all the tabs before calling the above function Form OnLoad event.
 
 
 
 3.Calling the Function :
 
3.1 Call on Form OnLoad event :
 
Suppose on Form OnLoad event I want to show only "General" tab and hide other tabs then call the above function as below.
 
function Form_OnLoad() {
    ToggleTabDisplayState("general"); //"general" is the name of the tab
}
 
3.2 Call on TabStateChange event:
 
Call the same function on the TabStateChange event 
 
Go to Form Properties =>Select Control as tab name=>Add Handler =>Select Library=>add function as ToggleTabDisplayState =>Provide name of the tab in Comma separated parameters list for example 
"contacts" => Save and publish


4.After Calling the Function :
Form shows only selected tab after calling the above function Form OnLoad event.
 
 










Hope it helps,
Regards,
Yusuf



Tuesday, 16 July 2013

Retrieving Subgrid Items count using Javascipt in MS CRM 2011/MS CRM 2013

Retrieving Subgrid Items count using Javascipt.

1.Get the subgrid  using "Name" of subgrid as given below.
















2.Write the Javascript function as given below:

function subgridItemCount() {
 
      // Get the Subgrid Control
    var grid = Xrm.Page.ui.controls.get('LineItems')._control;
    if (grid.get_innerControl() == null) {
        setTimeout(subgridItemCount, 1000);
        return false;
    }
    else if (grid.get_innerControl()._element.innerText.search("Loading") != -1) {
        setTimeout(subgridItemCount, 1000);
        return false;
    }
    var countRec = grid.get_innerControl().get_allRecordIds().length;
    if (countRec > 0) {
        alert(countRec);
 
    }
 
}


For MS CRM 2013:

function FindControl() {
    if (document.getElementById('subgridName')!= null) {
        var count=document.getElementById('subgridName').control.get_totalRecordCount();
        alert(count);
        }
        else {
            setTimeout("FindControl()", 1000);
        }
    }


3.Result




























Hope this helps,

Regards,

Yusuf

Tuesday, 2 July 2013

Retrieve N:N records in MS CRM 2011

Retrieving N:N records in MS CRM 2011 using LINQ requires less code and is straightforward.

I am assuming that "Account" is in N:N relationship with "Custom Entity".

Below is the screenshot for relationship





















Here is the Screenshot of account having custom entity records





























Query:

LINQ query to get all the N:N custom entity records for the above Account.

 string accountId = "CC572EC9-01E3-E211-AC62-984BE173A384";
  var customEntities = (from NtoN in makeUseOfContext.new_customentity_accountSet
                        where NtoN.accountid.Value == new Guid(accountId) && 
                        NtoN.new_customentityid != null
                         select new { 
                                    customentityid = NtoN.new_customentityid.Value 
                                   }).ToList();
        
Debug Mode:

















Similarly we can get the Accounts associated to the custom  entity.
Hope it will help someone somewhere :)

Thanks,
Yusuf

Microsoft Dynamics CRM - Orion release

The next major release of Microsoft Dynamics CRM will come in the form of the Orion release in the second half of 2013.

Major Changes:
.
The major themes for the Orion release are as follows:
• User Experience – Continuation of the journey in Polaris
• Ubiquitous – Role-tailored applications for Sales Professionals. (Ubiquitous key word replaces the word Mobile. You will be hearing this a lot more).
• Productivity – Internal Collaboration for the on-premise customers & Server Sync enhancements
• Business Process – Process-centric theme continued to the next level
• Online – Online first focus to continue (this means CRM Online will get all the new features first before OnPremise)

Orion User Interface:

Firstly, you will notice it has no ribbon. Next it has no left navigation bar. The navigation bar is now at the top (as shown in purple colour in the screenshot below).



Here is the full post.Refer this too.



Regards,

Yusuf

Friday, 21 June 2013

CRM 2011 – New SDK version 5.0.16 available

The MS CRM Team have released an updated CRM 2011 SDK version 5.0.16 which can be downloaded here http://www.microsoft.com/en-us/download/details.aspx?id=24004 or viewed on MSDN here http://msdn.microsoft.com/en-us/library/gg309408.aspx Check out the SDK Release History notes herehttp://msdn.microsoft.com/en-us/library/dn198205.aspx

Now the common question here is that what is changing in the new version.There are some changes please go through below post on

MSCRM Bing’d




Regards,
Yusuf

Friday, 24 May 2013

Using Child Workflows in MS CRM 2011.

While working with the Projects we have to implement several logic as per the Client Need.

Here is the requirement.

1)Case Severity can be (1,2,3,4) Where 1 is the highest and 4 is the lowest.
2)Whenever Severity is raised to 1.It should trigger a mail to an user and keep on sending until Status of the Case is Closed.

Solution:

1)"Keep on sending until Status of the Case is Closed" this Can be achieved using child workflow.
2)"Whenever severity is raised to 1" :It means we should compare the previous severity with the new severity.

Note:
So we should Create  a custom field "previous severity".Set this field  with the value of case severity.When the Case is Created.You can achieve this using either workflow or JavaScript.

Creating Workflows:We will create two workflows

1)Main Workflow
2)Child workflow

Main workflow will call the child workflow and child workflow will call itself to achieve this.

Main Workflow Screen shot:



Child Workflow Screen shot:













Note : This workflow is on change of "Severity" of case.

Hope this helps,

Regards,

Yusuf