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:
Create a new C# Plugin called Demo FX Lookup on sales order

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.

Select the Code tab and double click on CustomFieldPlugin to expand the code block. Paste the following code into the ButtonClicked event:
if(CustomField.PluginCustomField.Name == "FX_Currency_RecID")
{
JiwaFinancials.Jiwa.JiwaApplication.Entities.ForeignExchange.Currency currency = BusinessLogicHost.Manager.EntityFactory.CreateEntity<JiwaFinancials.Jiwa.JiwaApplication.Entities.ForeignExchange.Currency>();
currency.Search(FormObject.Form);
CustomFieldValue.DisplayContents = currency.ShortName;
CustomFieldValue.Contents = currency.RecID;
} |
|
If CustomField.PluginCustomField.Name = "FX_Currency_RecID" Then
Dim currency As JiwaFinancials.Jiwa.JiwaApplication.Entities.ForeignExchange.Currency = BusinessLogicHost.Manager.EntityFactory.CreateEntity(Of JiwaFinancials.Jiwa.JiwaApplication.Entities.ForeignExchange.Currency)()
currency.Search(FormObject.Form)
CustomFieldValue.DisplayContents = currency.ShortName
CustomFieldValue.Contents = currency.RecID
End If |
|
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.
Paste the following code into the ReadData event:
if(CustomField.PluginCustomField.Name == "FX_Currency_RecID")
{
if(string.IsNullOrWhiteSpace(CustomFieldValue.Contents) == false)
{
JiwaFinancials.Jiwa.JiwaApplication.Entities.ForeignExchange.Currency currency = BusinessLogicHost.Manager.EntityFactory.CreateEntity<JiwaFinancials.Jiwa.JiwaApplication.Entities.ForeignExchange.Currency>();
try
{
currency.ReadRecord(CustomFieldValue.Contents);
CustomFieldValue.DisplayContents = currency.ShortName;
} catch (System.Exception ex)
{
CustomFieldValue.DisplayContents = "";
}
}
else
{
CustomFieldValue.DisplayContents = "";
}
} |
|
If CustomField.PluginCustomField.Name = "FX_Currency_RecID" Then
If String.IsNullOrWhiteSpace(CustomFieldValue.Contents) = False Then
Dim currency As JiwaFinancials.Jiwa.JiwaApplication.Entities.ForeignExchange.Currency = BusinessLogicHost.Manager.EntityFactory.CreateEntity(Of JiwaFinancials.Jiwa.JiwaApplication.Entities.ForeignExchange.Currency)()
Try
currency.ReadRecord(CustomFieldValue.Contents)
CustomFieldValue.DisplayContents = currency.ShortName
Catch ex As System.Exception
CustomFieldValue.DisplayContents = ""
End Try
Else
CustomFieldValue.DisplayContents = ""
End If
End If |
|
Note that the "FX_Currency_RecID" in the first line is the same as the custom column created in this plugin.
Press
and you should receive a success message
Check the
checkbox
Save the plugin
Exit Jiwa and re-open
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