aamir_faried
26th August 2010, 16:36
Hello guys,
Could any body please help me out to find how to change Form Command Availability at run time.
I have two button on the session through form command. these form command has availability 'On Record Selected'. Its original purpose was to enable these button when any row in selected in the below Grid. (just like in Dashboard).
But now i have change in request and it is required the based on selected index the button (form command) should be enabled though either by selecting a record from Grid or it should be enable always.
i.e.
if session is sorted by 'index_1' then button (command) should be available by 'On Record Selected'
but if session is sorted by 'index_2' then button (command) should be available by 'alway'
Is there any way to do it.
Thanks for your help (in advance)
/Aamir
NPRao
26th August 2010, 22:03
Aamir,
You can try to explore using:
long number.of.marks 4R Number of selected records in the grid.
Note that from Tools Interface Version (TIV) TIV 1075 you can also use sel.num.selected()
long marked 4R Indicates the marked record. If multiple records are marked then this indicates the first one marked.
Deprecated from Tools Interface Version (TIV) TIV 1075.
boolean attr.currkey 4R true current field is a key field
false current field is not a key field
long attr.zoomindex 4 Number of table-index to start session zoomed to from a field.
aamir_faried
27th August 2010, 10:00
NPRao, thanks alot for your reply.
As for as i understand, you recommend a solution in which i can select record in grid in script. Yep, i could be one of the solution.
Actually my basic demand is that i dont want to select record in grid. I want to change command availability between the values "always" and "On Record Selected".
i.e.
if session is sorted by 'index_1' then button (command) should be available by 'On Record Selected'
but if session is sorted by 'index_2' then button (command) should be available by 'alway'
/Aamir
en@frrom
1st September 2010, 12:56
Imagine you have a form command of type function, and if index1 is selected, the command availability mode is 'always'; if a different index, the command availability is 'one record selected'.
You can do something like this:
choice.change.order:
after.choice:
if curr.key = 1 then
enable.commands("form.command.name")
else
disble.commands("form.command.name")
endif
choice.mark.occur:
after.choice:
if curr.key > 1 then
if number.of.marks = 1 then
enable.commands("form.command.name")
endif
endif
function extern form.command.name()
{
.....
... Your code
if curr.key > 1 then
disable.commands("form.command.name")
endif
}
Regards,
Eli Nager
erplearner2013
24th April 2014, 09:12
Hi,
i have to work for same scenario, in my case when changing my index 1 to any other index then my form command availability will change from 'One Record Selected' to 'Always;.
the solution which you have given will work for command availability changing from 'Always' to 'One Recorded selected'.
is their any other way?
As per my knowledge what i was thinking is that form commands table is ttadv316 in this table their is a field with command availability can we modify that when doing dynamic index switching, i have not used tt tables so far if any one understand what i m trying to say so please share some knowledge and also do tell me if i m not correct...........
JaapJD
24th April 2014, 09:26
Changing the form command at runtime in table ttadv316 will not work. Two reasons:
1. The table is not used at runtime, but the compiled (dumped) form on the file system.
2. If the table would be used, you have the problem that different users may use different indexes in this session concurrently.
So, you need to set the availability to 'Always' and check whether the the command is valid when it is used.
FabianoSilva
5th January 2015, 21:59
Perfect!!!! Works for me the command curr.key
Imagine you have a form command of type function, and if index1 is selected, the command availability mode is 'always'; if a different index, the command availability is 'one record selected'.
You can do something like this:
choice.change.order:
after.choice:
if curr.key = 1 then
enable.commands("form.command.name")
else
disble.commands("form.command.name")
endif
choice.mark.occur:
after.choice:
if curr.key > 1 then
if number.of.marks = 1 then
enable.commands("form.command.name")
endif
endif
function extern form.command.name()
{
.....
... Your code
if curr.key > 1 then
disable.commands("form.command.name")
endif
}
Regards,
Eli Nager
FabianoSilva
5th January 2015, 21:59
perfect, Works for me the command curr.key.
thanks a lot.