Can't use go_item

In a when-validate-item (w-v-i) trigger :item = 'Y' I want the cursor to move to a previous item on the  canvas. I cannot use a go_item in a w-v-i trigger. I tried a key-next-item with a go_item and it didn't GO.

K-N-I code
if :suspected_of_drug = 'Y'
   and :criminal_activity_code is null
   then
   go_item('incident_offenses.Criminal_Activity_Code');
end if;
SFMelangeAsked:
Who is Participating?
 
flow01Commented:
to fix your error message try
create  a key-next-item with

do_key(('key-enter'); --
-- once the key-enter is executed  evaluate the new status
    if :suspected_of_drug = 'Y'
    and :criminal_activity_code is null
    then go_item('incident_offenses.Criminal_activity_code');
   end if;

--  but I suspect this is not what you want in the end:
using this method in stead of the  when-validate-item you will have to take such action  for every key or mouse action that causes the suspected_of_drug item to leave
(previous-item, next_block, previous block , commit , .. etc)


-- i would use a timer
when-validate-item >>
message('validate item',acknowledge);
if :suspected_of_drug = 'Y'  AND :criminal_activity_code IS NULL THEN
      DECLARE timer_id Timer;  
      BEGIN timer_id := CREATE_TIMER('go_criminal_activity_code', 5, NO_REPEAT);  -- create a  timer firing after 5mseconds
      END;
END IF;
-- the item is marked as valid , but after that the timer fires

when-timer-expired >>  (on form level)
IF GET_APPLICATION_PROPERTY(TIMER_NAME) = 'GO_CRIMINAL_ACTIVITY_CODE' THEN
  go_item('criminal_activity_code');
END IF;

-- to prevent leaving the record by for example next_block or commit
when-validate-record >>
message('validate record',acknowledge);
if :suspected_of_drug = 'Y'  AND :criminal_activity_code IS NULL THEN
      DECLARE timer_id Timer;  
      BEGIN timer_id := CREATE_TIMER('go_criminal_activity_code', 5, NO_REPEAT);  -- create a  timer firing after 5mseconds
      END;
      raise form_trigger_failure; -- don't leave the record until the condition is satisfied
END IF;


0
 
leewv1Commented:
You can't use navigation commands (GO_BLOCK, GO_ITEM) in when-validate triggers.  

Here's a similar issue:  http://www.experts-exchange.com/Database/Oracle/Q_12041279.html
0
 
anumosesCommented:
key-next-item trigger use this do_key('enter');

key-enter trigger -
if :suspected_of_drug = 'Y'
   and :criminal_activity_code is null
   then
   go_item('incident_offenses.Criminal_Activity_Code');
end if;

Try this
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
SFMelangeAuthor Commented:
anumoses, I tried your suggestion but received an error - am I misunderstanding something?

1. created a key-next-itme with do_key('key-enter');
2. created key-enter trigger
3. got error on:
key-enter trigger -
    if :suspected_of_drug = 'Y'
    and :criminal_activity_code is null
    then go_item('incident_offenses.Criminal_activity_code');
   end if;
Error 103 at line 1 column 4
encountered the symbol "." when excepting one of the following:  :=.(@%;
This error is flagging the first hyphen on the first line key-enter trigger
0
 
anumosesCommented:
Are these triggers at item level? I mean where are you writing these triggers?
0
 
anumosesCommented:
You can also use previous_item; in the key-enter trigger
and keep the code for key-next-item as it is with do_key('enter');
0
 
anumosesCommented:
 if (:suspected_of_drug = 'Y' and :criminal_activity_code is null ) then
    go_item('incident_offenses.Criminal_activity_code');
   end if;
OR
  if (:suspected_of_drug = 'Y' and :criminal_activity_code is null ) then
    previous_item;
   end if;

This is for key-enter trigger

0
 
SFMelangeAuthor Commented:
anumoses,
Yes, these triggers are at item level.
Why am I getting an error on "the first line" which is auto populated "key-enter trigger -"
As for the "key-next-item "do_key('enter'); "  IS IT ('enter') or is it ('key-enter') ?
Thanks for the help.
0
 
anumosesCommented:
what is your forms version?
0
 
SFMelangeAuthor Commented:
anumoses
10g
0
 
anumosesCommented:
create a test .fmb

three fields.

In the second field add the code
key-enter trigger  and key-next-item trigger
key-enter trigger - code is previous_item;
key-next-item - code is do_key('enter');
Try and run this.  Here I cannot upload fmb.
0
 
anumosesCommented:
I ran in forms 10g. so it works for me
0
 
anumosesCommented:
its do_key('enter');  - correct


not do_key('key-enter'); in - correct
0
 
anumosesCommented:
Try this also
Do_Key('PREVIOUS_ITEM');  in w-v-i
0
 
SFMelangeAuthor Commented:
I used the advice of the thee experts and came up with my own solution.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.