Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dexterity - new Lookup window - ranges 1

Status
Not open for further replies.

Borvik

Programmer
Jan 2, 2002
1,392
US
I'm attempting to create a new lookup window for my GP application plugin.

The lookup itself is working - ie filling the scrolling window, and returning a value, but I cannot get it to set a range.

I created a form procedure for the form called Initialize so the lookup is opened this way:
Code:
open form EC_User_Lookup return to 'Login';
call Initialize of form EC_User_Lookup, 'Customer Number';
and here is the Initialize code:
Code:
in 'Customer Number' sCstnmbr;

local long num_records;

range clear table EC_User;
'Customer Number' of table EC_User = sCstnmbr;
range start table EC_User by EC_User_Key4;
'Customer Number' of table EC_User = sCstnmbr;
range end table EC_User by EC_User_Key4;

num_records = countrecords(table EC_User);
warning "Using CustNMBR: " + sCstnmbr + " (" + str(num_records) + ")";

fill window EC_User_Lookup_Scroll;
I have tried various combinations of the "fill window" statement including "fill window EC_User_Lookup_Scroll table EC_User by EC_User_Key4".

EC_User_Key4 contains only one key segment that is indexed ('Customer Number').

The warning message (which I'm only using for debugging purposes in a multi-dictionary environment) is correctly showing the Customer Number and the number of records for that customer number - yet the scrolling window still shows the records for EVERY customer number - not just the one specified in the range.

Any ideas on what I can do to get the scrolling window to show only the records for the passed Customer Number?

Thanks.
 
You MUST fill the window using the same index that the range is set on.

You need

fill window EC_User_Lookup_Scroll by EC_User_Key4;

You bigger problem is that you are not working with the same table buffer. Procedures and functions must be passed a table buffer otherwise they create their own instance.

So the local procedure's table buffer has the range set, but the fill window is using the form's table buffer which does not have the range set. So all records are shown.

To fix, add a Customer Number field to the lookup's main window. Copy the code from your Initialize script into the field's change script, adjusting to use the field value instead of a parameter.

Then change your Initialize script to set the Customer Number Field from the parameter and run script on that field. Now the range will be in the correct context.

PS: Don't forget ALL operations must use the same index as the range is set on to be limited by that range.

David Musgrave [MSFT]
Escalation Engineer - Microsoft Dynamics GP
Microsoft Dynamics Support - Asia Pacific

Microsoft Dynamics (formerly Microsoft Business Solutions)

Any views contained within are my personal views and
not necessarily Microsoft Business Solutions policy.
This posting is provided "AS IS" with no warranties,
and confers no rights.
 
Thanks Dave.

I had tried filling it via a push button as well - to no success (after filling a local field with the value).

I'm not sure what I did different with that scenario to what you suggested, but it works.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top