This discussion is archived
7 Replies Latest reply: Feb 5, 2013 6:29 AM by 989068 RSS

Ensure entry is uppercase master-detail form

989068 Newbie
Currently Being Moderated
Hello all,

I'm playing around with APEX version 4.0.2.00.09 and have created a standard Master-Detail Form using the built-in wizard. My database has a constraint that ensures all data entered must be in uppercase, but the detail section allows text to be entered in lowercase. In the image linked below, you'll note that description has an entry in lowercase so when this is inserted into the database it returns that the uppercase constraint has been violated. Is there a way to have some javascript (or other trickery) linked to this textbox to force the data to uppercase as the user types in it?

I noticed that a lot of websites mention adding some javascript to "HTML Form Element Attributes", but I do not have this section when editing the projects detail.


http://imageupload.co.uk/viewer.php?file=yu7i83h5dpk5cy0npsy0.png
  • 1. Re: Ensure entry is uppercase master-detail form
    munky Guru
    Currently Being Moderated
    Hi

    No need to do that, just create a computation that does an UPPER() on the item value before submission.

    Cheers

    Ben
  • 2. Re: Ensure entry is uppercase master-detail form
    Tom Petrus Expert
    Currently Being Moderated
    Javascript: since you're on version 4.0 you have dynamic actions.
    Define a dynamic action
    <ul>
    <li>Event: Change</li>
    <li>Selection Type: jQuery Selector</li>
    <li>jQuery Selector:
    td[headers='DESCRIPTION'] input:visible
    </li>
    <li>Condition: no condition</li>
    <li>
    <ul>
    True action: Set Value
    <li>Fire on Page Load: No</li>
    <li>Set Type: Javascript Expression</li>
    <li>Javascript Expression:
    $(this.triggeringElement).val().toUpperCase()
    </li>
    <li>Suppress Change Event: Yes</li>
    <li>Affected Elements:
    Selection Type: Triggering Element</li>
    </ul>
    </li>
    </ul>
    This will change the characters to all uppercase when the textbox loses focus and the value changed. (ex tabbing away, clicking somewhere else) If you want this to happen as en entry is made you can use the "Key Release" event, but realise that this has the annoying behaviour of setting the cursor to the end of the string. No issue when adding, but annoying when making an edit to an entry (ex deleting one character mid-string will set the cursor to the end of the string).

    You could also add a serverside validation (or computation), but here you will need to loop over the apex_application.g_f## array associated with your column you wish to validate. Easier validations are only added in version 4.1 (no computation though). There is also no "Post Calculation Computation" on a tabular form element like there is on a page item. (which Munky probably refers to?)

    Edited by: Tom on Feb 5, 2013 12:43 PM
  • 3. Re: Ensure entry is uppercase master-detail form
    989068 Newbie
    Currently Being Moderated
    I'm sorry, I'm very new to APEX and I do not understand what you mean. Could you be so kind to clarify how to create computation?

    Thanks for your time.

    Edited by: 986065 on Feb 5, 2013 3:52 AM
  • 4. Re: Ensure entry is uppercase master-detail form
    989068 Newbie
    Currently Being Moderated
    Tom,

    I right clicked on the "project details" section and clicked "create dynamic action", I then chose the "advanced" option, I followed your steps but I appear to be missing some of the last few steps using this method:

    Suppress Change Event: Yes
    Affected Elements:
    Selection Type: Triggering Element

    I only have a selection box that allows me to set it to "triggering event" but I do not have an option to "Suppress Change Event". Setting this and running the application is still not auto-uppercasing the text, even if I change the event type to, say, "key release".

    I really appreciate your time.
  • 5. Re: Ensure entry is uppercase master-detail form
    Tom Petrus Expert
    Currently Being Moderated
    986065 wrote:
    I right clicked on the "project details" section and clicked "create dynamic action", I then chose the "advanced" option, I followed your steps but I appear to be missing some of the last few steps using this method:

    Suppress Change Event: Yes
    Affected Elements:
    Selection Type: Triggering Element

    I only have a selection box that allows me to set it to "triggering event" but I do not have an option to "Suppress Change Event". Setting this and running the application is still not auto-uppercasing the text, even if I change the event type to, say, "key release".
    Wish i had access to a 4.0 instance, but right now i only have 4.1.0 and up. It could very well be that from 4.0 to 4.1 there were some additions made, but i can't recall those differences anymore. I'll try and help as good as i can:
    Your dynamic action itself is set to the jQuery selector, right? (and not the "project details" region)
    The "Suppress Change Event" is a select item in the "Settings" of the true action. If you don't have it, don't worry about it. In 4.1 setting this to "No" would cause an infinite loop of change events firing (but setting a value through javascript/jQuery does not fire a change event, so firing a change event when you set a value with a dynamic action is a part of the apex framework. I take it that if it isn't there then there are no change events firing).
    Can you select "Triggering Element" in the "Affected Elements" region of the true action? If not, what options do you have?
    Do you see javascript errors when running your page?
    (What browser do you use or can you use? Having firefox+firebug or chrome with the developer tools are both great tools which help a lot in debugging javascript, and either would readily show if there are errors.)
  • 6. Re: Ensure entry is uppercase master-detail form
    603257 Journeyer
    Currently Being Moderated
    Have you considered the easy option of just using a trigger on the table to set the required field to uppercase? That is the most "strict" way because it ensures that no data can ever get in your table which isn't in uppercase, unlike a client-side solution such as Javascript.
  • 7. Re: Ensure entry is uppercase master-detail form
    989068 Newbie
    Currently Being Moderated
    After going through these steps again, this worked.

    Thank you so much for your help, I really appreciate it.

Legend

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