...
- 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:
Code Block title 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.Paste the following code into the ReadData event:
Code Block title 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) { // pivot no longer exists, just blank it out. 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.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
...