Issue finding a record

I have a TabPanel on a form and the TabPanel is set to Table view locked. To the very left of each row in the TabPanel I placed a Details button which a user can click on to see the details of the record. However I can not seem to get to the exact record. I keep getting a random record.

The script I have attached to the Details button is as follows:

//Get record details and place them in globals
globals.gLdr_entity_id = ldr_entity_id;
globals.gCoh_acct = coh_acct;
globals.gCoh_cost_ctr = coh_cost_ctr;

//switch form and perform find
forms.Grant_SubAcct.controller.show();
forms.Grant_SubAcct.controller.find();
forms.Grant_SubAcct.ldr_entity_id = globals.gLdr_entity_id;
forms.Grant_SubAcct.controller.newRecord();
forms.Grant_SubAcct.coh_acct = globals.gCoh_acct;
forms.Grant_SubAcct.controller.newRecord();
forms.Grant_SubAcct.coh_cost_ctr = globals.gCoh_cost_ctr;
forms.Grant_SubAcct.controller.search();

I also tried capturing (ldr_entity_id, coh_acct, & coh_cost_ctr) as local variables but received the same results.

I also tried the following code as well with no luck:

var vIndex = controller.getSelectedIndex();
forms.Grant_SubAcct.controller.loadRecords(vIndex); 
forms.Grant_SubAcct.controller.show();

The backend is Sybase version is 12.5.3 (on a Unix box).
The driver Im using is com.sybase.jdbc3.jdbc.SybDriver
Database Server URL is: jdbc:sybase:Tds:IpAddress:4100/databasename
Servoy Developer
Version 3.1.5-build 409
Java version 1.6.0_01-b06 (Windows XP)

Thanks,
David

the following code works just fine if I navigate to the Form that the tabPanel is based on and click on the Details button

var vIndex = controller.getSelectedIndex();
forms.Grant_SubAcct.controller.loadRecords(vIndex); 
forms.Grant_SubAcct.controller.show();

Hi David

You could use a global relationship.

Setup a global integer variable:
globals.gcurr_TableNameID

Setup a global relationship:
‘gcurr_TablenameID_to_TableName_ID’ using globals.gcurr_TableNameID → TableName_ID

Then attach a method the the Detail button:

globals.gcurr_TableName = dr_entity_id // set the global variable
forms.Grant_SubAcct.controller.loadRecords(gcurr_TablenameID_to_TableName_ID) // load the one record that is required

Depending on how the Details form works with other forms you may need to set it to ‘useSeperateFoundset’.

HTH

Graham Greensall
Worxinfo Ltd

Hi Graham

Thanks for the suggestion, but I need to match three fields to get a unique record.

The three fields are:
ldr_enttiy_id
coh_acct
coh_cost_ctr

All are text fields and all are primary keys.

Hi David,

Couple of things:

//switch form and perform find 
forms.Grant_SubAcct.controller.show(); 
forms.Grant_SubAcct.controller.find(); 
forms.Grant_SubAcct.ldr_entity_id = globals.gLdr_entity_id; 
forms.Grant_SubAcct.controller.newRecord(); 
forms.Grant_SubAcct.coh_acct = globals.gCoh_acct; 
forms.Grant_SubAcct.controller.newRecord(); 
forms.Grant_SubAcct.coh_cost_ctr = globals.gCoh_cost_ctr; 
forms.Grant_SubAcct.controller.search();

This code performs an OR search because you are adding a new find request for each criteria and I get the impression that you need to have all 3 fields in a single search request. So could this be causing the inconsistent find result ?

var vIndex = controller.getSelectedIndex(); 
forms.Grant_SubAcct.controller.loadRecords(vIndex); 
forms.Grant_SubAcct.controller.show();

You are launching this from the parent form and so the controller.getSelectedIndex will pick up the index of the parent form record. You should change this to :forms.Grant_SubAcct.controller.getSelectedIndex();

But how are you then viewing the record that you have loaded ?
Are you changing the main form to that of the related record and viewing it there or are you loading it in a form in dialogue to view it ?

Cheers
Harry

davidaarong:
Hi Graham

Thanks for the suggestion, but I need to match three fields to get a unique record.

The three fields are:
ldr_enttiy_id
coh_acct
coh_cost_ctr

All are text fields and all are primary keys.

That doesn’t make much of a difference, because a relation can be based on more than one global.

If you do as Graham suggested, but use 3 globals instead of 1 in your relation and set all those globals in your method, you are fine.