Search code examples
javascriptdynamics-crm-2011

how to save data through javascript in select list in crm


I am adding a selectlist in my web resource and then saving the data through JavaScript like this

entity.attributes['new_category'] = categoryValue;

where 

categoryValue = $("#category option:selected")[0].innerHTML

But when i am creating the entity like 

XrmServiceToolkit.Soap.Create(entity)

it is throwing me and error


Solution

  • When trying to assign option set values using XrmServiceToolkit, which new_category does look like it is, you need to assign the value like so:

    entity.attributes["new_category"] = { value: categoryValue, type: "OptionSetValue" };