Creating new record

Jul 2, 2012 at 3:32 PM

I am new to CRM and the Toolkit

I am trying to prefill the value only when the user create the new record. 

Below is the JavaScript I tired but does not work 

 

function SettingDefaultValueList() {   

var category = crmForm.all.category;   
var recordID = Xrm.Page.data.entity.getId();   
if (recordID == null) {       
if (category.DataValue != null)          
category.DataValue = 1    }}

Coordinator
Jul 11, 2012 at 2:30 PM

Hey There.

I assume that what you mean is to pre populate / set the vaule for a OptionSet field named 'category'

What you after is (i have not tested. Just typed them in) :

var CRM_FORM_TYPE_CREATE = 1;
var CRM_FORM_TYPE_UPDATE = 2;
var CRM_FORM_TYPE_READONLY = 3;
var CRM_FORM_TYPE_DISABLED = 4;
   
switch (Xrm.Page.ui.getFormType()) {
   case CRM_FORM_TYPE_CREATE:
      var category = Xrm.Page.getAttribute('category');
      category.setValue(1);
      break;
}
Jul 12, 2012 at 1:47 PM

Thank you that is what I am looking for.