Page 1 of 1

Inventory Category Custom Field Lookup

PostPosted: Mon May 25, 2020 7:01 pm
by SBarnes
I am trying to add a lookup custom field to inventory Categories 2 and 3 but can not get the button click event to fire.

I have already done the following:

1. Under form references added Inventory Categories
2. Under business login references added the following
Inventory Categories
Inventory Category Configuration 1
Inventory Category Configuration 2
Inventory Category Configuration 3

what am I doing wrong as in the button click I can't even get a message box to show, let alone the search window?

This is in 7.2.1

There is also a bug where on the custom field if you hit the look up button on the custom field on last row where no data is entered you get a null reference exception.

Re: Inventory Category Custom Field Lookup

PostPosted: Tue May 26, 2020 11:02 am
by SBarnes
OK so I've worked out the issue here in Jiwa for inventory categories, they are custom line fields not custom fields

Re: Inventory Category Custom Field Lookup

PostPosted: Tue May 26, 2020 11:46 am
by Scott.Pearce
I suspected as much.

I've attached a plugin which also locks the last row lookup button. I had to jump through some hoops to achieve this. I'll log a bug to have the native code corrected and will post the bug no. back here.

Plugin Add lookup to Inventory Category 2.xml
(35.65 KiB) Downloaded 51 times

Re: Inventory Category Custom Field Lookup

PostPosted: Tue May 26, 2020 11:49 am
by SBarnes
Thanks Scott

Re: Inventory Category Custom Field Lookup

PostPosted: Tue May 26, 2020 11:52 am
by Scott.Pearce
Also logged as DEV-8248

Re: Inventory Category Custom Field Lookup

PostPosted: Tue May 26, 2020 3:34 pm
by SBarnes
Hi Scott

I've largely gotten setting the values to work with 1 minor glitch when the search window comes down the grid display value is not updating, I know the correct value is going in because if you hit save it appears and I've checked with VS, below is the code any idea on how to get around this issue

Code: Select all
            if (search.Results.Count > 0)
            {                  
               var idField = (JiwaFinancials.Jiwa.JiwaApplication.JiwaSearch.Field)search.get_Fields(1);
               CustomFieldValue.Contents = idField.FieldValue.ToString();
               
               var DescriptionField = (JiwaFinancials.Jiwa.JiwaApplication.JiwaSearch.Field)search.get_Fields(2);
               
               CustomFieldValue.DisplayContents =  DescriptionField.FieldValue.ToString();
               GridObject.set_GridText(Col, Row,CustomFieldValue.DisplayContents);
               GridObject.Refresh();
            }

Re: Inventory Category Custom Field Lookup

PostPosted: Tue May 26, 2020 3:39 pm
by SBarnes
My Bad take 1 off the column value and it works

Re: Inventory Category Custom Field Lookup

PostPosted: Tue May 26, 2020 3:58 pm
by Scott.Pearce
Push the display data into .DisplayContents, and push the id value into .Contents. In the ReadData() function, you place code that resolves .Contents to .DisplayContents (ie. an ID to a Description). I've updated the plugin to show this.

Plugin Add lookup to Inventory Category 2.xml
(36.46 KiB) Downloaded 53 times


Edit: Setting .Contents will cause the appropriate row to re-display for you, so set .DisplayContents, THEN set .Contents. Do NOT set grid text directly, and get rid of the GridObject.Refresh line.

Edit 2:

Code: Select all
    if (search.Results.Count > 0)
            {     
               var DescriptionField = (JiwaFinancials.Jiwa.JiwaApplication.JiwaSearch.Field)search.get_Fields(2);
               CustomFieldValue.DisplayContents =  DescriptionField.FieldValue.ToString();
           
               var idField = (JiwaFinancials.Jiwa.JiwaApplication.JiwaSearch.Field)search.get_Fields(1);
               CustomFieldValue.Contents = idField.FieldValue.ToString();
            }

Re: Inventory Category Custom Field Lookup

PostPosted: Tue May 26, 2020 4:02 pm
by SBarnes
Hi Scott

I have read code and that works fine as proven by the screen saving and refreshing or going out of the screen and coming back in, for some reason without setting the grid cell explicitly is not refreshing but only when closing the search screen.

Re: Inventory Category Custom Field Lookup

PostPosted: Tue May 26, 2020 4:04 pm
by Scott.Pearce
Yeah, it looks like setting .DisplayContents does not fire a change event, but setting .Contents does. So I set .Contents last.