Page 1 of 1

Jiwa 8, search windows and getting col values

PostPosted: Tue May 12, 2026 9:51 am
by DannyC
In the Upgrade Guidance For Plugin Developers moving from Jiwa 7 to Jiwa 8, is this
Invoking a Search Window
The previous method of invoking a search window will still function, but users will benefit from changing to the more extensible and simpler search.

A pre-defined search
You can invoke the search for existing pre-defined searches as follows:

string id = null;
using (JiwaFinancials.Jiwa.JiwaApplication.JiwaSearchAsync.SearchForm searchDialog = JiwaFinancials.Jiwa.JiwaApplication.JiwaSearchAsync.Factory.CreateSearchForm(this, OwnerForm, OwnerForm.GetType().ToString(), "Inventory Item"))
{
if (searchDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
id = searchDialog.Results[0];
}
}


All OK but it returns (in this example) the InventoryID. How can I get the value from other columns like PartNo for example?
I've tried searchDialog.Results[1] but I get an index out of range error.

Re: Jiwa 8, search windows and getting col values  Topic is solved

PostPosted: Tue May 12, 2026 10:34 am
by Mike.Sheen
DannyC wrote:How can I get the value from other columns like PartNo for example?


ThatsTheNeatPart.png


We don't provide a clean way to do that - in theory it's possible, but you'd need to consider when the multi-select grid is present also.

In cases where we want more than the Id from a search, we create the corresponding entity, and read the item using the Id. But in reality, we usually only ever want the Id - for instance when selecting an inventory item to add to a Purchase Order, Sales Order, or anything - the business logic wants us to provide the Id, and that's all - so we never have a need for more than that, and so that is why the search was designed this way.

Re: Jiwa 8, search windows and getting col values

PostPosted: Tue May 12, 2026 11:56 am
by DannyC
In cases where we want more than the Id from a search, we create the corresponding entity


I see, makes sense. Only a couple of lines of code, all good.

Re: Jiwa 8, search windows and getting col values

PostPosted: Tue May 12, 2026 2:38 pm
by DannyC
What I am doing is configuring a sales order line custom field, as a lookup type.
It's purpose is to associate this line with another inventory item.

In the BottonClicked code block, I've got
Code: Select all
public void ButtonClicked(JiwaFinancials.Jiwa.JiwaApplication.IJiwaBusinessLogic BusinessLogicHost, JiwaFinancials.Jiwa.JiwaApplication.Controls.JiwaGrid GridObject, JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm FormObject, int Col, int Row, JiwaFinancials.Jiwa.JiwaApplication.IJiwaLineCustomFieldValues HostItem, JiwaFinancials.Jiwa.JiwaApplication.CustomFields.CustomField CustomField, JiwaFinancials.Jiwa.JiwaApplication.CustomFields.CustomFieldValue CustomFieldValue)      
{
   if (CustomField.PluginCustomField.Name == "Item1")
   {
      string id = null;
      using (JiwaFinancials.Jiwa.JiwaApplication.JiwaSearchAsync.SearchForm searchDialog = JiwaFinancials.Jiwa.JiwaApplication.JiwaSearchAsync.Factory.CreateSearchForm(BusinessLogicHost.Manager, FormObject.Form, FormObject.GetType().ToString(), "Inventory Item"))
      {
         if (searchDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
            id = searchDialog.Results[0];
            JiwaFinancials.Jiwa.JiwaApplication.Entities.Inventory.Inventory inventory = BusinessLogicHost.Manager.EntityFactory.CreateEntity<JiwaFinancials.Jiwa.JiwaApplication.Entities.Inventory.Inventory>();
            inventory.ReadRecord(id);
            CustomFieldValue.Contents = inventory.PartNo;
            CustomFieldValue.DisplayContents = inventory.PartNo;
         }
      }                  
   }   
}


All works well, the PartNo is saved to the database. But when I select my partNo the grid doesn't show my value until I save, i.e. the sales order is re-read.
I have
Code: Select all
CustomFieldValue.DisplayContents = inventory.PartNo;

but wonder if there's another line I need to add for Jiwa 8 to get the PartNo to display on the lines grid?

Re: Jiwa 8, search windows and getting col values

PostPosted: Tue May 12, 2026 2:46 pm
by Mike.Sheen
DannyC wrote:But when I select my partNo the grid doesn't show my value until I save, i.e. the sales order is re-read.
I have
Code: Select all
CustomFieldValue.DisplayContents = inventory.PartNo;

but wonder if there's another line I need to add for Jiwa 8 to get the PartNo to display on the lines grid?


Try setting the Contents after setting the DisplayContents. The setting of the DisplayContents will silently set the property and not raise an event signalling a change, whereas setting the Contents does raise an event and the form will respond and re-display the entire line.

Alternatively you could invoke CustomFieldValue.NotifyPropertyChanged() after setting the DisplayContents and it will cause the event to fire and cause a re-display.

Re: Jiwa 8, search windows and getting col values

PostPosted: Tue May 12, 2026 3:00 pm
by DannyC
Try setting the Contents after setting the DisplayContents


Bingo! No need for the NotifyPropertyChanged().

Appreciate the tip, thx.