Batch Print/Email. Set the default setting not Ad Hoc  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Batch Print/Email. Set the default setting not Ad Hoc

Postby DannyC » Tue Apr 12, 2022 4:24 pm

I don't want the Batch Emailing/Printing form to display "Ad-Hoc" as the default setting.
I want it to default to one of the settings I have.

I've got this code but it's giving me an error as if SettingCollection isn't a collection. "JiwaFinancials.Jiwa.JiwaSales.BatchPrinting.SettingCollection is a type which is not valid in the given context."

Code: Select all
    public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
    {
      if (JiwaForm is JiwaFinancials.Jiwa.JiwaSalesUI.BatchPrinting.MainForm)
      {
         JiwaFinancials.Jiwa.JiwaSalesUI.BatchPrinting.MainForm batchEmail = (JiwaFinancials.Jiwa.JiwaSalesUI.BatchPrinting.MainForm)JiwaForm;
         foreach (JiwaFinancials.Jiwa.JiwaSales.BatchPrinting.Setting mySetting in JiwaFinancials.Jiwa.JiwaSales.BatchPrinting.SettingCollection)
         {
            if (mySetting.Name == "Email Invoices for Customer for a given Date Range")
            {
               batchEmail.BatchPrint.CurrentSettings.Settings.Read(mySetting.RecID);
            }
         }
      }
    }


How can I default the batchprint to a different default?
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Batch Print/Email. Set the default setting not Ad Hoc

Postby SBarnes » Tue Apr 12, 2022 5:22 pm

You can't use in the foreach the statement JiwaFinancials.Jiwa.JiwaSales.BatchPrinting.SettingCollection that is the type you need a variable/property in other words an instance of the type.

The forums doesn't have a compiler but I'm pretty sure the below is what it should be.

Code: Select all
public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
    {
      if (JiwaForm is JiwaFinancials.Jiwa.JiwaSalesUI.BatchPrinting.MainForm)
      {
         JiwaFinancials.Jiwa.JiwaSalesUI.BatchPrinting.MainForm batchEmail = (JiwaFinancials.Jiwa.JiwaSalesUI.BatchPrinting.MainForm)JiwaForm;
         foreach (JiwaFinancials.Jiwa.JiwaSales.BatchPrinting.Setting mySetting in batchEmail.BatchPrint.Settings)
         {
            if (mySetting.Name == "Email Invoices for Customer for a given Date Range")
            {
               batchEmail.BatchPrint.CurrentSettings.Settings.Read(mySetting.RecID);
            }
         }
      }
    }

Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Batch Print/Email. Set the default setting not Ad Hoc

Postby DannyC » Tue Apr 12, 2022 5:35 pm

Thanks Stuart.
That fixes the error but it is still defaulting to Ad-Hoc.
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Batch Print/Email. Set the default setting not Ad Hoc

Postby SBarnes » Tue Apr 12, 2022 5:39 pm

That's probably because the ui is setting it on the combo itself, you may need to override it through the control when the form is shown.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Batch Print/Email. Set the default setting not Ad Hoc  Topic is solved

Postby SBarnes » Tue Apr 12, 2022 6:58 pm

Yeah I was right, SetupSettingsFrame does it in the form shown below which is called from SetupControls which is called from SetupForm which is called from Setup, so if you can get in behind that code being called i.e. behind Jiwa setup you should just need to set the combobox called SettingsUltraComboEditor and given the form is setup before a plugin gets called it should be as simple as doing it there in the form plugin setup.

So just work out which one on the combo items in list is your setting and set the select item index accordingly. By the way the items in the combo are of type Infragistics.Win.ValueListItem and the datavalue will be the setting just cast it back from an object if you need it and the displaytext will be what the combo is showing which is what you are looking for anyway in your previous code.


Code: Select all
      private void SetupSettingsFrame()
        {
            IEnumerator enumerator = null;
            bool flag = this._IsDisplaying;
            try
            {
                this._IsDisplaying = true;
                this.SettingsUltraComboEditor.DropDownStyle = DropDownStyle.DropDownList;
                string str = "";
                object obj = str;
                this.Manager.JLib.GetProfileKey(this.Manager.Database.JiwaLoginUserID, string.Concat("BatchPrintUI.", base.Name), "Settings", ref obj);
                str = Conversions.ToString(obj);
                int count = -1;
                try
                {
                    enumerator = this.BatchPrint.Settings.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        Setting current = (Setting)enumerator.Current;
                        this.SettingsUltraComboEditor.Items.Add(current, current.Name);
                        if (Operators.CompareString(current.Name.Trim(), str.Trim(), false) != 0)
                        {
                            continue;
                        }
                        count = checked(this.SettingsUltraComboEditor.Items.Count - 1);
                    }
                }
                finally
                {
                    if (enumerator is IDisposable)
                    {
                        (enumerator as IDisposable).Dispose();
                    }
                }
                if (count != -1)
                {
                    this.SettingsUltraComboEditor.SelectedIndex = count;
                }
                else if (this.SettingsUltraComboEditor.Items.Count <= 0)
                {
                    this.SettingsUltraComboEditor.SelectedIndex = 0;
                }
                else
                {
                    this.SettingsUltraComboEditor.SelectedIndex = checked(this.SettingsUltraComboEditor.Items.Count - 1);
                }
            }
            finally
            {
                this._IsDisplaying = flag;
            }
        }
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Batch Print/Email. Set the default setting not Ad Hoc

Postby DannyC » Wed Apr 13, 2022 11:20 am

Righto, here's the solution:

Code: Select all
    public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
    {
       if (JiwaForm is JiwaFinancials.Jiwa.JiwaSalesUI.BatchPrinting.MainForm)
       {
           JiwaFinancials.Jiwa.JiwaSalesUI.BatchPrinting.MainForm batchEmailForm = (JiwaFinancials.Jiwa.JiwaSalesUI.BatchPrinting.MainForm)JiwaForm;
         int i = 0;
           foreach (JiwaFinancials.Jiwa.JiwaSales.BatchPrinting.Setting mySetting in batchEmailForm.BatchPrint.Settings)
           {
               if (mySetting.Name == "Email Invoices for Customer for a given Date Range")
               {
               batchEmailForm.SettingsUltraComboEditor.SelectedIndex = i;
               }
            i++;
           }
       }
   }
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 8 guests