PO Shipping Address Spare Fields  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

PO Shipping Address Spare Fields

Postby pricerc » Wed Nov 20, 2019 12:17 pm

So after reading https://forums.jiwa.com.au/viewtopic.php?f=26&t=375&hilit=shipping+address I put some similar code in my form.

Except then it doesn't populate.

So I take a look at ILSpy, and see this:
Code: Select all
public void DisplayShippingAddress()
{
   JiwaGrid shippingAddressJiwaGrid = ShippingAddressJiwaGrid;
   checked
   {
      int num = ShippingAddressJiwaGrid.ActiveSheet.RowCount - 1;
      for (int i = 0; i <= num; i++)
      {
string text = Conversions.ToString(shippingAddressJiwaGrid.get_GridText("Field", i));
         switch (<PrivateImplementationDetails>.ComputeStringHash(text))
         {
....
         case 2959222051u:
            if (Operators.CompareString(text, "Spare1", TextCompare: false) == 0)
            {
               shippingAddressJiwaGrid.set_GridText("Value", i, (object)_PurchaseOrder.ShippingAddress.Spare1);
            }
            break;
...
      }
      shippingAddressJiwaGrid = null;
   }
}



this suggests to me that if the text in the "Field" column isn't "Spare1", then it's not going to get the Spare1 value out of the ShippingAddress.

Any other suggestions?
Last edited by pricerc on Wed Nov 20, 2019 12:36 pm, edited 1 time in total.
/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
User avatar
pricerc
Jiwa Kohai
Jiwa Kohai
 
Posts: 230
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 6

Re: PO Shipping Address Spare Fields  Topic is solved

Postby pricerc » Wed Nov 20, 2019 12:33 pm

To answer my own question....


this works, but it is a bit clunky:

Code: Select all
       Private Sub PurchaseOrderForm_ReadEnd(sender As Object, e As EventArgs)
            Dim purchaseOrder = TryCast(sender, PurchaseOrder)
            If purchaseOrder Is Nothing Then Return

            Dim purchaseOrderForm As MainForm = TryCast(purchaseOrder.Client, MainForm)
            If purchaseOrderForm Is Nothing Then Return

'...
            purchaseOrderForm.ShippingAddressJiwaGrid.GridText("Value", 9) = purchaseOrder.ShippingAddress.Spare1
        End Sub

/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
User avatar
pricerc
Jiwa Kohai
Jiwa Kohai
 
Posts: 230
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 6

Re: PO Shipping Address Spare Fields

Postby Scott.Pearce » Wed Nov 20, 2019 12:36 pm

You are correct.

To work around this you could add handlers for these events:

PurchaseOrder.Read
PurchaseOrder.Created
PurchaseOrder.PropertyChanged (e.PropertyName == "ShippingAddress")
PurchaseOrder.Deserialized
PurchaseOrder.CopyEnd

The handlers should then call a function you write called DisplaySpareShippingAddressFields, and could look something like this:

Code: Select all
public void DisplaySpareShippingAddressFields(JiwaFinancials.Jiwa.JIwaApplication.Controls.JiwaGrid ShippingAddressGrid, JiwaFinancials.Jiwa.JiwaPurchaseOrder.PurchaseOrders PurchaseOrder)
{
    ShippingAddressGrid.GridText("Value", 9) = PurchaseOrder.ShippingAddress.Spare1;
}
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Jiwa Senpai
Jiwa Senpai
 
Posts: 578
Joined: Tue Feb 12, 2008 11:27 am
Location: North Sydney, New South Wales
Topics Solved: 172


Return to Technical / Programming

Who is online

Users browsing this forum: No registered users and 8 guests

cron