sachinbaan
13th February 2014, 07:30
Hi,

How to switch index programatically.?

sachinbaan
13th February 2014, 07:43
i tried to.key() but not getting proper result

bhushanchanda
13th February 2014, 07:59
Hi,

Explore the functionality of to.key()

Prog. Manual (http://www.baanboard.com/programmers_manual_baanerp_help_functions_db_operations_to_key)

Also note:-

Syntax:
function void to.key (long key_number [, long nr.view.fields])

Description

Use this to change the key of the main table without user interaction. The key_number argument specifies the new key.

When nr.view.fields is specified the session will start with the specified number of viewfields, this is valid only for sessions with dynamic index switching. When in dynamic index switching sessions this parameter is not passed, the default number of viewfields as defined in Sessions - Indices for that index. Note the alignment, labels, and validation when you have sessions with variable number of viewfields.

When changing the key of the main table within the on.main.table() function, you must use db.change.order() instead. Also, to change the key of a table other than the main table, you must use db.change.order().

You can also use execute(change.order) to change the key of the main table. In this case, the user selects the new key.

Note that during execution of the ADD.SET, MODIFY.SET and MARK.DELETE commands, the current key is saved and the primary key becomes the current key. After the database has been updated, the 4GL engine restores the saved key.


Arguments
long key_number Sequence number of the key to be used

[long nr.view.fields] specifies the specified number of viewfields the session will start with


Context
This function is implemented in the 4GL Engine and can be used in 4GL script types.


long dynamic.index.switching:- Can be set in before.program for non-integrated sessions. Indicates the way the session should use dynamic index switching. Possible values:

This functionality is deprecated. Dynamic index switching should be enabled in the session properties. If a session only enables Dynamic Index Switching in the before.program section this will not work in WebTop.

0 No dynamic index switching.
-1 Restart when view fields differ.
-2 Always restart session when switching indices.

sachinbaan
13th February 2014, 08:23
hi,

in my session i m having 3 index
1. cono,cnln,vrsn
2. cprj,cono,cnln,vrsn
3. cprj

now when i start the session index 1 is active, when i search data using ctrl+f it shows all 3 index with radio button with index1 selected, i want index3 to be selected by default..... help me

bhushanchanda
13th February 2014, 10:19
Hi,

Just do this:--

choice.find.data:
before.choice:
to.key(3, 0) | 3 is the index number and 0 is the number of view fields on your form. If there are any view fields, put the number here.