Community
Showing results for 
Search instead for 
Do you mean 
Reply

Giving back to the Community - Sample Code - Recurring Activities, Opportunities, Products

Copper Super Contributor
Posts: 478
Country: Australia

Giving back to the Community - Sample Code - Recurring Activities, Opportunities, Products

Hi all

 

Over the last year i have been writing some code to customise my Act and received a lot of help from the Act Community particularly wellmet, jimdurkin, sam_raikes, vivek, knif and several others. So to help other newbies i will post my code here.

 

Before i do you must understand i am not a coder to claim such would be insulting to those listed above, i only dabble, so my code is not sexy or clean, it is what it is.

 

Once the first button had been created i then went to town on automation of workflow the 2nd project was creating buttons for when i sold a product to a client it would then create the entire workflow, problems to deal with where Recurring Activities, create a new Opportunity, add Product to the Opportunity, and custom fields in the Opportunity.

 

The code below is for my Investment Application Button and deals with 4 different investment types i sell to clients

 

    [Act.Shared.ComponentModel.CustomControl(true)]

    //Investment Fund Application Button
    // Work flow items specific to the processing of an application for non superannuation based investments. Only one option can be selected at a time
    class Button4 : System.Windows.Forms.Button
    {
        protected override void OnClick(System.EventArgs e)
        {
            try
            {


                Contact c = Act.UI.ActApplication.Instance.ApplicationState.CurrentContact;

                //List out the activity types
                Act.Framework.Activities.ActivityType[] activityTypes = Act.UI.ActApplication.Instance.ActFramework.Activities.GetActivityTypes();

                //set a new activity template link
                Act.Framework.Activities.ActivityTemplate aTemplate;

                //Get Platform Name
                ContactFieldDescriptor PlatCompFD = null;
                PlatCompFD = Act.UI.ActApplication.Instance.ActFramework.Contacts.GetContactFieldDescriptor("CUST_ContactTable1_090144.CUST_Platform_065607025", true);
                string PlatComp = PlatCompFD.GetValue(c).ToString();

                //Get Annuity Type Checkboxes
                ContactFieldDescriptor AnnuityProdFD = null;
                AnnuityProdFD = Act.UI.ActApplication.Instance.ActFramework.Contacts.GetContactFieldDescriptor("CUST_ContactTable1_090144.CUST_ProdAnn_071358635", true);
                string AnnuityProdVal = AnnuityProdFD.GetValue(c).ToString();

                //Get Managed Fund Type Checkboxes
                ContactFieldDescriptor MFundProdFD = null;
                MFundProdFD = Act.UI.ActApplication.Instance.ActFramework.Contacts.GetContactFieldDescriptor("CUST_ContactTable1_090144.CUST_ProdMFunds_071419275", true);
                string MFundProdVal = MFundProdFD.GetValue(c).ToString();

                //Get DomaCom Type Checkboxes
                ContactFieldDescriptor DomaComProdFD = null;
                DomaComProdFD = Act.UI.ActApplication.Instance.ActFramework.Contacts.GetContactFieldDescriptor("CUST_ContactTable1_090144.CUST_DomaCom_073359680", true);
                string DomaComProdVal = DomaComProdFD.GetValue(c).ToString();

                //Get MDA SMA Type Checkboxes
                ContactFieldDescriptor MDAProdFD = null;
                MDAProdFD = Act.UI.ActApplication.Instance.ActFramework.Contacts.GetContactFieldDescriptor("CUST_ContactTable1_090144.CUST_MDASMA_073427355", true);
                string MDAProdVal = MDAProdFD.GetValue(c).ToString();

                PlatCompFD.SetValue(c, " ");
                MFundProdFD.SetValue(c, false);
                AnnuityProdFD.SetValue(c, false);
                DomaComProdFD.SetValue(c, false);
                MDAProdFD.SetValue(c, false);

                //Roll through each activity type and establish new activites 
                foreach (Act.Framework.Activities.ActivityType a in activityTypes)
                {
                    if (a.Name == "To-do")
                    {
                        string regarding = "Check Application (" + PlatComp + ")";
                        string details = "Application for " + c.FullName + " has been checked for any missing or incomplete data (a separate Activity is to be established for each missing item)\n\nScan Copy: Yes / No\n\nPaper App: Yes / No\n\nDetails: Nil\n\n\nAnnuity: " + AnnuityProdVal + " (Non Super Money)\nMFunds: " + MFundProdVal + "\nDomaCom: " + DomaComProdVal + "\nMDA-SMA: " + MDAProdVal + "\n";
                        string location = "Office";

                        aTemplate = Act.UI.ActApplication.Instance.ActFramework.Activities.CreateActivity(a);
                        aTemplate.ActivityContacts.Add(c);
                        aTemplate.StartTime = System.DateTime.Now.AddMinutes(65);
                        aTemplate.EndTime = System.DateTime.Now.AddMinutes(15);
                        aTemplate.Regarding = regarding;
                        aTemplate.Location = location;
                        aTemplate.Details = details;
                        aTemplate.Priority = Act.UI.ActApplication.Instance.ActFramework.Activities.GetActivityPriority("Low");
                        aTemplate.Update();
                    }

                    if (a.Name == "To-do")
                    {
                        string regarding = "Check ID has been provided to " + PlatComp + "";
                        string details = "Check that the FSC ID Forms have been provided for " + c.FullName + " and detail or copy of forms sent to the provider (" + PlatComp + ")\n\n Details: Nil\n\nScan Copy: Yes / No\n\nPaper Copy: Yes / No\n\n";
                        string location = "Office";

                        aTemplate = Act.UI.ActApplication.Instance.ActFramework.Activities.CreateActivity(a);
                        aTemplate.ActivityContacts.Add(c);
                        aTemplate.StartTime = System.DateTime.Now.AddMinutes(75);
                        aTemplate.EndTime = System.DateTime.Now.AddMinutes(15);
                        aTemplate.Regarding = regarding;
                        aTemplate.Location = location;
                        aTemplate.Details = details;
                        aTemplate.Priority = Act.UI.ActApplication.Instance.ActFramework.Activities.GetActivityPriority("Medium");
                        aTemplate.Update();
                    }

                    if (a.Name == "To-do")
                    {
                        string regarding = "Process Application (" + PlatComp + ")";
                        string details = "Application for Annuity: " + AnnuityProdVal + " (Non Super Money), MFunds: " + MFundProdVal + ", DomaCom: " + DomaComProdVal + ", MDA-SMA: " + MDAProdVal + ", has been processed\n\nLogement Method: Online / Mail\n\nDetails: Nil\n\n";
                        string location = "Office";

                        aTemplate = Act.UI.ActApplication.Instance.ActFramework.Activities.CreateActivity(a);
                        aTemplate.ActivityContacts.Add(c);
                        aTemplate.StartTime = System.DateTime.Now.AddMinutes(95);
                        aTemplate.EndTime = System.DateTime.Now.AddMinutes(70);
                        aTemplate.Regarding = regarding;
                        aTemplate.Location = location;
                        aTemplate.Details = details;
                        aTemplate.Priority = Act.UI.ActApplication.Instance.ActFramework.Activities.GetActivityPriority("High");
                        aTemplate.Update();
                    }

                    if (a.Name == "To-do")
                    {
                        string regarding = "Check Status of " + PlatComp + " Application";
                        string details = "Status of the application was checked online\n\nDetails:\n\n";
                        string location = "Office";

                        aTemplate = Act.UI.ActApplication.Instance.ActFramework.Activities.CreateActivity(a);
                        aTemplate.ActivityContacts.Add(c);
                        aTemplate.StartTime = System.DateTime.Now.AddHours(48);
                        aTemplate.EndTime = aTemplate.StartTime.AddMinutes(15);
                        aTemplate.Regarding = regarding;
                        aTemplate.Location = location;
                        aTemplate.Details = details;
                        aTemplate.Priority = Act.UI.ActApplication.Instance.ActFramework.Activities.GetActivityPriority("Medium");
                        aTemplate.Update();
                    }

                    if (a.Name == "To-do")
                    {
                        string regarding = "Follow up Investment Funds";
                        string details = "Check online the receipt of funds, if required contact the source and destination funds for clarity, and check if the DDR has been processed correctly.\n\n Details:\n\n";
                        string location = "Office";

                        aTemplate = Act.UI.ActApplication.Instance.ActFramework.Activities.CreateActivity(a);
                        aTemplate.ActivityContacts.Add(c);
                        aTemplate.StartTime = System.DateTime.Now.AddDays(3);
                        aTemplate.EndTime = aTemplate.StartTime.AddMinutes(20);
                        aTemplate.Regarding = regarding;
                        aTemplate.Location = location;
                        aTemplate.Details = details;
                        aTemplate.Priority = Act.UI.ActApplication.Instance.ActFramework.Activities.GetActivityPriority("Medium");
                        aTemplate.Update();
                    }

                    if (a.Name == "To-do")
                    {
                        string regarding = "Investment Allocation";
                        string details = "Lodge the investment allocation once the funds have been received with care taken to any substancial changes in the investment market from original SOA";
                        string location = "Office";

                        aTemplate = Act.UI.ActApplication.Instance.ActFramework.Activities.CreateActivity(a);
                        aTemplate.ActivityContacts.Add(c);
                        aTemplate.StartTime = System.DateTime.Now.AddDays(5);
                        aTemplate.EndTime = aTemplate.StartTime.AddMinutes(45);
                        aTemplate.Regarding = regarding;
                        aTemplate.Location = location;
                        aTemplate.Details = details;
                        aTemplate.Priority = Act.UI.ActApplication.Instance.ActFramework.Activities.GetActivityPriority("High");
                        aTemplate.Update();
                    }

                    if (a.Name == "To-do")
                    {
                        string regarding = "Update Database Details";
                        string details = "CRM Database has been updated to include new (" + PlatComp + ") products, and if relevant removal of old products";
                        string location = "Office";

                        aTemplate = Act.UI.ActApplication.Instance.ActFramework.Activities.CreateActivity(a);
                        aTemplate.ActivityContacts.Add(c);
                        aTemplate.StartTime = System.DateTime.Now.AddDays(6);
                        aTemplate.EndTime = aTemplate.StartTime.AddMinutes(25);
                        aTemplate.Regarding = regarding;
                        aTemplate.Location = location;
                        aTemplate.Details = details;
                        aTemplate.Priority = Act.UI.ActApplication.Instance.ActFramework.Activities.GetActivityPriority("Low");
                        aTemplate.Update();
                    }

                    if (a.Name == "To-do")
                    {
                        string regarding = "Update Family Fee Group";
                        string details = "Check clients platform and where possible / relevant cross link family accounts to reduce the administration fee structure within the " + PlatComp + " platform.";
                        string location = "Office";

                        aTemplate = Act.UI.ActApplication.Instance.ActFramework.Activities.CreateActivity(a);
                        aTemplate.ActivityContacts.Add(c);
                        aTemplate.StartTime = System.DateTime.Now.AddDays(16);
                        aTemplate.EndTime = aTemplate.StartTime.AddMinutes(5);
                        aTemplate.Regarding = regarding;
                        aTemplate.Location = location;
                        aTemplate.Details = details;
                        aTemplate.Priority = Act.UI.ActApplication.Instance.ActFramework.Activities.GetActivityPriority("Low");
                        aTemplate.Update();
                    }

                    if (a.Name == "To-do")
                    {
                        string regarding = "Confirm Investment Allocation";
                        string details = "Confirm the investment allocation for the " + PlatComp + " account has been finalised.";
                        string location = "Office";

                        aTemplate = Act.UI.ActApplication.Instance.ActFramework.Activities.CreateActivity(a);
                        aTemplate.ActivityContacts.Add(c);
                        aTemplate.StartTime = System.DateTime.Now.AddDays(7);
                        aTemplate.EndTime = aTemplate.StartTime.AddMinutes(15);
                        aTemplate.Regarding = regarding;
                        aTemplate.Location = location;
                        aTemplate.Details = details;
                        aTemplate.Priority = Act.UI.ActApplication.Instance.ActFramework.Activities.GetActivityPriority("Low");
                        aTemplate.Update();
                    }

                    if (a.Name == "To-do")
                    {
                        string regarding = PlatComp + " Cash Account and Investment Review Check";
                        string details = "Check existing investments and particularly the cash account if required switch funds into existing investment mixture\n\n Details: \n\n";
                        string location = "Office";

                        aTemplate = Act.UI.ActApplication.Instance.ActFramework.Activities.CreateActivity(a);
                        aTemplate.ActivityContacts.Add(c);
                        aTemplate.StartTime = System.DateTime.Now.AddDays(30);
                        aTemplate.EndTime = aTemplate.StartTime.AddMinutes(30);
                        aTemplate.Regarding = regarding;
                        aTemplate.Location = location;
                        aTemplate.Details = details;
                        aTemplate.Priority = Act.UI.ActApplication.Instance.ActFramework.Activities.GetActivityPriority("Medium");

                        int StartDay = aTemplate.StartTime.Day;
                        int StartMonth = aTemplate.StartTime.Month;

                        ActivityRecurSpec recurSpec = (ActivityRecurSpec)aTemplate.RecurSpec.Clone();

                        ActivityRecurDay activityRecurDay = new ActivityRecurDay(StartDay);
                        recurSpec.DayType = ActivityRecurDayType.Numbered;
                        recurSpec.Day = activityRecurDay;

                        recurSpec.IsEndless = true;

                        recurSpec.Period = ActivityRecurPeriod.Monthly;
                        recurSpec.Frequency = 1;

                        if (ActivityRecurUtility.ValidateRecurSpec(recurSpec, true))
                        {
                            aTemplate.RecurSpec = recurSpec;

                            try
                            {
                                aTemplate.Update();
                            }
                            catch
                            {
                                throw;
                            }
                        }
                        else
                        {
                            // INVALID RECUR SPEC
                        }


                    }
                }

                c.Update();

                Act.UI.ActApplication.Instance.RefreshLoadedViews();

                if (AnnuityProdVal == "True")
                {
                    OpportunityStatus oStatus = OpportunityStatus.Open;
                    int iProbability = 50;
                    DateTime dEstCloseDate = System.DateTime.Now.AddDays(15);
                    Boolean bMakeItPrivate = false;
                    string sName = "" + PlatComp + " Non Superannuation Annuity (Pension Phase)";

                    ContactList cList = Act.UI.ActApplication.Instance.ActFramework.Contacts.GetContacts(null);
                    Contact cContact = cList[0];

                    Guid[] gArray = new Guid[1];
                    gArray[0] = c.ID;

                    //List out the note types
                    Act.Framework.Notes.NoteType[] noteTypes = Act.UI.ActApplication.Instance.ActFramework.Notes.GetNoteTypes();
                    DateTime now = DateTime.Now;

                    Stage[] sStages = Act.UI.ActApplication.Instance.ActFramework.StageManager.Processes[0].Stages;
                    Stage oStage = sStages[5];

                    ProductList pList = Act.UI.ActApplication.Instance.ActFramework.Products.GetProducts(null);
                    Product pProduct = pList[18];

                    string sReason = "A new Annuity (ordinary money) with " + PlatComp + " has been finalised in the name " + c.FullName + " ";
                    DateTime dOpenDate = System.DateTime.Now; decimal curval1 = 0;

                    Opportunity oOpp = Act.UI.ActApplication.Instance.ActFramework.Opportunities.CreateOpportunity(sName, oStatus, oStage, dEstCloseDate, bMakeItPrivate);
                    oOpp.Probability = iProbability;
                    oOpp.User7 = "Investment";
                    oOpp.Competitor = PlatComp;
                    oOpp.Reason = sReason;
                    oOpp.UpdateContacts(gArray, null); oOpp.Update();
                    oOpp.Fields["TBL_OPPORTUNITY.CUST_AdviceSUM_050445029",  true] = curval1;
                    oOpp.Fields["TBL_OPPORTUNITY.CUST_AdvicePUM_050311460",  true] = curval1;
                    oOpp.Fields["TBL_OPPORTUNITY.CUST_AdviceFUM_050239770",  true] = curval1;
                    //Set a new Note
                    Act.UI.ActApplication.Instance.ActFramework.Notes.CreateNote(noteTypes[0], "New Opportunity created titled " + sName + "\n" + sReason + "\n\nThis is under the " + oOpp.User7 + " opportunity type with " + pProduct.ToString() + " product style.", now, false, oOpp);

                    oOpp.Update();

                    OpportunityProduct oProd = Act.UI.ActApplication.Instance.ActFramework.Products.OpportunityProductManager.CreateCustomEntity();
                    oProd.Name = pProduct.ToString();
                    oProd.Quantity = 1;
                    oProd.Cost = 0;
                    oProd.Price = 1;
                    oProd.Discount = 0;
                    oProd.SetOpportunities(Act.UI.ActApplication.Instance.ActFramework.Opportunities.GetOpportunityAsOpportunityList(oOpp));
                    oProd.Update();

                    MessageBox.Show("Need to update new Opportunity, Company and application data", "Additional Job", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    // Folder Checking Method
                    // Checks and creates missing folders based on the client type group

                    //Get current contact group
                    string ContactRecordType = c.Fields["TBL_CONTACT.INSTANTMSGID", true].ToString();
                    string clast = c.LastName;
                    string cfirst = c.FirstName;
                    string newpath1 = clast + ", " + cfirst + "/" + sName;
                    var instance = new DropBoxFolderCheker();
                    instance.cSort(ContactRecordType, newpath1);
                }

                if (MDAProdVal == "True")
                {
                    OpportunityStatus oStatus = OpportunityStatus.Open;
                    int iProbability = 50;
                    DateTime dEstCloseDate = System.DateTime.Now.AddDays(15);
                    Boolean bMakeItPrivate = false;
                    string sName = "" + PlatComp + " MDA-SMA Account";

                    ContactList cList = Act.UI.ActApplication.Instance.ActFramework.Contacts.GetContacts(null);
                    Contact cContact = cList[0];

                    Guid[] gArray = new Guid[1];
                    gArray[0] = c.ID;

                    //List out the note types
                    Act.Framework.Notes.NoteType[] noteTypes = Act.UI.ActApplication.Instance.ActFramework.Notes.GetNoteTypes();
                    DateTime now = DateTime.Now;

                    Stage[] sStages = Act.UI.ActApplication.Instance.ActFramework.StageManager.Processes[0].Stages;
                    Stage oStage = sStages[5];

                    ProductList pList = Act.UI.ActApplication.Instance.ActFramework.Products.GetProducts(null);
                    Product pProduct = pList[24];

                    string sReason = "A new MDA-SMA Account (ordinary money) with " + PlatComp + " has been finalised in the name " + c.FullName + " ";
                    DateTime dOpenDate = System.DateTime.Now; decimal curval1 = 0;

                    Opportunity oOpp = Act.UI.ActApplication.Instance.ActFramework.Opportunities.CreateOpportunity(sName, oStatus, oStage, dEstCloseDate, bMakeItPrivate);
                    oOpp.Probability = iProbability;
                    oOpp.User7 = "Investment";
                    oOpp.Competitor = PlatComp;
                    oOpp.Reason = sReason;
                    oOpp.UpdateContacts(gArray, null); oOpp.Update();
                    oOpp.Fields["TBL_OPPORTUNITY.CUST_AdviceSUM_050445029",  true] = curval1;
                    oOpp.Fields["TBL_OPPORTUNITY.CUST_AdvicePUM_050311460",  true] = curval1;
                    oOpp.Fields["TBL_OPPORTUNITY.CUST_AdviceFUM_050239770",  true] = curval1;
                    //Set a new Note
                    Act.UI.ActApplication.Instance.ActFramework.Notes.CreateNote(noteTypes[0], "New Opportunity created titled " + sName + "\n" + sReason + "\n\nThis is under the " + oOpp.User7 + " opportunity type with " + pProduct.ToString() + " product style.", now, false, oOpp);

                    oOpp.Update();

                    OpportunityProduct oProd = Act.UI.ActApplication.Instance.ActFramework.Products.OpportunityProductManager.CreateCustomEntity();
                    oProd.Name = pProduct.ToString();
                    oProd.Quantity = 1;
                    oProd.Cost = 0;
                    oProd.Price = 1;
                    oProd.Discount = 0;
                    oProd.SetOpportunities(Act.UI.ActApplication.Instance.ActFramework.Opportunities.GetOpportunityAsOpportunityList(oOpp));
                    oProd.Update();

                    MessageBox.Show("Need to update new Opportunity, Company and application data", "Additional Job", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    // Folder Checking Method
                    // Checks and creates missing folders based on the client type group

                    //Get current contact group
                    string ContactRecordType = c.Fields["TBL_CONTACT.INSTANTMSGID", true].ToString();
                    string clast = c.LastName;
                    string cfirst = c.FirstName;
                    string newpath1 = clast + ", " + cfirst + "/" + sName;
                    var instance = new DropBoxFolderCheker();
                    instance.cSort(ContactRecordType, newpath1);

                }
                if (DomaComProdVal == "True")
                {
                    OpportunityStatus oStatus = OpportunityStatus.Open;
                    int iProbability = 50;
                    DateTime dEstCloseDate = System.DateTime.Now.AddDays(15);
                    Boolean bMakeItPrivate = false;
                    string sName = "" + PlatComp + " Fractional Property Account";

                    ContactList cList = Act.UI.ActApplication.Instance.ActFramework.Contacts.GetContacts(null);
                    Contact cContact = cList[0];

                    Guid[] gArray = new Guid[1];
                    gArray[0] = c.ID;

                    //List out the note types
                    Act.Framework.Notes.NoteType[] noteTypes = Act.UI.ActApplication.Instance.ActFramework.Notes.GetNoteTypes();
                    DateTime now = DateTime.Now;

                    Stage[] sStages = Act.UI.ActApplication.Instance.ActFramework.StageManager.Processes[0].Stages;
                    Stage oStage = sStages[5];

                    ProductList pList = Act.UI.ActApplication.Instance.ActFramework.Products.GetProducts(null);
                    Product pProduct = pList[2];

                    string sReason = "A new Fractional Property Account with " + PlatComp + " has been finalised in the name " + c.FullName + " ";
                    DateTime dOpenDate = System.DateTime.Now; decimal curval1 = 0;

                    Opportunity oOpp = Act.UI.ActApplication.Instance.ActFramework.Opportunities.CreateOpportunity(sName, oStatus, oStage, dEstCloseDate, bMakeItPrivate);
                    oOpp.Probability = iProbability;
                    oOpp.User7 = "Investment";
                    oOpp.Competitor = PlatComp;
                    oOpp.Reason = sReason;
                    oOpp.UpdateContacts(gArray, null); oOpp.Update();
                    oOpp.Fields["TBL_OPPORTUNITY.CUST_AdviceSUM_050445029",  true] = curval1;
                    oOpp.Fields["TBL_OPPORTUNITY.CUST_AdvicePUM_050311460",  true] = curval1;
                    oOpp.Fields["TBL_OPPORTUNITY.CUST_AdviceFUM_050239770",  true] = curval1;
                    //Set a new Note
                    Act.UI.ActApplication.Instance.ActFramework.Notes.CreateNote(noteTypes[0], "New Opportunity created titled " + sName + "\n" + sReason + "\n\nThis is under the " + oOpp.User7 + " opportunity type with " + pProduct.ToString() + " product style.", now, false, oOpp);

                    oOpp.Update();

                    OpportunityProduct oProd = Act.UI.ActApplication.Instance.ActFramework.Products.OpportunityProductManager.CreateCustomEntity();
                    oProd.Name = pProduct.ToString();
                    oProd.Quantity = 1;
                    oProd.Cost = 0;
                    oProd.Price = 1;
                    oProd.Discount = 0;
                    oProd.SetOpportunities(Act.UI.ActApplication.Instance.ActFramework.Opportunities.GetOpportunityAsOpportunityList(oOpp));
                    oProd.Update();

                    MessageBox.Show("Need to update new Opportunity, Company and application data", "Additional Job", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    // Folder Checking Method
                    // Checks and creates missing folders based on the client type group

                    //Get current contact group
                    string ContactRecordType = c.Fields["TBL_CONTACT.INSTANTMSGID", true].ToString();
                    string clast = c.LastName;
                    string cfirst = c.FirstName;
                    string newpath1 = clast + ", " + cfirst + "/" + sName;
                    var instance = new DropBoxFolderCheker();
                    instance.cSort(ContactRecordType, newpath1);

                }

                if (MFundProdVal == "True")
                {
                    OpportunityStatus oStatus = OpportunityStatus.Open;
                    int iProbability = 50;
                    DateTime dEstCloseDate = System.DateTime.Now.AddDays(15);
                    Boolean bMakeItPrivate = false;
                    string sName = "" + PlatComp + " Managed Funds";

                    ContactList cList = Act.UI.ActApplication.Instance.ActFramework.Contacts.GetContacts(null);
                    Contact cContact = cList[0];

                    Guid[] gArray = new Guid[1];
                    gArray[0] = c.ID;

                    //List out the note types
                    Act.Framework.Notes.NoteType[] noteTypes = Act.UI.ActApplication.Instance.ActFramework.Notes.GetNoteTypes();
                    DateTime now = DateTime.Now;

                    Stage[] sStages = Act.UI.ActApplication.Instance.ActFramework.StageManager.Processes[0].Stages;
                    Stage oStage = sStages[5];

                    ProductList pList = Act.UI.ActApplication.Instance.ActFramework.Products.GetProducts(null);
                    Product pProduct = pList[30];

                    string sReason = "A new MFund with " + PlatComp + " has been finalised in the name " + c.FullName + " ";
                    DateTime dOpenDate = System.DateTime.Now; decimal curval1 = 0;

                    Opportunity oOpp = Act.UI.ActApplication.Instance.ActFramework.Opportunities.CreateOpportunity(sName, oStatus, oStage, dEstCloseDate, bMakeItPrivate);
                    oOpp.Probability = iProbability;
                    oOpp.User7 = "Investment";
                    oOpp.Competitor = PlatComp;
                    oOpp.Reason = sReason;
                    oOpp.UpdateContacts(gArray, null); oOpp.Update();
                    oOpp.Fields["TBL_OPPORTUNITY.CUST_AdviceSUM_050445029",  true] = curval1;
                    oOpp.Fields["TBL_OPPORTUNITY.CUST_AdvicePUM_050311460",  true] = curval1;
                    oOpp.Fields["TBL_OPPORTUNITY.CUST_AdviceFUM_050239770",  true] = curval1;
                    //Set a new Note
                    Act.UI.ActApplication.Instance.ActFramework.Notes.CreateNote(noteTypes[0], "New Opportunity created titled " + sName + "\n" + sReason + "\n\nThis is under the " + oOpp.User7 + " opportunity type with " + pProduct.ToString() + " product style.", now, false, oOpp);

                    oOpp.Update();

                    OpportunityProduct oProd = Act.UI.ActApplication.Instance.ActFramework.Products.OpportunityProductManager.CreateCustomEntity();
                    oProd.Name = pProduct.ToString();
                    oProd.Quantity = 1;
                    oProd.Cost = 0;
                    oProd.Price = 1;
                    oProd.Discount = 0;
                    oProd.SetOpportunities(Act.UI.ActApplication.Instance.ActFramework.Opportunities.GetOpportunityAsOpportunityList(oOpp));
                    oProd.Update();

                    MessageBox.Show("Need to update new Opportunity, Company and application data", "Additional Job", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    // Folder Checking Method
                    // Checks and creates missing folders based on the client type group

                    //Get current contact group
                    string ContactRecordType = c.Fields["TBL_CONTACT.INSTANTMSGID", true].ToString();
                    string clast = c.LastName;
                    string cfirst = c.FirstName;
                    string newpath1 = clast + ", " + cfirst + "/" + sName;
                    var instance = new DropBoxFolderCheker();
                    instance.cSort(ContactRecordType, newpath1);

                }

                c.Update();

                Act.UI.ActApplication.Instance.RefreshLoadedViews();
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message, "{0} Exception caught - Invest App Button");
            }

        }
    }

Jason Dawson Financial Planning
Brisbane | Australia - JDFP Home Page

Act Ver - Act! Premium Version 17.1.169.0, Hot Fix 3
OS - Windows 7 (stand alone machine)
MS Office - Enterprise 2007
Phone - Samsung Galaxy s6