Issue Extending Debtor Import Screen  Topic is solved

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

Issue Extending Debtor Import Screen

Postby SBarnes » Mon Mar 29, 2021 3:30 pm

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());
      
   }   
   
}
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1696
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 191

Re: Issue Extending Debtor Import Screen

Postby Scott.Pearce » Mon Mar 29, 2021 3:39 pm

Can you provide the plugin for us to step through?
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 765
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 230

Re: Issue Extending Debtor Import Screen

Postby SBarnes » Mon Mar 29, 2021 4:06 pm

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.
Attachments
Plugin Debtor Import Sample.xml
(40.7 KiB) Downloaded 776 times
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1696
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 191

Re: Issue Extending Debtor Import Screen  Topic is solved

Postby Mike.Sheen » Mon Mar 29, 2021 4:10 pm

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.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: Issue Extending Debtor Import Screen

Postby SBarnes » Mon Mar 29, 2021 4:13 pm

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.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1696
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 191

Re: Issue Extending Debtor Import Screen

Postby Scott.Pearce » Mon Mar 29, 2021 4:16 pm

Yeah that should work. I'd do it in form Setup of the plugin.
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 765
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 230

Re: Issue Extending Debtor Import Screen

Postby SBarnes » Mon Mar 29, 2021 4:57 pm

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
Attachments
dmimporttestdebtor.csv
(77 Bytes) Downloaded 1042 times
Plugin Debtor Import Sample.xml
(45.15 KiB) Downloaded 750 times
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1696
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 191

Re: Issue Extending Debtor Import Screen

Postby SBarnes » Tue Mar 30, 2021 8:56 am

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();      
   }
Attachments
Plugin Debtor Import Sample.xml
(46.21 KiB) Downloaded 898 times
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 2 guests