Friday, 22 April 2016

04:01 - No comments

Restrict to Select the date or year || MS CRM


Select particular days in date picker field in dynamics CRM:

Objective:
To select the particular days in date filed in dynamics CRM, for example he can able to select in up to 1 year from today [21-4-16 to 21-4-17]. If he try to select past or above one year he will get the error message and he can’t able to save the record.

Create date field in and give option as date only.


After that 

Data the below JavaScript code. Call the event in onchange function. 


function mydatecalculation()
{
var now = new Date(); 
var samplecheck = Xrm.Page.getAttribute("new_datesample").getValue(); 
var oneDay = 1000 * 60 * 60 * 24;
if ( samplecheck == null || samplecheck== '')
{
Xrm.Page.getControl("new_datesample").clearNotification();
}
else
{
var diffYear = samplecheck.getFullYear() - now.getFullYear();  
debugger;
if(diffYear > 1)
{
Xrm.Page.getControl('new_datesample').setNotification("Invalid Date");
}
else if(diffYear < 0)
{
Xrm.Page.getControl("new_datesample").setNotification("Invalid Date");
}
else
{
var startselect = new Date(samplecheck.getFullYear(), 0, 0);
var diffselect = samplecheck - startselect;
var selectday = Math.floor(diffselect / oneDay);
var startcurrent = new Date(now.getFullYear(), 0, 0);
var diffcurrent = now - startcurrent;
var currentday = Math.floor(diffcurrent / oneDay);


if(selectday >= currentday)
{
debugger;
var getyear = samplecheck.getFullYear(); 
var checkyear = getyear % 4;
var firstDate = new Date();
var secondDate = new Date(samplecheck);
var diffDays = null;
var checkdayes = null;
if(checkyear == 0)
{
diffDays = Math.round(Math.abs((firstDate.getTime() - secondDate.getTime())/(oneDay)));
checkdayes = diffDays / 364;
if(checkdayes < 1)
{
Xrm.Page.getControl("new_datesample").clearNotification();
}
else
{
Xrm.Page.getControl('new_datesample').setNotification("Invalid Date");
}
}
else
{
 
diffDays = Math.round(Math.abs((firstDate.getTime() - secondDate.getTime())/(oneDay)));
checkdayes = diffDays / 365;
if(checkdayes < 1)
{
Xrm.Page.getControl("new_datesample").clearNotification();
}
else
{
Xrm.Page.getControl('new_datesample').setNotification("Invalid Date");
}
}
}
}
}
}

Thursday, 10 March 2016

11:47 - No comments

Duplicate Detection Rule Republisher for CRM 2011 || CRM 2013

In Microsoft Dynamics CRM if we create any duplicate detection role publish it. But every some particular day or week or month it get automatically unpublished . So again we need to publish our duplication detection role.



For this issue we can resolve by following the link                                                                               


link :http://duplicatedetectionrulerepublisher.codeplex.com/ 

http://duplicatedetectionrulerepublisher.codeplex.com/releases/view/121976


In this link to download the zip file and follow the steps.

Wednesday, 17 February 2016

07:54 - 1 comment

Get the Count of Annotation (notes) Records in Case Record Entity | MS CRM

Get the count of annotation (notes) records in case record entity.

First add the latest  XRMServiceToolKit, JSON and Jquery





after that add the below code in OnLoad event 


function mycountsample()
{
debugger;
var id =Xrm.Page.data.entity.getId();
var entityName = Xrm.Page.data.entity.getEntityName();
var fetchxmlcount="<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"
+"<entity name='annotation'>"
+"<attribute name='subject' />"
+"<attribute name='notetext' />"
+"<attribute name='filename' />"
+"<attribute name='annotationid' />"
+"<order attribute='subject' descending='false' />"
+"<filter type='and'>"
+"<condition attribute='isdocument' operator='eq' value='1' />"
+"</filter>"
+"<link-entity name='incident' from='incidentid' to='objectid' alias='ab'>"
+"<filter type='and'>"
+"<condition attribute='incidentid' operator='eq' uitype='incident' value='"+id+"' />"
+"</filter>"
+"</link-entity>"
+"</entity>"
+"</fetch>";
var rCollection= XrmServiceToolkit.Soap.Fetch(fetchxmlcount);
alert(rCollection.length);
}






then refresh and open the record you will the count of annotation record..









Tuesday, 16 February 2016

20:09 - No comments

Identify the trigger for an On-load event for Sub-grid in Dynamics CRM | MS CRM

Introduction :

With CRM 2015 SP1, the client API was extended to allow attaching events to subgrid to manage the subgrid data operations.

The OnLoad event however executes on all of the following operations

1.Load of parent form
2.Save of parent form
3. Add a new record in sub grid
4. Remove a record from sub grid
5.Navigating to prev/next page in sub grid

when we register a method on the onload event, ts does not indicate in any way which of the above actually fired the onload event

Workaround to identifying the operation :

We cannot register an event when the record is added/removed from the sub grid. The only event available is onload so one way to identify if it was one of the add/remove operations that caused the grid to call the onload event. we can keep a check on the count of records in the grid.

we can register the onload event using the following code


   function onLoad() {

    var funtionName = "onLoad";

    try {

        //setting timeout beacuse subgid take some time to load after the form is loaded

        setTimeout(function () {

            //validating to check if the sub grid is present on the form

            if (Xrm.Page != null && Xrm.Page != undefined && Xrm.Page.getControl("contact_subgrid") != null && Xrm.Page.getControl("contact_subgrid") != undefined) {

                //stores the row count of subgrid on load event of CRM Form

                _rowCount = Xrm.Page.getControl("contact_subgrid").getGrid().getTotalRecordCount();

                //registering refreshform function onload event of subgrid

                Xrm.Page.getControl("contact_subgrid").addOnLoad(onGridLoad);

            }

        }, 5000);

    } catch (e) {

        Xrm.Utility.alertDialog(functionName + "Error: " + (e.message || e.description));

    }

}


The rowcount is defined as global variable and is updated here to store the count of  records in the grid when the form is loaded initially.



    function onGridLoad() {

    var functionName = " onGridLoad ";

    var currentRowCount = null;

    try {

        //setting timeout beacuse subgrid take some time to load after the form is loaded

        setTimeout(function () {

            //validating to check if the sub grid is present on the form

            if (Xrm.Page != null && Xrm.Page != undefined && Xrm.Page.getControl("contact_subgrid") != null &&                                   Xrm.Page.getControl("contact_subgrid") != undefined) {

                //stores the row count of subgrid on load event of CRM Form

                currentRowCount = Xrm.Page.getControl("contact_subgrid").getGrid().getTotalRecordCount();

                if (currentRowCount > _rowCount) {

                    //call the intended function which we want to call only when records are added to the grid

                    dosomething();

                    //set current row count to the global row count

                    _rowCount = currentRowCount;

                }

                else if (currentRowCount < _rowCount) {

                    //call the intended function which we want to call only when records are removed from the grid

                    dosomethingelse();

                    //set current row count to the global row count

                    _rowCount = currentRowCount;

                }

            }

        }, 2000);

    } catch (e) {

        Xrm.Utility.alertDialog(functionName + "Error: " + (e.message || e.description));

    }

}

Monday, 15 February 2016

05:01 - No comments

Make a subgrid “+” button launch a new record form | MS Dynamics CRM


 In Microsoft Dynamics CRM, to add a record to a subgrid on a form, you hit the + button in the upper right hand corner. You will notice that for some subgrids you will get a lookup field, while others will give you a new record form.

The reason for this different behavior is that the new button (+) can either function as “add new” or “add existing.” For example, when you are adding an opportunity, you probably will want to have the new button create a new opportunity, while when adding a contact to an account, you may want to have the user select from an existing list of contacts (or search existing first, then add a new one).

To control the behavior of the new record button on subgrids, look at the child entity being selected in the subgrid..If the lookup field for the parent is required, the user will get a “new record” form when clicking the + button. If the lookup field for the parent entity is not required on the child entity, the user will get the lookup field to “add existing.”

Friday, 22 January 2016

11:37 - No comments

Retrieve Fields Values Using Late Bound In Microsoft Dynamics CRM 2011

Code:
//Get the record of the “Account” entity.
Entity _Account = OrganizationService.Retrieve(“account”, new Guid(“recordguid”), new ColumnSet(){AllColumns=true});
//To get string value
string Name = _Account[“name”].ToString();
//To get Option Set selected value
int OptionSetValue = ((OptionSetValue)_Account[“accountcategorycode”]).Value;
//To get  Option Set selected text
String  OptionSetTest = ((OptionSetValue)_Account.FormattedValue[“accountcategorycode”]).Value;
//To get  date time field value
DateTime CollectionDate = ((DateTime)_Account[“new_collectiondate”]).Date;
//To get  money field value
decimal Creditlimit = ((Money)_Account[“creditlimit”]).Value;
//To fetch decimal field value
decimal Executivecommission = (decimal)_Account[“new_executivecommission”];

Monday, 19 October 2015

23:19 - No comments

Interview Question




  1. What is Final block ?
  2. What is CLR ?
  3. Validation in ASP.Net
  4. How to install Database in CRM or How to map database to CRM ?
  5. What is Fetch XML ?
  6. What is foreachloop?
  7. What is Ribbon ? How to add the Ribbon.?
  8. What is Isolation Mode?
  9. What is Web resource
  10. What the messages in there in Plugin ?
  11. What is Exception Handling ?
  12. If you export the solution what are there inside the solution ? 
  13. What is Matadata in Dynamic CRM ?
  14.  I have a Entity, I didnot add any JavaScript function for that Entity. If i open the Entity i am getting JavaScript runtime error. So Where i need to check for this error ?
  15. What is Retrieve Multiple ? How Many records can we retrieve using Retrieve Multiple ?
  16. what is Custom Workflow?
  17. How to create Entity,Fields,Values in CRM Database ?
  18. What is SQL  Architecture,Table ?
  19. Custom Application ?
  20. What is XML File ?