Set current record into FID

Hi

i want to click a button from a portal child record (button in the portal) and show this record in a FID (record view, different form) including the other related child records. i want to make sure i can go to the record in the FID i was on when i called the method from the portal.

i can do this but don’t know how to make sure i get to the original record id i was on. have tried various forms of get/set selected index/record.

The form in dialog is for the child records (record view).

what happens if the records in the portal are sorted differently from the records in the FID?

also not sure what the best way to load the related child records since i am calling from a child record. currently doing a search.

appreciate any help

Hi Rodney,

Check out this thread:Go to record from foundset in list - Classic Servoy - Servoy Community

It seems to have the essentials for what you need

Hope this helps
Cheers
Harry

Hi Harry

Thanks for your reply.

saw that post previously and tried the example but still not working.

current code:

// get the index of the selected record
var v_index = parent_to_child.getSelectedIndex();

// loads the related child records
var fs = databaseManager.convertFoundSet(foundset, parent_to_child);
forms.fid_components.controller.loadRecords(fs);

// sets the initial index
forms.fid_components.controller.setSelectedIndex(v_index);

// pop fid
application.showFormInDialog( forms.schedules_fid_components, 100, 200, 675, 750, “Lifspan Components”, false, false, true);

this tells me the foundset count on the FID is all records not just the related records and worse when i move through the records on the FID the form displays only the 1 record?? very odd.

is this the best way to load the related records into the form before popping a FID?

Hi Rodney,

Have you watched this through debugger and does it create the dataset correctly for you ?

I have a method which does the same but uses a SQL query to get the dataset

// get the psl pk
globals.gNum01 = zzid_organisation_psl

// first load the related person records for the organisation
var pk_orgn = forms.orgn_t_summary.zzid_organisation
var query = 'select zzid_j_organisation_person from j_organisation_person where zrid_organisation = ' + pk_orgn;
var dataset = databaseManager.getDataSetByQuery(controller.getServerName(), query, null, 150);

forms.j_orgn_person_t_list300.controller.loadRecords(dataset)

// then show the form in dialogue to choose the link
var vTitle	= 'Choose Person'
application.showFormInDialog( forms.j_orgn_person_t_list300  , -1, -1, -1, -1, vTitle)

This seems to parallel your process and works fine for me

Cheers
Harry

ADDENDUM:
Rodney I have just added the line:

forms.j_orgn_person_t_list300.controller.setSelectedIndex(3)

to the method above after the load records function and it works using a manual index setting (have changed the index number several times and it always goes to target index !)

There must be something amiss with your dataset :cry:

Hi Harry

Will try the query and dataset instead. Thanks

Where do you go to the selected id in your method after loading the records, i can’t see that anywhere in your code?

Hi Rodney,

This is how I modified it:

// get the psl pk 
globals.gNum01 = zzid_organisation_psl 

// first load the related person records for the organisation 
var pk_orgn = forms.orgn_t_summary.zzid_organisation 
var query = 'select zzid_j_organisation_person from j_organisation_person where zrid_organisation = ' + pk_orgn; 
var dataset = databaseManager.getDataSetByQuery(controller.getServerName(), query, null, 150); 

forms.j_orgn_person_t_list300.controller.loadRecords(dataset) 

forms.j_orgn_person_t_list300.controller.setSelectedIndex(3)

// then show the form in dialogue to choose the link 
var vTitle   = 'Choose Person' 
application.showFormInDialog( forms.j_orgn_person_t_list300  , -1, -1, -1, -1, vTitle)

Straight after the ‘loadRecords’ function

Cheers
Harry

rodneysieb:
Hi

i want to click a button from a portal child record (button in the portal) and show this record in a FID (record view, different form) including the other related child records. i want to make sure i can go to the record in the FID i was on when i called the method from the portal.

i can do this but don’t know how to make sure i get to the original record id i was on. have tried various forms of get/set selected index/record.

The form in dialog is for the child records (record view).

what happens if the records in the portal are sorted differently from the records in the FID?

also not sure what the best way to load the related child records since i am calling from a child record. currently doing a search.

appreciate any help

an easy way to bypass managing foundsets and record indexes is to create your FID form set with the same structure as the form set from where you clicked from to open the FID. example:

1- let’s assume that your starting form is an organization record with a portal listing all the people in that organization.

2- you want to click on a person in the portal, open a FID which lists all the people in the organization, and be on the person you clicked.

3- instead of opening a FID where the form is based on the people table, open a FID where the base form is based on the organization table. display your people list with a tab panel that covers the entire form and uses the same relationship of organization_to_people that you were using on the form that you clicked.

because of the FID form design and because servoy shares foundsets and indexes between identically setup forms, you won’t see anything that has to do with the organization record – you just see a list of the people in the organization and your index will be on the person you clicked to open the FID.

Hi

Thanks guys.

I have got around this in the meantime by making sure the sorting of records in the portal is the same as the FID and then i can get/set the index to get to the same record no problem.

Will try using the same parent table for the FID as mentioned.

Thanks again.