How to handle UTC Daylight saving using Javascript in MSCRM.

Call the function Now from the onload event or change event. The current function will populate the current date and time on your date time field and will also take care of the daylight savings.

Capture 24

function Now(primaryControl, attributename) {
    debugger;
    var formcontext = primaryControl.getFormContext(); //formcontext is new
    // upgraded way of 
    //calling Xrm.Page which now 
    // got depricated in D365
    //If you are still working on crm 16 or below you can directly use Xrm.Page 
    if (formcontext.ui.getFormType() == 1) {
        var date = new Date();
        if (date.dst()) {
            date.setHours(date.getHours() + 1);
            formcontext.getAttribute(attributename).setValue(date);
            return;
        }
        formcontext.getAttribute(attributename).setValue(date);
    }
}

Date.prototype.stdTimezoneOffset = function () {
    debugger;
    var jan = new Date(this.getFullYear(), 0, 1);
    var jul = new Date(this.getFullYear(), 6, 1);
    return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset());
}

Date.prototype.dst = function () {
    debugger;
    return this.getTimezoneOffset() < this.stdTimezoneOffset();
}

Know More on MSCRM Audit & Audit History

Auditing

Microsoft Dynamics 365 comes with several tools to help you manage data. One of these is the auditing feature, which allows you to track changes made to data in Dynamics 365. It also tracks each time a user logs into your system. If auditing is enabled, CRM automatically creates logs for the changes that are tracked. By default, auditing is not turned on.

Read More »

Retrieve entity-name from Object Type code in MSCRM using C#

//Find the Logical Name from the entity type code - this needs a reference to the Organization Service to look up metadata
public string GetEntityLogicalName(IOrganizationService service)
{
    var entityFilter = new MetadataFilterExpression(LogicalOperator.And);
    entityFilter.Conditions.Add(new MetadataConditionExpression("ObjectTypeCode ", MetadataConditionOperator.Equals, this.EntityTypeCode));
    var propertyExpression = new MetadataPropertiesExpression { AllProperties = false };
    propertyExpression.PropertyNames.Add("LogicalName");
    var entityQueryExpression = new EntityQueryExpression()
    {
        Criteria = entityFilter,
        Properties = propertyExpression
    };

    var retrieveMetadataChangesRequest = new RetrieveMetadataChangesRequest()
    {
        Query = entityQueryExpression
    };

    var response = (RetrieveMetadataChangesResponse)service.Execute(retrieveMetadataChangesRequest);

    if (response.EntityMetadata.Count == 1)
    {
        return response.EntityMetadata[0].LogicalName;
    }
    return null;
}