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

Discussions relating to Jiwa 8 plugin development, and the Jiwa 8 API.

Jiwa 8, search windows and getting col values

Postby DannyC » Tue May 12, 2026 9:51 am

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.
User avatar
DannyC
Senpai
Senpai
 
Posts: 729
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 32

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

Postby Mike.Sheen » Tue May 12, 2026 10:34 am

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.
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: 2589
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 816

Re: Jiwa 8, search windows and getting col values

Postby DannyC » Tue May 12, 2026 11:56 am

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.
User avatar
DannyC
Senpai
Senpai
 
Posts: 729
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 32

Re: Jiwa 8, search windows and getting col values

Postby DannyC » Tue May 12, 2026 2:38 pm

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?
User avatar
DannyC
Senpai
Senpai
 
Posts: 729
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 32

Re: Jiwa 8, search windows and getting col values

Postby Mike.Sheen » Tue May 12, 2026 2:46 pm

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.
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: 2589
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 816

Re: Jiwa 8, search windows and getting col values

Postby DannyC » Tue May 12, 2026 3:00 pm

Try setting the Contents after setting the DisplayContents


Bingo! No need for the NotifyPropertyChanged().

Appreciate the tip, thx.
User avatar
DannyC
Senpai
Senpai
 
Posts: 729
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 32


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 1 guest