Tuesday, 20 May 2014

CRM 2011/2013 Know More about Duration Field

In CRM, we can know there is a field data type, that is Whole Number, when you take a look deeper, it has more than 1 available format.

image

Now, we are talking about Duration format.

When you apply Duration as your Whole Number format, it actually still save number in the Database.

image

But, when you go to the form and see that you can choose from the Picklist :

image

It is fine if user can choose from the form by himself.

But, when you come to the backend code and plugin and for example you want to count the Sales Cycle aging by calculation End Date minus Start Date, you have to be aware that the lowest unit is in Minute. It makes your Duration not in Days conversion but in Minutes.

image
So, make sure that in your plugin you should convert that the Minutes if you want to get duration in Day.
TargetEntity.tfp_Duration = intDuration * 1440;

Here is the result :

In the database :

image

In the CRM Web

image

Hope it helps!

2 comments:


  1. Unable to update the Duration field by using plugins.

    Entity retrievedIncident = ServiceObj.Retrieve("incident", relatedIncidentGuid, new ColumnSet(true));
    DateTime createdOn = (DateTime)retrievedIncident.Attributes["createdon"];
    TracingServiceObj.Trace("Case created Date:" + actualEnd);

    TimeSpan totalTimeSpent = actualEnd.Subtract(createdOn);
    TracingServiceObj.Trace("Duration :" + totalTimeSpent.TotalDays);

    Entity incident = new Entity("incident");
    incident.Id = relatedIncidentGuid;
    incident.Attributes["aac_duration"] = totalTimeSpent.TotalMinutes;
    ServiceObj.Update(incident);

    ReplyDelete
  2. CERTIFICATE PROGRAMME IN BUSINESS MANAGEMENT
    The new today and tomorrow demand executives who are mentally prepared and ready to take on the future with skills and knowledge that will equip them to make a space for themselves at their workplaces. This programme, offered by IIM Kozhikode,

    ReplyDelete

My Name is..