locked
get Picklist selected value RRS feed

  • Question

  • how could i get selected value from Picklist?
     Picklist just has the folowing properties : name,value,isnull 
    foreach(object HeartBeat in me.heart.Beats) messageBox.show("I miss u !!")
    Monday, April 27, 2009 10:33 AM

All replies

  • Hi,

    It depends on which context you are using it

    For javascript we have GetSelectedOption() method.

    In case of plugin or custom workflow activity you could you could get it either from context's inputparameter or through image registered as explained here
    http://nishantrana.wordpress.com/2008/07/11/preentity-and-postentity-images-in-crm-40/

    Regards,
    Nishant Rana








    http://nishantrana.wordpress.com
    Monday, April 27, 2009 10:46 AM
  • You could use either of the two methods below.

    The examples have been copy pasted from the MS CRM SDK help file.

    If you haven't already I recommend you download it.



    EXAMPLE below:

    {Field}.SelectedText

    Description:  Get property

    Returns the string value of the currently selected option.



    OR


    {Field}.DataValue

    Description: Get/set property

    Get returns a string representation of the value of the currently selected option. You can use the method parseInt() to safely convert this to an integer value.

    Set changes the selection to the value specified.

     

     

    H.


    Technical Consultant | http://hassanhussain.wordpress.com/
    • Proposed as answer by Hassan Hussain Monday, April 27, 2009 10:46 AM
    Monday, April 27, 2009 10:46 AM
  • [CrmWorkflowActivity("Create Phone Call", "Smart Money Activities")]
    
        public partial class CustomActivity : SequenceActivity
    
        {
    
            public CustomActivity()
    
            {
    
                InitializeComponent();
    
            }
    
    
    
            public static DependencyProperty myPicklistProperty = DependencyProperty.Register("myPicklist", typeof(Picklist), typeof(CustomActivity));
    
    
    
            [CrmInput("My Picklist")]
    
            [CrmAttributeTarget("account", "industrycode")]
    
            public Picklist myPicklist
    
            {
    
                get
    
                {
    
                    return (Picklist)base.GetValue(myPicklistProperty);
    
                }
    
                set
    
                {
    
                    base.SetValue(myPicklistProperty, value);
    
                }
    
            }
    
     protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
    
            {
    
                IContextService contextService = (IContextService)   executionContext.GetService(typeof(IContextService));
    
                IWorkflowContext context = contextService.Context;
    
                ICrmService crmService = context.CreateCrmService();
    
                         Microsoft.Crm.SdkTypeProxy.email myemail = new Microsoft.Crm.SdkTypeProxy.email();
    
                myemail.subject = "task subject";
    
                myemail.to = myPicklist; //how could i do this , is it necessary to use java script ?
    
    
    
    ...
    
    ..
    
    ...

    foreach(object HeartBeat in me.heart.Beats) messageBox.show("I miss u !!")
    Monday, April 27, 2009 11:03 AM
  • Hi,

    To get the selected value in Picklist, while adding the step for workflow, when you click on set properities, the dialog box would open up wherein you could set
    the value for your mypicklist as selected picklist value for that record using Dynamic Value.
    You could set it value as {Industry(Account)} dynamic value and you could refer it within your above code as

    myemail.to =myPicklist.name;

    Regards,
    Nishant Rana
    http://nishantrana.wordpress.com
    Monday, April 27, 2009 11:18 AM
  • Cannot implicitly convert type 'string' to 'Microsoft.Crm.Sdk.
    foreach(object HeartBeat in me.heart.Beats) messageBox.show("I miss u !!")
    Monday, April 27, 2009 11:50 AM
  • Hi,

    This is how you would set the  myemail.to property

                Microsoft.Crm.SdkTypeProxy.activityparty[] ap = new Microsoft.Crm.SdkTypeProxy.activityparty[1];
                ap[0] = new activityparty();
                ap[0].partyid = new Lookup();
                ap[0].partyid.type = EntityName.systemuser.ToString();
                ap[0].partyid.Value = new Guid("guidOfCrmUser");

                Microsoft.Crm.SdkTypeProxy.email mymail = new Microsoft.Crm.SdkTypeProxy.email();
                mymail.to = ap;


    Regards,
    Nishant Rana

    http://nishantrana.wordpress.com
    Monday, April 27, 2009 12:46 PM