Page 1 of 1

Issue Extending Debtor Import Screen

PostPosted: Mon Mar 29, 2021 3:30 pm
by SBarnes
Following how you extend the inventory import screen I have attempted to extend the debtor import screen, but I am running into a problem, when the business object is created I add my extra destination property and the following two lines of code fire to give me the answer of 105

Code: Select all
         JiwaFinancials.Jiwa.JiwaDebtors.Import.DebtorImport DebtorImportObject = (JiwaFinancials.Jiwa.JiwaDebtors.Import.DebtorImport)JiwaBusinessLogic;
      
         System.Windows.Forms.MessageBox.Show(DebtorImportObject.DestinationProperties.Count.ToString());


However when I then look at the list after I read in the csv it wasn't there so I added the following to the form plugin and both message boxes give an answer of 104, so something is clear different between the two forms where something is changing the object, but I have no idea what, I am attaching to the read end just as with the inventory to cover off if the property needs adding again, any idea what could be causing the difference?

Code: Select all
public class FormPlugin : System.MarshalByRefObject, JiwaFinancials.Jiwa.JiwaApplication.IJiwaFormPlugin
{
   public static JiwaFinancials.Jiwa.JiwaDebtorsUI.Import.MainForm dform;

    public override object InitializeLifetimeService()
    {
        // returning null here will prevent the lease manager
        // from deleting the Object.
        return null;
    }

    public void SetupBeforeHandlers(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
    {
      dform = ( JiwaFinancials.Jiwa.JiwaDebtorsUI.Import.MainForm )JiwaForm;
      dform.BrowseUltraButton.Click += BeforeButtonClick;
    }

    public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
    {
      dform.BrowseUltraButton.Click += AfterButtonClick;
    }
   
   
   public void BeforeButtonClick(object sender, EventArgs e)
   {
      System.Windows.Forms.MessageBox.Show(dform.DebtorImportObject.DestinationProperties.Count.ToString());
      
   }
   
   public void AfterButtonClick(object sender, EventArgs e)
   {
      System.Windows.Forms.MessageBox.Show(dform.DebtorImportObject.DestinationProperties.Count.ToString());
      
   }   
   
}

Re: Issue Extending Debtor Import Screen

PostPosted: Mon Mar 29, 2021 3:39 pm
by Scott.Pearce
Can you provide the plugin for us to step through?

Re: Issue Extending Debtor Import Screen

PostPosted: Mon Mar 29, 2021 4:06 pm
by SBarnes
Hi Scott,

Attached is a sample that demonstrates the issue, it's not the original plugin as that has a mammoth amount of code in it, but this has the same problem and demonstrates the issue.

Re: Issue Extending Debtor Import Screen  Topic is solved

PostPosted: Mon Mar 29, 2021 4:10 pm
by Mike.Sheen
Logged as DEV-8675.

It's caused by the form incorrectly invoking the Setup() method of the business logic AFTER the being created by the factory - that call to setup should be removed because the factory calls that, and then calls any interested plugin setup methods - calling Setup() after the plugins are invoked effectively resets all the collections, including the DestinationPropertyCollection.

I'll see if I can work out how you can work around this and post back here.

Re: Issue Extending Debtor Import Screen

PostPosted: Mon Mar 29, 2021 4:13 pm
by SBarnes
I think I have a work around based upon what I just posted why not append the properties in the button click that fires from setup before on the form?

Unless you have a neater answer.

Re: Issue Extending Debtor Import Screen

PostPosted: Mon Mar 29, 2021 4:16 pm
by Scott.Pearce
Yeah that should work. I'd do it in form Setup of the plugin.

Re: Issue Extending Debtor Import Screen

PostPosted: Mon Mar 29, 2021 4:57 pm
by SBarnes
Ok this gets weirder I can now get it to correctly hold the extra setting in the attached version but it is not finding the match on Extra for the attached csv

Re: Issue Extending Debtor Import Screen

PostPosted: Tue Mar 30, 2021 8:56 am
by SBarnes
So this wasn't as simple as originally thought, not only do you need to add the destination properties at a different point but you also need to fix the dropdown list in the mappings grid with a function like the below, not sure if this will be relevant to the bug fix, and I have reattached the final plugin.


Code: Select all
   private void FixMappingList ( JiwaFinancials.Jiwa.JiwaDebtors.Import.DebtorImport debtorImport )
   {
      JiwaFinancials.Jiwa.JiwaDebtorsUI.Import.MainForm dform = ( JiwaFinancials.Jiwa.JiwaDebtorsUI.Import.MainForm )debtorImport.Client;
      JiwaFinancials.Jiwa.JiwaApplication.Controls.JiwaGrid   mappingsJiwaGrid = dform.MappingsJiwaGrid;
        List<string> strs = new List<string>();
        List<string> strs1 = new List<string>();      
      foreach( JiwaFinancials.Jiwa.JiwaDebtors.Import.DestinationProperty property in debtorImport.DestinationProperties)
      {
   
            strs1.Add(property.RecID);
            strs.Add(property.Caption);         
      }
        ((ComboBoxCellType)mappingsJiwaGrid.ActiveSheet.Columns["DestinationPropertyDisplayName"].CellType).Items = strs.ToArray();
        ((ComboBoxCellType)mappingsJiwaGrid.ActiveSheet.Columns["DestinationPropertyDisplayName"].CellType).ItemData = strs1.ToArray();
        mappingsJiwaGrid.SetupComplete();      
   }