/
Custom Lookup Field

Custom Lookup Field

For a custom lookup style column FX_Currency_RecID (for example on the Sales Order form).

The field will be populated by clicking the lookup button and selecting from currencies on the existing FX_Currency table. The existing form under System Settings > Foreign Exchange > Currencies will be used to maintain the list of foreign currencies for the sales order form.

The end result will look like this on the sales order form:

To create the lookup column, complete the following steps:

  1. Create a new C# Plugin called Demo FX Lookup on sales order





  2. Select custom fields tab and select Sales order row under the Modules grid. In the fields grid, enter the Name as  FX_Currency_RecID and choose cell type of Lookup. Press Save.





  3.  Select the Code tab and double click on CustomFieldPlugin to expand the code block.  Paste the following code into the ButtonClicked event:


    ButtonClicked event

    if (CustomField.PluginCustomField.Name == "FX_Currency_RecID") { var Currency = new JiwaFinancials.Jiwa.JiwaApplication.Entities.ForeignExchange.Currency(); Currency.Search(FormObject.Form); CustomFieldValue.DisplayContents = Currency.ShortName; CustomFieldValue.Contents = Currency.RecID; }


    Note that after JiwaFinancials.Jiwa.JiwaApplication.Entities.<select any existing Jiwa entity>    it is possible to refer to other Jiwa entities instead of Foreign Exchange.  In this example we are using the ForeignExchange.Currency entity.


  4. Paste the following code into the ReadData event:


    ReadData event

    if (CustomField.PluginCustomField.Name == "FX_Currency_RecID") { if (CustomFieldValue.Contents != null && CustomFieldValue.Contents.Trim().Length > 0) { var Currency = new JiwaFinancials.Jiwa.JiwaApplication.Entities.ForeignExchange.Currency(); try { Currency.ReadRecord(CustomFieldValue.Contents); CustomFieldValue.DisplayContents = Currency.ShortName; } catch (System.Exception ex) { CustomFieldValue.DisplayContents = ""; } } else { CustomFieldValue.DisplayContents = ""; } }


    Note that the "FX_Currency_RecID" in the first line is the same as the custom column created in this plugin. 


  5. Press  and you should receive a success message

  6. Check the checkbox

  7. Save the plugin

  8. Exit Jiwa and re-open

  9. Test the plugin by creating a new sales order and selecting a currency in the Custom tab > This Sales Order tab > FX_Currency_RecID lookup 

 

 

 

 

 

 

Related content

Creating a new Jiwa database where Australian Dollar is not the local currencies sets both as Local
Creating a new Jiwa database where Australian Dollar is not the local currencies sets both as Local
More like this
Creating custom fields via a plugin
Creating custom fields via a plugin
More like this
Change a column name
Change a column name
More like this
Plugin to prevent 0.00 FX Amount transactions being saved where Amount > 0.00 - 7.00.175 only
Plugin to prevent 0.00 FX Amount transactions being saved where Amount > 0.00 - 7.00.175 only
More like this
Jiwa 7.01.00.00
Jiwa 7.01.00.00
More like this
Sales Order and Quote User 1 to 3 fields appear to be set to Integer rather than Float
Sales Order and Quote User 1 to 3 fields appear to be set to Integer rather than Float
More like this