locked
DropDown List on CRM 2011 how to connect with plugin RRS feed

  • Question

  • Hey guys I have a question

    I am creating a page aspx to create records on my CRM Organization, I have a dropdown list with three values, and on my page aspx I have the same three options, how can I match this with CRM, like if I have a lookup on my CRM, on the .NET code I did

    incident["customerid"] = new EntityReference("contact", contact_GUID)

    how can I do like this, but the field on CRM is a DropDown List not a Lookup ?

    thanks

    Friday, September 30, 2011 11:37 AM

Answers

  • Its working for me

    try

    OptionSetValue op = new OptionSetValue();

    OptionSetValue.Value=3;

    incident["caseoringcode"] = op;

    I hope this helps.

     

     


    Amreek singh Senior CRM Consultant CDC Praxa Sydney,Australia http://mscrmshop.blogspot.com/
    • Marked as answer by Gustavo CRM Friday, September 30, 2011 1:49 PM
    Friday, September 30, 2011 1:10 PM

All replies

  • it is like

    fieldname =new OptionSetValue(1);// change the value 2/3/

    I hope this helps.


    Amreek singh Senior CRM Consultant CDC Praxa Sydney,Australia http://mscrmshop.blogspot.com/
    Friday, September 30, 2011 12:19 PM
  • Sorry but did not work

    I put like this:

    incident["caseoringcode"] = new OptionSetValue(3) //3 because is the WEB number on the field on the CRM

    but did not work =[ an error ocurred and if I comment this line I can create the record.

     

    Friday, September 30, 2011 12:40 PM
  • Its working for me

    try

    OptionSetValue op = new OptionSetValue();

    OptionSetValue.Value=3;

    incident["caseoringcode"] = op;

    I hope this helps.

     

     


    Amreek singh Senior CRM Consultant CDC Praxa Sydney,Australia http://mscrmshop.blogspot.com/
    • Marked as answer by Gustavo CRM Friday, September 30, 2011 1:49 PM
    Friday, September 30, 2011 1:10 PM
  • thanks worked =]

    I was doing a mistake on the code hehe

    Friday, September 30, 2011 1:49 PM
  • Just other question

     

    now I need to retrieve this informations like

    Entity cases = new Entity("incident");

    string origin = cases["caseorigincode"].ToString();

    string client = cases["customerid"].ToString();

     

    The problem is that: I can`t get the text of the field I recieve something like that:

    origin = Microsoft.Xrm.Sdk.OptionSetValue

    client = Microsoft.Xrm.Sdk.EntityReference

    what I need to do to get the TEXTS of this fields ?

    thanks

     

    Friday, September 30, 2011 1:59 PM
  • Hi,

    Regarding OptionSet field, you need to retrieve the OptionSet label as mentioned in the following posts with sample codes: http://social.microsoft.com/Forums/en-US/crmdevelopment/thread/0d3e4d5e-2635-4bb7-a0a6-2314aefe1250

    http://social.microsoft.com/Forums/en-US/crm/thread/e307b84e-4934-4664-8d8b-d3f2f56c1fa1/

    Regarding Lookup field, you need to retieve the entity primary field using Service.Retrieve call i.e.

     

    Entity AccountEntity = Service.Retrieve("account", account_guid, new ColumnSet(new string[]{"name"}));

     

    string name = AccountEntity["name"].toString();


    Jehanzeb Javeed

    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".

    Friday, September 30, 2011 2:06 PM
  • Jehanzeb

     

    Ok but how I will get the GUIDID of the client ?

    what I am doing is that

     

    Entity cases = new Entity("incident");

    cases = service.retrieve("incident", GUID(that I did a FetchXML), new ColumnSet(new String[]{"customerid"}));

    but if i put

    var test = cases["customerid"] I dont recieve the GUID of this customer, how can I do that ?

    thanks

    Friday, September 30, 2011 2:38 PM
  • Hi,

    You will get the GUID by type casting the customerid attribute to EntityReference, i.e.

    EntityReference CustomerEntityRef = (EntityReference)cases["customerid"];

    // Could be contact or account

    EntityName = CustomerEntityRef.Name;

    Guid EntityId = CustomerEntityRef.Id; 

     


    Jehanzeb Javeed

    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    Friday, September 30, 2011 2:42 PM
  • string origin = cases["caseorigincode"].Value.ToString();// it will give you value like 1/2/3

    string client = cases["customerid"].Name;  //to get the name or .Id.ToString(); to get guids as string

    If you want to get text value in the optionset check FormatedValues

    I hope this helps.


    Amreek singh Senior CRM Consultant CDC Praxa Sydney,Australia http://mscrmshop.blogspot.com/
    • Proposed as answer by Amreek Singh Sunday, October 2, 2011 1:03 PM
    Sunday, October 2, 2011 1:03 PM