Custom field event  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Custom field event

Postby Riyaz » Mon Apr 16, 2018 11:20 am

Hi

I need to have an change event attached to a specific custom field which gets added the Custom Fields tab under PO , basically what am after is that, if the value is chosen / changed on this particular custom field, I'll need to change a specific value on all the line items of the Order tab. Pls advise the possibilities
Riyaz
Kohai
Kohai
 
Posts: 233
Joined: Wed Dec 02, 2015 2:05 pm
Topics Solved: 2

Re: Custom field event  Topic is solved

Postby SBarnes » Tue Apr 17, 2018 8:11 pm

Hi Riyaz,

Attached is rough example using a sales order of what you need to do which should translate onto a purchase order fairly easily as both have a generic object collection so that you can look for where values change.
Attachments
Plugin Custom Value Change Test.xml
(32.82 KiB) Downloaded 91 times
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Custom field event

Postby Mike.Sheen » Wed Apr 18, 2018 12:35 pm

Hi Riyaz,

I'm not sure if Sbarnes solution suits or not - I interpreted the question a little differently.

The attached plugin demonstrates how to detect when a custom field on the purchase order changes, and how to iterate all lines on the purchase order and set a property of each line (in this example I simply set the description of each line to be the value of the custom field).

The code itself is all in the BusinessLogicPlugin class:

Code: Select all
public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaBusinessLogic JiwaBusinessLogic, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
{
   JiwaFinancials.Jiwa.JiwaPurchaseOrders.PurchaseOrder purchaseOrder = (JiwaFinancials.Jiwa.JiwaPurchaseOrders.PurchaseOrder)JiwaBusinessLogic;
   purchaseOrder.CustomFieldValues.Changed += PurchaseOrder_CustomFieldValue_Changed;
}

public void PurchaseOrder_CustomFieldValue_Changed(JiwaFinancials.Jiwa.JiwaApplication.CustomFields.CustomFieldValue item, System.ComponentModel.PropertyChangedEventArgs e)
{
   if (item.CustomField.PluginCustomField.Name == "TestCustomField")
   {
      JiwaFinancials.Jiwa.JiwaPurchaseOrders.PurchaseOrder purchaseOrder = (JiwaFinancials.Jiwa.JiwaPurchaseOrders.PurchaseOrder)item.CustomFieldValueCollection.CustomFieldCollection.BusinessLogic;
      
      foreach (JiwaFinancials.Jiwa.JiwaPurchaseOrders.Line poLine in purchaseOrder.Lines)
      {
         // Demonstrate setting a property of the purchase order line
         poLine.Description = item.Contents;
      }
   }
}


The plugin provided targets 07.01.00 - but if you need it for an earlier version it should work fine as well.
Attachments
Plugin PO Custom Field Change.xml
(30.51 KiB) Downloaded 93 times
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: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Custom field event

Postby Riyaz » Wed Apr 18, 2018 5:12 pm

Thanks both Stuart and Mike for this, I appreciate it
Riyaz
Kohai
Kohai
 
Posts: 233
Joined: Wed Dec 02, 2015 2:05 pm
Topics Solved: 2


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 12 guests