Community
Showing results for 
Search instead for 
Do you mean 
Reply

Add an event on a picklist

Accepted Solution Solved
Copper Contributor
Posts: 6
Country: Hong_Kong
Accepted Solution

Add an event on a picklist

Hello, 

Im trying to add an event on a picklist but that doesn't work, I've tried a lot of things but this keep failing if someone has an idea ?

Hope this time, one guy will give 2min of his time to answer. That could be nice.

Thanks, koceila.


Accepted Solutions
Solution
Accepted by topic author koceila
‎05-09-2016 07:10 AM
Copper Contributor
Posts: 6
Country: Hong_Kong

Re: Add an event on a picklist

Hello,

Thanks for your answer, I've already solved the problem. For next guys :

if (fieldName == registration.Name)
{
  os.ListRegistrationUpdate();
}

public void ListRegistrationUpdate()
{
 var o = application.ApplicationState.CurrentOpportunity;
            string choix = Convert.ToString(o.OpportunityFields["Opportunity.License_Registration"]);
            string requete = ReadingRequest.Request(choix, 102);
            if (!(requete.Equals("null")) && !(requete.Equals("Error_Connection_Failed")))
            {
                dynamic registrationSelect = Newtonsoft.Json.JsonConvert.DeserializeObject(requete);
                // La date 0000-00-00 n est pas supporte par le convert on doit donc obligatoirement verifier
                if (!((Convert.ToString(registrationSelect.Registration_Date)).Equals("0000-00-00")))
                {
                    o.OpportunityFields["Opportunity.License_Registration_Date", false] = Convert.ToDateTime(registrationSelect.Registration_Date);
                }
                else
                {
                    o.OpportunityFields["Opportunity.License_Registration_Date", false] = null;
                }
                if (!((Convert.ToString(registrationSelect.Last_Update_Date)).Equals("0000-00-00")))
                {
                    o.OpportunityFields["Opportunity.License_Last_Update_Date", false] = Convert.ToDateTime(registrationSelect.Last_Update_Date);
                }
                else
                {
                    o.OpportunityFields["Opportunity.License_Last_Update_Date", false] = null;
                }
                if (!((Convert.ToString(registrationSelect.Last_Use_Date)).Equals("0000-00-00")))
                {
                    o.OpportunityFields["Opportunity.License_Last_Use_Date", false] = Convert.ToDateTime(registrationSelect.Last_Use_Date);
                }
                else
                {
                    o.OpportunityFields["Opportunity.License_Last_Use_Date", false] = null;
                }
            }
            else
            {
                if ((requete.Equals("Error_Connection_Failed")))
                {
                    MessageBox.Show("Un probleme de connexion est survenu");
                }
                SuppressionRegistrationWithoutListValues();
            }
            o.Update();
        }

Forgot to clean my picklist was one of my mistake too.

 

                    var ACTFM = application.ActFramework;
                    var pickListRegistrationOpportunity = ACTFM.PickLists.GetPickList("License_Registrations_List_Opportunity");
                    while (pickListRegistrationOpportunity.Items.Count > 0)
                    {
                        pickListRegistrationOpportunity.Items.RemoveAt(0);
                    }

View solution in original post


All Replies
Bronze Super Contributor
Posts: 1,231
Country: USA

Re: Add an event on a picklist

Not sure what event you are trying to hook into. SelectedIndexChanged, TextChange, ect

 

Can you pots your code so far?

 

-- Jim 

Solution
Accepted by topic author koceila
‎05-09-2016 07:10 AM
Copper Contributor
Posts: 6
Country: Hong_Kong

Re: Add an event on a picklist

Hello,

Thanks for your answer, I've already solved the problem. For next guys :

if (fieldName == registration.Name)
{
  os.ListRegistrationUpdate();
}

public void ListRegistrationUpdate()
{
 var o = application.ApplicationState.CurrentOpportunity;
            string choix = Convert.ToString(o.OpportunityFields["Opportunity.License_Registration"]);
            string requete = ReadingRequest.Request(choix, 102);
            if (!(requete.Equals("null")) && !(requete.Equals("Error_Connection_Failed")))
            {
                dynamic registrationSelect = Newtonsoft.Json.JsonConvert.DeserializeObject(requete);
                // La date 0000-00-00 n est pas supporte par le convert on doit donc obligatoirement verifier
                if (!((Convert.ToString(registrationSelect.Registration_Date)).Equals("0000-00-00")))
                {
                    o.OpportunityFields["Opportunity.License_Registration_Date", false] = Convert.ToDateTime(registrationSelect.Registration_Date);
                }
                else
                {
                    o.OpportunityFields["Opportunity.License_Registration_Date", false] = null;
                }
                if (!((Convert.ToString(registrationSelect.Last_Update_Date)).Equals("0000-00-00")))
                {
                    o.OpportunityFields["Opportunity.License_Last_Update_Date", false] = Convert.ToDateTime(registrationSelect.Last_Update_Date);
                }
                else
                {
                    o.OpportunityFields["Opportunity.License_Last_Update_Date", false] = null;
                }
                if (!((Convert.ToString(registrationSelect.Last_Use_Date)).Equals("0000-00-00")))
                {
                    o.OpportunityFields["Opportunity.License_Last_Use_Date", false] = Convert.ToDateTime(registrationSelect.Last_Use_Date);
                }
                else
                {
                    o.OpportunityFields["Opportunity.License_Last_Use_Date", false] = null;
                }
            }
            else
            {
                if ((requete.Equals("Error_Connection_Failed")))
                {
                    MessageBox.Show("Un probleme de connexion est survenu");
                }
                SuppressionRegistrationWithoutListValues();
            }
            o.Update();
        }

Forgot to clean my picklist was one of my mistake too.

 

                    var ACTFM = application.ActFramework;
                    var pickListRegistrationOpportunity = ACTFM.PickLists.GetPickList("License_Registrations_List_Opportunity");
                    while (pickListRegistrationOpportunity.Items.Count > 0)
                    {
                        pickListRegistrationOpportunity.Items.RemoveAt(0);
                    }