This discussion is archived
8 Replies Latest reply: Nov 15, 2012 7:50 AM by Howard (... in Training) RSS

Is the "Button Name" available in the PL/SQLfor the "Condition"

731104 Newbie
Currently Being Moderated
I know that the "Button Name" is available when a page is submitted through a button in the REQUEST.

Do I have the button name as well available in the "Conditions" section of the button?

Background:
We have devised a state transition logic linking APEX and an arbitrary business object in the database.
Each event of the state machine is represented by a "Button Name". In the page display cycle of the APEX page, the business object retrieved to the page is evaluated whether the event is allowed in that condition.
This should avoid offering events that are not possible.

Currently the handling is manageable, but error prone and mundane.

Button Name: APPROVAL
...

Condition
is_event_allowed(<Primary Key of Business Object>, 'APPROVAL')
...

... and yes I could generate the PL/SQL for the page buttons, automatically based on the events, but ... I am not so far to be that generic;-)

Tx,
Thomas

Edited by: t-o-b on Nov 9, 2012 7:36 AM
corrected the bad English in the first sentence
  • 1. Re: Is the "Button Name" available in the PL/SQLfor the "Condition"
    Howard (... in Training) Pro
    Currently Being Moderated
    Yes! The REQUEST variable contains the button name. So you can write code like this
    begin
    if :REQUEST in ('SAVE','UPDATE') and :P1_itemname = 'A' then
    return true;
    else
    return false;
    end if;
    end;
    I believe you would pass the value of ":REQUEST" to your process.

    Or use one of the conditions which references REQUEST, such as "REQUEST is contained within Expression 1" and you give the button name in "Expression 1"

    See: http://www.talkapex.com/2011/12/apex-process-condition-with-multiple.html

    Thanks to Martin Giffy D'Souza.

    May God Bless,
    Howard
  • 2. Re: Is the "Button Name" available in the PL/SQLfor the "Condition"
    731104 Newbie
    Currently Being Moderated
    Hi Howard,

    this does not work as the REQUEST is only submitted into the session, when the page is submitted.
    I need the "Button Name" during the rendering phase, when the Condition is evaluated. I want to access this for every button, not necessarily requiring any of them to be pressed.

    I decided to generate the button code (only) from the state machine configuration through a template. These buttons are not referenced anywhere else as button conditions or the like. It is not truly generic but works and is faster than adding them all by hand.

    Regards,
    - Thomas
  • 3. Re: Is the "Button Name" available in the PL/SQLfor the "Condition"
    Howard (... in Training) Pro
    Currently Being Moderated
    Hello again. I'm trying to understand what you are doing.

    Some questions:
    1) Are you trying to do something with all the defined buttons at once? But in the general case, you don't know which buttons have been defined because that happens in another process?
    2) Are you operating on each button, one at a time as they are rendered?
    3) Or, do you want to do some other operation -- separate and apart from the button creation / rendering -- but based upon whether that button exists?

    It seems to me, that the only way you can take some action in a separate process is if you have set some global (i.e., application or page level) item to some value that you will check to determine what action to take.

    Well, one other way. Do you need to know the underlying Oracle tables where button definitions are stored when they are created? Someone may be able to assist with that if that's what we are talking about.

    Kind regards,
    Howard
  • 4. Re: Is the "Button Name" available in the PL/SQLfor the "Condition"
    Howard (... in Training) Pro
    Currently Being Moderated
    One more thing. If you just want to manipulate the button on the page itself, I do that all the time. I have PREVIOUS and NEXT buttons which never disappear but are enabled and/or disabled depending whether there is previous or next data to view. I don't need the button name for this but I have an item holding the "disable" attribute that I associate with the button. When the attribute is null, the button is enabled. When it is "disabled," so is the button. I re/set the attributes in a header process.
  • 5. Re: Is the "Button Name" available in the PL/SQLfor the "Condition"
    731104 Newbie
    Currently Being Moderated
    Howard (DBA in Training) wrote:
    Hello again. I'm trying to understand what you are doing.

    Some questions:
    1) Are you trying to do something with all the defined buttons at once? But in the general case, you don't know which buttons have been defined because that happens in another process?
    No - I am trying to define the button condition through a packaged function that is dependent on the button name. I have a few buttons and wanted to avoid copy and past errors.
    Button Name: APPROVAL
    ...

    Condition
    is_event_allowed(<Primary Key of Business Object>, <Button Name> instead of the explicit "APPROVAL")
    2) Are you operating on each button, one at a time as they are rendered?
    Yes
    3) Or, do you want to do some other operation -- separate and apart from the button creation / rendering -- but based upon whether that button exists?
    No
    >
    It seems to me, that the only way you can take some action in a separate process is if you have set some global (i.e., application or page level) item to some value that you will check to determine what action to take.
    No separate process
    >
    Well, one other way. Do you need to know the underlying Oracle tables where button definitions are stored when they are created? Someone may be able to assist with that if that's what we are talking about.
    Before I go that far and create a dependency that goes beyond the APEX APIs I'd rather risk the copy-and-past error. Be aware of the dragons.
    >
    Kind regards,
    Howard
  • 6. Re: Is the "Button Name" available in the PL/SQLfor the "Condition"
    Howard (... in Training) Pro
    Currently Being Moderated
    Okay! It's just what you said ... but it took me a while to see what that meant.

    In fancy talk: You want to know if the button name is exposed at rendering time. Okay. We agree that somewhere a variable holds this value .. but is it available. Well, there are some things known only to experts. This might be one of those.

    My only contribution then is to suggest that you try starting another request worded something like:
    EXPERTS ONLY: Is the button "name" exposed at button rendering time.

    This might attract more expert attention and everyone else will read it to discover what you need an expert for.

    It took me a while to appreciate that this had everything to do with rendering and to quit thinking that it had anything to do with button press time.

    Good luck!
    Howard
  • 7. Re: Is the "Button Name" available in the PL/SQLfor the "Condition"
    fac586 Guru
    Currently Being Moderated
    t-o-b wrote:
    I know that the "Button Name" is available when a page is submitted through a button in the REQUEST.

    Do I have the button name as well available in the "Conditions" section of the button?
    I'm not clear on what you are actually asking.

    1. Access during page show to the button name/<tt>REQUEST</tt> value used in the last page accept?

    OR

    2. Contextual/introspective authorization schemes/conditions that "know" which component they are being evaluated for (like <tt>this</tt> in JavaScript)?

    OR

    3. Something else?
    this does not work as the REQUEST is only submitted into the session, when the page is submitted.
    I need the "Button Name" during the rendering phase, when the Condition is evaluated.
    Note that the <tt>REQUEST</tt> value can be referenced during page show processing if it is set in a branch or URL.

    Obviously this may be useful in case (1) above.
  • 8. Re: Is the "Button Name" available in the PL/SQLfor the "Condition"
    Howard (... in Training) Pro
    Currently Being Moderated
    It took me the longest time to understand he was asking exactly the right question. He needs to evaluate the condition for a button. Easily trivial right! You don't need the name of the button because it's the condition for that button. But if you want the condition evaluating code to be in a called "generic" function then you have to pass the button NAME so it knows what button it's analyzing.

    Doh! Thomas. Can you just hard code the button name -- or whatever you want to pass -- as a literal in the call to the function in the condition block?

    Howard

Legend

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