locked
Set a default value in a field from a picklist CRM 4.0 RRS feed

  • Question

  • I have a picklist field on the incident that is almost always the same value. What is the best way to set this as the default value when an incident (case) is created. Should I do a onLoad script or is there an easier way?
    Tuesday, May 5, 2009 12:34 AM

Answers

  • Hi,

    There is an example in the SDK.


    The following code example shows how to set values in a field of type Lookup. This example shows how to set the parent account lookup field on the account form.

    //Create an array to set as the DataValue for the lookup control.
    var lookupData = new Array();
    //Create an Object add to the array.
       var lookupItem= new Object();
    //Set the id, typename, and name properties to the object.
       lookupItem.id = '{1AAC1363-01A1-DB11-8432-0003FF9CE217}';
       lookupItem.typename = 'account';
       lookupItem.name = 'A Bike Store';
    // Add the object to the array.
       lookupData[0] = lookupItem;
    // Set the value of the lookup field to the value of the array.
       crmForm.all.parentaccountid.DataValue = lookupData;



    Cheers,
    Jim


    Jim Wang - MVP Dynamics CRM - http://jianwang.blogspot.com , http://mscrm.cn
    Tuesday, May 5, 2009 8:47 AM
    Moderator

All replies

  • No code needed, you can set it in the configuration - just open the attribute and you can set it there.
    Scott Sewell, CustomerEffective | http:\\blog.CustomerEffective.com | Twitter:@ScottSewell
    Tuesday, May 5, 2009 12:38 AM
    Moderator
  • ah..... I found out my problem of not being able to do that.   I had assumed you could do that.....   My attribute is a lookup and not a picklist.  I will change it.  Thanks
    Tuesday, May 5, 2009 1:35 AM
  • Hi,

    There is an example in the SDK.


    The following code example shows how to set values in a field of type Lookup. This example shows how to set the parent account lookup field on the account form.

    //Create an array to set as the DataValue for the lookup control.
    var lookupData = new Array();
    //Create an Object add to the array.
       var lookupItem= new Object();
    //Set the id, typename, and name properties to the object.
       lookupItem.id = '{1AAC1363-01A1-DB11-8432-0003FF9CE217}';
       lookupItem.typename = 'account';
       lookupItem.name = 'A Bike Store';
    // Add the object to the array.
       lookupData[0] = lookupItem;
    // Set the value of the lookup field to the value of the array.
       crmForm.all.parentaccountid.DataValue = lookupData;



    Cheers,
    Jim


    Jim Wang - MVP Dynamics CRM - http://jianwang.blogspot.com , http://mscrm.cn
    Tuesday, May 5, 2009 8:47 AM
    Moderator