Home » Developer & Programmer » Forms » when-validate-record trigger (forms 9i)
when-validate-record trigger [message #509268] Thu, 26 May 2011 15:35 Go to next message
deahayes3
Messages: 203
Registered: May 2006
Senior Member

Hello all,

I am trying to write a procedure using when-validate-record that will clear all fields, display a message and ignore all commits if user is not authorized to have access to make changes to the form.

I have tried to use Clear_form(no_validate)and clear_record and neither works, any suggestions;
Re: when-validate-record trigger [message #509269 is a reply to message #509268] Thu, 26 May 2011 15:39 Go to previous messageGo to next message
joy_division
Messages: 4963
Registered: February 2005
Location: East Coast USA
Senior Member
The usual response you will get is "it does not work" is not an Oracle message. Please explain in detail what happened, and why you think it did not work.
Re: when-validate-record trigger [message #509270 is a reply to message #509269] Thu, 26 May 2011 15:51 Go to previous messageGo to next message
deahayes3
Messages: 203
Registered: May 2006
Senior Member

When I use clear_record it seems as though the form gets stuck, I can not even close the form.

I am receiving this error:
frm-40737 illegal restricted procedure CLEAR_FORM in WHEN VALIDATE PROCEDURE

The only good thing is, its not saving to the database but the message that I have to display that the user is not authorized is displaying 3 times (Save button twice, close button once) perhaps I should check this validation on another trigger? I would like to stay on the form and clear the record.
Re: when-validate-record trigger [message #509281 is a reply to message #509270] Fri, 27 May 2011 00:50 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Well, perhaps you should turn it upside down. Instead of checking whether that particular user is allowed to modify items' values at the END of the story, do that at the BEGINNING. A WHEN-NEW-FORM-INSTANCE trigger, or PRE-FORM, or even PRE-BLOCK might be the candidates. SET-BLOCK-PROPERTY built-in is what I have on mind. Depending on what exactly you want to prevent, you could combine several combinations. For example: UPDATE_ALLOWED specifies whether the operator or the application is allowed to update records in the given block. So you'd
if user = 'READER_ONLY' then
   SET_BLOCK_PROPERTY('block_name', update_allowed, property_false);
else
   SET_BLOCK_PROPERTY('block_name', update_allowed, property_true);
end if;

Re: when-validate-record trigger [message #509330 is a reply to message #509281] Fri, 27 May 2011 03:51 Go to previous messageGo to next message
cookiemonster
Messages: 13937
Registered: September 2008
Location: Rainy Manchester
Senior Member
I'm with Littlefoot. If I, as a user, entered a load of data in form, clicked save, and then got an error message telling me I'm not allowed to do anything and everything I entered disappeared - I'd be very annoyed.
Tell the users they aren't allowed to do stuff at the start.
Re: when-validate-record trigger [message #509390 is a reply to message #509330] Fri, 27 May 2011 07:47 Go to previous messageGo to next message
deahayes3
Messages: 203
Registered: May 2006
Senior Member

Thanks so much for the responses, but let me give you a little more detail. On certain records the user will not be allowed to update records. When the user tries to update or create a new record that is two weeks past todays date, the form should not allow them to save if they are not an authorized user. The goal is to have users enter records on time and not change records a month or so later. Hope this helps.
Re: when-validate-record trigger [message #509392 is a reply to message #509390] Fri, 27 May 2011 08:03 Go to previous message
cookiemonster
Messages: 13937
Registered: September 2008
Location: Rainy Manchester
Senior Member
Then block them in when-new-record-instance. Use set_item_instance_property to change update_allowed and for the records in question.
You can also do that from post-query.
And to make the users lives easier you could set the visual attributes for those records to make them obviously different from the records they are allowed to modify.
Previous Topic: Help in Oracle Forms 6i
Next Topic: How to Export Text File in Oracle 8[URGENT]?
Goto Forum:
  


Current Time: Sat Sep 07 15:33:27 CDT 2024