Community
Showing results for 
Search instead for 
Do you mean 
Reply

Button control creating errors in ACT Log (I think)

Copper Contributor
Posts: 123
Country: Canada

Button control creating errors in ACT Log (I think)

I have been working on some button controls that do certain functions for the users at the company I work for.

I had an issue getting one to draw onto the Group Layout so I decided to look in the logs and found the errors below:

 

Any idea what would cause this error? It seems like the errors only show up when I open up the layout designer for one of the layouts which I have added the Button control to.

Error Exception: System.NotSupportedException: TypeConverter cannot convert from System.String.
   at System.ComponentModel.TypeConverter.GetConvertFromException(Object value)
   at System.ComponentModel.TypeConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
   at System.ComponentModel.TypeConverter.ConvertFromInvariantString(ITypeDescriptorContext context, String text)
   at Act.UI.Designer.Layout.LayoutDesignerLoader.ReadValue(XmlNode node, TypeConverter converter, ArrayList errors, Object& value)System.Exception: System.NotSupportedException: TypeConverter cannot convert from System.String.
   at System.ComponentModel.TypeConverter.GetConvertFromException(Object value)
   at System.ComponentModel.TypeConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
   at System.ComponentModel.TypeConverter.ConvertFromInvariantString(ITypeDescriptorContext context, String text)
   at Act.UI.Designer.Layout.LayoutDesignerLoader.ReadValue(XmlNode node, TypeConverter converter, ArrayList errors, Object& value)

Also this is an error that happens directly after:

Error Exception: Unable to parse node: 'False'.System.Exception: Unable to parse node: 'False'.

 


I'm not very experienced with programming these but the code I was using is below.  Any thoughts or sugestions?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.ComponentModel;

using Act.Framework;
using Act.UI;
using Act.Framework.Contacts;
using Act.Framework.Opportunities;
using Act.Shared.ComponentModel;
using Act.Framework.ComponentModel;
using Act.Shared.Collections;

namespace Act.Custom.Controls
{
    [
       CustomControlAttribute(true), // mark as a custom control
       LayoutToolboxItemFriendlyName(), // give the control a name
    ]
    class DoctorLetterWritten : Button // we implement this interface only for being an opportunity bound control
    {
        private ActApplication actApp;
        private ActFramework actFwk;
        
        public DoctorLetterWritten()
        {
            actApp = Act.UI.ActApplication.Instance;
            actFwk = actApp.ActFramework;
            this.Click += btn_clicked;
        }
        ~DoctorLetterWritten()
        {
            this.Click -= btn_clicked;
        }

        public override string Text
        {
            get
            {
                // we want the button text to be the same regardless of design mode
                return "Doctor Letter Written";
            }
            set
            {
                ;// we don't want to allow programmatic setting of this
            }
        }

        private void btn_clicked(object sender, EventArgs de)
        {
            
            Act.Framework.Opportunities.Opportunity currentOpp = actApp.ApplicationState.CurrentOpportunity;
            if (currentOpp != null)
            {
                string oppName = currentOpp.Name;
                DialogResult result = MessageBox.Show("Are you sure you want to update opportunity: "+ currentOpp.Name + "\n" + "\n" + "Stage = Waiting on Dr." + "\n" + "Dr Letter Date = Today's Date", "WARNING!", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    SetDrLetterFields(currentOpp);
                }
                
            }
        }

        public static string LayoutToolboxFriendlyName
        {
            get
            {
                return "Doctor Letter Written";
            }
        }

        private void SetDrLetterFields(Opportunity opp)
        {
            // the User5 field is the Dr Letter Date field in ACT
            opp.User5 = DateTime.Today;
            
            // get the stage I want to set on the opp
            Act.Framework.Opportunities.Stage[] stages = actApp.ActFramework.StageManager.GetStages("Waiting on Dr.");
            Act.Framework.Opportunities.Stage oppStage = stages.First();
            
            //set the stage and update
            opp.Stage = oppStage;

            // the line below is used to set other fields.
            //opp.Fields["Additional Info Date", Act.Framework.MutableEntities.FieldNameType.Alias] = DateTime.Today;
            opp.Update();


            MessageBox.Show("Successfully updated: " + opp.Name + "\n" + "\n" + "Stage = Waiting on Dr." + "\n" + "Dr Letter Date = Today's Date");

        }

    }
}

 

 

 

Copper Contributor
Posts: 123
Country: Canada

Re: Button control creating errors in ACT Log (I think)

I most likely didn't set some properties on the button correctly but not quite sure.

Realize my code is probably horrific.