Now, we are talking about Duration format.
When you apply Duration as your Whole Number format, it actually still save number in the Database.
But, when you go to the form and see that you can choose from the Picklist :
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.
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 :
In the CRM Web
Hope it helps!
ReplyDeleteUnable 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);