Adding fields to ToDos  Topic is solved

Discussions relating to Jiwa 7 plugin development, and the Jiwa 7 API.

Adding fields to ToDos

Postby DannyC » Mon Feb 10, 2025 5:03 pm

I've had an interesting request from a client who wants to create ToDos based off debtor maintenance.
In these debtors are multiple contacts and multiple delivery addresses.

Any created ToDo will be associated with one contact and one delivery address.

When a ToDo is created, I want to give the user a combobox or Infragistics drop down similar to the Source record dropdown but could be visually like the Priority, don't really care. Just need to give them the options of choosing from a lookup.

I am thinking it would be best to create Custom Fields on the ToDos which are lookups?
Then copy the custom fields to the main tab?

Seem like the best option?

I think I should be able to find examples where custom fields have been copied to other maintenance form tabs.

Here's a mockup. Good ol' Paint.
Attachments
Debtor To Do.jpg
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: Adding fields to ToDos  Topic is solved

Postby SBarnes » Mon Feb 10, 2025 10:56 pm

Adding a lookup is done with code similar to this where a lookup was being added to the sales order form, in this case adding a second contact on the delivery tab, most of the code in the event handlers you can ignore its just there for completely showing the example, the trick is to work out which control on the form to add the control to and how to position it, the best option here is to use a decompiler on the form and look at a control that is close to where you want to position your control and work out what its parent is.

A lot of the below was worked out by simply looking at the Jiwa code in the form and replicating it onto the second control.

I doubt you can shorten up the subject box like in your mock up due to the setting the control may already have so you may have to place the two lookups side by side.


Code: Select all
            DeliveryContactNameEditableLookup = new EditableLookup();
            salesform.UltraPanel13.ClientArea.Controls.Add(DeliveryContactNameEditableLookup);
            //DeliveryContactNameEditableLookup.Location = new Point(lblContactName.Left + lblContactName.Width + 10, 38);
            DeliveryContactNameEditableLookup.Location = new Point(lblContactName.Left + lblContactName.Width + 10, salesform.DeliveryAddress1EditableLookup.Top);
            DeliveryContactNameEditableLookup.LookupEnabled = true;
            DeliveryContactNameEditableLookup.LookupVisible = true;
            DeliveryContactNameEditableLookup.Manager = null;
            DeliveryContactNameEditableLookup.Margin = new Padding(4);
            DeliveryContactNameEditableLookup.MinimumSize = new Size(20, 20);
            DeliveryContactNameEditableLookup.Name = "DeliveryContactNameEditableLookup2";
            DeliveryContactNameEditableLookup.Size = new Size(402, 21);
            DeliveryContactNameEditableLookup.TabIndex = 72;
            DeliveryContactNameEditableLookup.Text = null;
            DeliveryContactNameEditableLookup.UltraTextEditor.MaxLength = 50;
            DeliveryContactNameEditableLookup.TextChanged += new EventHandler(DeliveryContactNameEditableLookup_TextChanged);
            DeliveryContactNameEditableLookup.ButtonClicked += new EditableLookup.ButtonClickedEventHandler(DeliveryContactNameEditableLookup_ButtonClicked);
            salesform.UltraPanel13.Width = DeliveryContactNameEditableLookup.Left + DeliveryContactNameEditableLookup.Width + 10;


        private void DeliveryContactNameEditableLookup_TextChanged(object sender, EventArgs e)
        {
            if (settingValues)
            {
                return;
            }
            string histid = this.salesorder.SalesOrderHistorys[this.salesorder.SelectedHistoryNo].RecID;
            SOHistorySecondContact secon = secondcontacts.GetSecondContactForHistID(histid);
            secon.SalesOrderHistory = this.salesorder.SalesOrderHistorys[this.salesorder.SelectedHistoryNo];
            secon.Contact2Name = DeliveryContactNameEditableLookup.TextBox.Text;
            salesform.SetToolBar(true);
        }

private void DeliveryContactNameEditableLookup_ButtonClicked(object sender, EventArgs e)
        {
            try
            {
                settingValues = true;

                clsSearch search = this.manager.Search;
                search.Clear();
                search.FilterNo = 31019;
                search.CurrentOption = 1;
                search.Caption = "Debtor With Contacts";
                search.UsePinBoard = false;
                SearchOption searchOption = this.manager.CollectionItemFactory.CreateCollectionItem<SearchOption>();
                SearchOption searchOption1 = searchOption;
                string str = string.Concat("SELECT CN_Contact.ContactID, CN_Contact.Title, CN_Contact.FName, CN_Contact.SName, CN_Contact.Mobile", " FROM CN_Contact JOIN CN_Main ");
                str = string.Concat(str, " ON (CN_Main.ProspectID = CN_Contact.ProspectID) ");
                str = string.Concat(str, " WHERE CN_Main.DebtorID = ", this.manager.Database.FormatChar(this.salesorder.Debtor.DebtorID));
                searchOption1.Title = "Debtor With Contacts";
                searchOption1.SQLStr = str;
                searchOption1.OrderBy = "ORDER BY CN_Contact.FName";
                searchOption1.AddColumn("ID", VariantType.String, "", 0, 1, ".", 2, Column.DecimalPlacesTypes.HardCoded, false, ",", -1);
                searchOption1.AddColumn("Title", VariantType.String, "", 10, 2, ".", 2, Column.DecimalPlacesTypes.HardCoded, false, ",", -1);
                searchOption1.AddColumn("FName", VariantType.String, "", 30, 3, ".", 2, Column.DecimalPlacesTypes.HardCoded, false, ",", -1);
                searchOption1.AddColumn("SName", VariantType.String, "", 40, 4, ".", 2, Column.DecimalPlacesTypes.HardCoded, false, ",", -1);
                searchOption1.AddColumn("Mobile", VariantType.String, "", 20, 5, ".", 2, Column.DecimalPlacesTypes.HardCoded, false, ",", -1);
                this.manager.Search.AddSearchOption(ref searchOption);
                searchOption = null;
                clsSearch _clsSearch = this.manager.Search;
                if (_clsSearch.Show(this.salesform) == DialogResult.OK && _clsSearch.Results.Count != 0)
                {
                    string histid = this.salesorder.SalesOrderHistorys[this.salesorder.SelectedHistoryNo].RecID;
                    SOHistorySecondContact secon = secondcontacts.GetSecondContactForHistID(histid);
                    secon.SalesOrderHistory = this.salesorder.SalesOrderHistorys[this.salesorder.SelectedHistoryNo];
                    secon.Contact2Name = ((JiwaFinancials.Jiwa.JiwaApplication.JiwaSearch.Field)_clsSearch.get_Fields(3)).FieldValue.ToString() + " " + ((JiwaFinancials.Jiwa.JiwaApplication.JiwaSearch.Field)_clsSearch.get_Fields(4)).FieldValue.ToString();

                    secon.Mobile2 = ((JiwaFinancials.Jiwa.JiwaApplication.JiwaSearch.Field)_clsSearch.get_Fields(5)).FieldValue.ToString();
                    SetExtraControlValues(secon);
                    salesform.SetToolBar(true);
                }
                _clsSearch = null;

            }
            finally
            {
                settingValues = false;
            }
        }
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1696
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 191


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 4 guests