locked
How to set a pick list and option set values in CRM 2011 using C# RRS feed

  • Question

  • Can u help  How to set a pick list and option set values  in CRM 2011 using C# ..



    NO ONE CAN STOP ME.....

    Friday, March 30, 2012 12:13 PM

Answers

  • Hello Cool Dude ;)

    Actually your question has a lot of answers and the correct depends on answer of following question - do you use early binding or late binding in your code?

    In case of early binding your code will look like:

    InstanceOfYourEntity.OptionSetField = new OptionSetValue(ValueOfOptionSet);

    In case of late binding your code will look like:
    InstanceOfYourEntity["optionsetfield"] = new OptionSetValue(ValueOfOptionSet);


    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    Follow Andriy on Twitter

    Friday, March 30, 2012 4:00 PM
    Moderator
  • Hi Parth Cool Dude,

    Try this code...

    LookupProperty companyId = new LookupProperty();
            companyId.Name = "new_companyid";
            companyId.Value = new Lookup();
            companyId.Value.name = DdlCompany.SelectedItem.Text;
            companyId.Value.Value = new Guid(DdlCompany.SelectedValue);

    CrmDateTimeProperty estimatedStartDate = new CrmDateTimeProperty();
            estimatedStartDate.Name = "new_estimatedstartdate";
            estimatedStartDate.Value = new CRM.CrmDateTime();
            estimatedStartDate.Value.Value = Convert.ToString(CalEstimatedStartDate.SelectedDate);

    PicklistProperty projectTypepicklist = new PicklistProperty();
            projectTypepicklist.Name = "new_projecttypepicklist";
            projectTypepicklist.Value = new Picklist();
            projectTypepicklist.Value.Value = DdlProjectType.SelectedIndex + 1;

    Now you can understand how to do this.... Ok.!!

    Thursday, April 5, 2012 9:05 AM

All replies

  • Try:-

        OptionSetValue op = new OptionSetValue(143570000);
                    shortlist.new_StatusSelectedCheckbox = op;

    Regards Faisal

    Friday, March 30, 2012 12:19 PM
  • hi :Faisal Fiaz 

    i tried the code itz not working.

    what is "shortlist.new_StatusSelectedCheckbox".

    where are u  mapping.


    NO ONE CAN STOP ME.....

    Friday, March 30, 2012 1:00 PM
  • Hello Cool Dude ;)

    Actually your question has a lot of answers and the correct depends on answer of following question - do you use early binding or late binding in your code?

    In case of early binding your code will look like:

    InstanceOfYourEntity.OptionSetField = new OptionSetValue(ValueOfOptionSet);

    In case of late binding your code will look like:
    InstanceOfYourEntity["optionsetfield"] = new OptionSetValue(ValueOfOptionSet);


    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    Follow Andriy on Twitter

    Friday, March 30, 2012 4:00 PM
    Moderator
  • Hi Parth Cool Dude,

    Try this code...

    LookupProperty companyId = new LookupProperty();
            companyId.Name = "new_companyid";
            companyId.Value = new Lookup();
            companyId.Value.name = DdlCompany.SelectedItem.Text;
            companyId.Value.Value = new Guid(DdlCompany.SelectedValue);

    CrmDateTimeProperty estimatedStartDate = new CrmDateTimeProperty();
            estimatedStartDate.Name = "new_estimatedstartdate";
            estimatedStartDate.Value = new CRM.CrmDateTime();
            estimatedStartDate.Value.Value = Convert.ToString(CalEstimatedStartDate.SelectedDate);

    PicklistProperty projectTypepicklist = new PicklistProperty();
            projectTypepicklist.Name = "new_projecttypepicklist";
            projectTypepicklist.Value = new Picklist();
            projectTypepicklist.Value.Value = DdlProjectType.SelectedIndex + 1;

    Now you can understand how to do this.... Ok.!!

    Thursday, April 5, 2012 9:05 AM