Category: Dynamics CRM

Configure SLA for Custom Entities

In previous releases, you could create SLAs only for case records. With CRM Online 2016 Update 1 and CRM 2016 SP1, you can now create enhanced SLAs for entities that are enabled for SLA. A system administrator or customizer can enable SLAs for the following entities and also for custom entities and custom activities:

  • Account
  • Contact
  • Order
  • Invoice
  • Quote
  • Opportunity
  • Lead
  • All activity entities like email, phone, and appointment except recurring appointment and its instances.

 

To enable SLA for custom entities you can select Enable for SLA option in the entity.

Untitled

once the entity is published you can configure SLA using the same steps we used for case, system will ask for the related entity at the time of SLA creation  .

Untitled

Please note that only enhanced SLA is available for custom entities , standard SLA can be used only with case entity.

To create see how to configure SLA please follow the link :Define SLA

To add a timer control to the form please follow : Add Timer

Hope this was helpful……..

 

 

WEB API- Part 6 : Create record

Create record using WEB API 

Following code shows how to create an Account record using WEB API and how to set different types of fields

function CreateAccount() {
 
    var serverURL = Xrm.Page.context.getClientUrl();
    var account = {};
    account["name"] = "New Account";
   
   
 //Set LookUp
    account["primarycontactid"] = {
        "firstname": "Sample",
        "lastname": "Contact"
    };// this will create new contact ,if you need to link an existing contact use the following
 //account["primarycontactid@odata.bind"]="/contacts(contactId)"; 
 
    //optionset
    account["companytype"] = 2;
    //two options
    account["donotemail"] = true;
    //number
    account["numberofemployees"] = 30;
 
    var req = new XMLHttpRequest();
    req.open("POST", serverURL + "/api/data/v8.0/accounts", true);
    req.setRequestHeader("Accept", "application/json");
    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    req.setRequestHeader("OData-MaxVersion", "4.0");
    req.setRequestHeader("OData-Version", "4.0");
    req.onreadystatechange = function() {
        if (this.readyState == 4 /* complete */ ) {
            req.onreadystatechange = null;
            if (this.status == 204) {
                var NewAccount = this.getResponseHeader("OData-EntityId");
                var NewAccountId = NewAccount.substr(NewAccount.length - 38).substring(1, 37); 
                Xrm.Utility.openEntityForm("account", NewAccountId); //Open newly created account record
            } else {
                var error = JSON.parse(this.response).error;
                alert(error.message);
            }
        }
    };
    req.send(JSON.stringify(account));
}

 

Please note following code for setting an existing lookup value

 account["primarycontactid@odata.bind"]="/contacts(contactId)";

“contacts” is plural name for contact entity .

var NewAccount = this.getResponseHeader(“OData-EntityId”);  will give  you the newly created record…

Field Conflicts

Recently I faced a strange issue, I used a filed (lookup) twice in the form and applied a pre-filtering java-script to the field. But only one filed is getting filtered by the script.I tried many options and I couldn’t identify the issue. Have you even faced  this issue ? Finally I got the answer from  Scott Durow ( Thank you Scott!!! ). I decided to post this issue because if someone is facing the same issue , this will help them to solve the issue. Following is the explanation for this issue.

The issue you are experiencing is because the ‘getControl’ method returns only the first control – so in fact you are only adding the custom filter to the first control.

An attribute object has a ‘controls’ collection that can give you all the controls for a specific attribute. So you can add the filter to all the controls by using something like:

Xrm.Page.getAttribute(“fieldname”).controls.forEach(

function (control, i) {

control.addPreSearch(filterCustomerAccounts);

var customerAccountFilter = “<filter type=’and’><condition attribute=’accountcategorycode’ operator=’eq’ value=’1’/></filter>”;

control.addCustomFilter(customerAccountFilter, “account”);

}

);

Hope this helps!!!

Nijo