This discussion is archived
12 Replies Latest reply: Jun 14, 2009 9:19 PM by 682000 RSS

go_item in Oracle From 10g

682000 Newbie
Currently Being Moderated
Hi,
I have got following logic to validate surname and given_name in when-validate-record trigger. What I need to do is wthe user receives ''Both Surname and Given Name must be entered' message the cursor also goes to surname field

but I can't use go_item('myblock.suanme') in when-validate-record trigger. Could you tell me what the best wat to acheive this? Thanks

IF :myblock.W_PHONE IS NOT NULL
OR :myblock.EMAIL IS NOT NULL THEN
IF :myblock.FAM_NAME IS NULL
OR :myblock.GIV_NAME IS NULL THEN
message( 'Both Surname and Given Name must be entered');
raise form_trigger_failure;
END IF;
END IF;
  • 1. Re: go_item in Oracle From 10g
    598585 Journeyer
    Currently Being Moderated
    You can simply make the REQUIRED property TRUE for sirname and given_name.

    Please mark the answer if it helps.
  • 2. Re: go_item in Oracle From 10g
    682000 Newbie
    Currently Being Moderated
    Thanks for the reply. But the fields are just conditionally required not always mandatory fields. that's why I put the code in when-validate-record trigger.

    Thanks
  • 3. Re: go_item in Oracle From 10g
    Andreas Weiden Guru
    Currently Being Moderated
    You can set the require-property at runtime, e.g. when the condition changes.
  • 4. Re: go_item in Oracle From 10g
    682000 Newbie
    Currently Being Moderated
    Hi Andreas,
    Thanks for your help. Yes I did set the property required to trye but the cursor focus still in the current field not the field I want it to go eg given name field.
    I tried Next_Navigation_Item Property and it does not help either. All I need is when the user receives message and cursor also goes to the item so user can do the data entry without looking for the field. Thanks

    Michael
  • 5. Re: go_item in Oracle From 10g
    Andreas Weiden Guru
    Currently Being Moderated
    The following code works for a form with 3 fields in a block, TEXTITEM_A and TEXTITEM_B to be conditional Required or not and an item CONDITION to simulate the conditional setting of these properties, there is no need for w WHEN-VALIDATE-RECORD-trigger in this scenario.
    SET_ITEM_PROPERTY('BLOCK.TEXTITEM_A', REQUIRED, PROPERTY_FALSE);
    SET_ITEM_PROPERTY('BLOCK.TEXTITEM_B', REQUIRED, PROPERTY_FALSE);
    IF :BLOCK.CONDITION='A' THEN
      SET_ITEM_PROPERTY('BLOCK.TEXTITEM_A', REQUIRED, PROPERTY_TRUE);
      SET_ITEM_PROPERTY('BLOCK.TEXTITEM_A', ITEM_IS_VALID, PROPERTY_FALSE);
    ELSIF :BLOCK.CONDITION='B' THEN
      SET_ITEM_PROPERTY('BLOCK.TEXTITEM_B', REQUIRED, PROPERTY_TRUE);
      SET_ITEM_PROPERTY('BLOCK.TEXTITEM_B', ITEM_IS_VALID, PROPERTY_FALSE);
    END IF;
    The code is placed at the WHEN-VALIDATE-ITEM-trigger of the item BLOCK.CONDITION.
  • 6. Re: go_item in Oracle From 10g
    682000 Newbie
    Currently Being Moderated
    Hi Andreas,

    Thanks for your help. I'll try out your solution. Appraciated your time!!

    Michael Tian
  • 7. Re: go_item in Oracle From 10g
    682000 Newbie
    Currently Being Moderated
    Hi Andreas,
    Thanks for providing me the sample and I aply it to my form. But I have got one problem and hopefully you could help me to
    resolve it.

    Requirements is: R_PCODE must be entered if either R_ADDR1 or R_ADDR2 is populated

    I have got the following code in when-validate-item in block level not item level

    IF :SYSTEM.TRIGGER_ITEM = 'BLOCK.R_ADDR1' THEN
    SET_ITEM_PROPERTY('BLOCK.R_PCODE', REQUIRED, PROPERTY_FALSE);
    IF :BLOCK.R_ADDR1 IS NOT NULL THEN
    SET_ITEM_PROPERTY('BLOCK.R_PCODE', REQUIRED, PROPERTY_TRUE);
    END IF;
    SET_ITEM_PROPERTY ('BLOCK.R_PCODE', ITEM_IS_VALID, PROPERTY_FALSE);
    END IF;

    IF :SYSTEM.TRIGGER_ITEM = 'BLOCK.R_ADDR2' THEN
    SET_ITEM_PROPERTY('BLOCK.R_PCODE', REQUIRED, PROPERTY_FALSE);
    IF :BLOCK.R_ADDR2 IS NOT NULL THEN
    SET_ITEM_PROPERTY('BLOCK.R_PCODE', REQUIRED, PROPERTY_TRUE);
    END IF;
    SET_ITEM_PROPERTY ('BLOCK.R_PCODE', ITEM_IS_VALID, PROPERTY_FALSE);
    END IF;


    Problem:
    First time in the form if I populate R_ADDR1 and leave R_PCODE blank and save the record,I'm expecting that form will ask me to populate R_PCODE,
    but record is saved into database. If I then change the value of R_ADDR1 and save it, this time I will be ask to populate R_PCODE and work as expected.
    The problem is only at the very first time and then works fine

    This problem only happens to R_ADDR1 not R_ADDR2. In other words, If 1st time I populate R_ADDR2 and leave R_PCODE blank. I'll be asked to populate R_PCODE.
    I really don't know why behaviour


    Could you give me some advice on this issue? Many Thanks
  • 8. Re: go_item in Oracle From 10g
    Andreas Weiden Guru
    Currently Being Moderated
    Is there an additional WHEN-VALIDATE-ITEM-trigger at item-level on BLOCK.R_ADDR1?
  • 9. Re: go_item in Oracle From 10g
    682000 Newbie
    Currently Being Moderated
    Hi Andreas,
    No, there is no item level trigger for P_ADDR1. Thanks. I suspect that code maybe corrupted. Is that possible?
  • 10. Re: go_item in Oracle From 10g
    682000 Newbie
    Currently Being Moderated
    Hi Andreas,
    When I use the following method to validate R_PCODE, the message I get is generic madatory field validate one "FRM:40202 Field must be enter". Is there a way to customise this message to "Postcode field must be entered"?
    Thanks.

    IF :SYSTEM.TRIGGER_ITEM = 'BLOCK.R_ADDR1' THEN
    SET_ITEM_PROPERTY('BLOCK.R_PCODE', REQUIRED, PROPERTY_FALSE);
    IF :BLOCK.R_ADDR1 IS NOT NULL THEN
    SET_ITEM_PROPERTY('BLOCK.R_PCODE', REQUIRED, PROPERTY_TRUE);
    END IF;
    SET_ITEM_PROPERTY ('BLOCK.R_PCODE', ITEM_IS_VALID, PROPERTY_FALSE);
    END IF;

    IF :SYSTEM.TRIGGER_ITEM = 'BLOCK.R_ADDR2' THEN
    SET_ITEM_PROPERTY('BLOCK.R_PCODE', REQUIRED, PROPERTY_FALSE);
    IF :BLOCK.R_ADDR2 IS NOT NULL THEN
    SET_ITEM_PROPERTY('BLOCK.R_PCODE', REQUIRED, PROPERTY_TRUE);
    END IF;
    SET_ITEM_PROPERTY ('BLOCK.R_PCODE', ITEM_IS_VALID, PROPERTY_FALSE);
    END IF;
  • 11. Re: go_item in Oracle From 10g
    Andreas Weiden Guru
    Currently Being Moderated
    Here is a possible solution Re: Trigger name for Action --> Save
  • 12. Re: go_item in Oracle From 10g
    682000 Newbie
    Currently Being Moderated
    Hi Andreas,
    Thanks! I'll try on-error triggers.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points