Update: 04.Feb.2014
Iudith from ittoolbox suggests, instead of WHEN-NEW-FORM-INSTANCE, PRE-FORM should be used for populating values to PARAMETER elements, thus when the focus is set, the initial values will be set for the columns.
The post will be open for more comments. Cheers!
rajesh
The main advantage of an initial value for a text column is the form status remains NEW, instead of CHANGED & entering the query mode by pressing the F11 key is initiated without throwing errors even if you have mandatory (Required:Yes) property set for one more more columns within the same block.
(Strictly limiting the solution towards custom development for Oracle E-Business Suite, using TEMPLATE.FMB & forms developer 10g)
When a custom module is loaded, 10g run time doesn’t populate values assigned to GLOBAL/PARAMETER variables for the first record. Iudith explains this is default nature of forms load. However, the consequent records are getting the initial values from the GLOBAL/PARAMETER elements.
This time we are providing a workaround solution towards this dreaded situation, which should make a developer’s life bit easier.
Do not assign “First Navigation Block”, instead keep it as <Null>
Open “WHEN-NEW-FORM-INSTANCE” and programmatically send the focus to your first block (in which text columns are assigned with GLOBAL/PARAMETER values as initial values)
Somehow, this method populates the initial values for text columns when the forms is initiated. We believe, such a navigation to the block enforces a WHEN-NEW-RECORD-INSTANCE indirectly and populates all the referred elements.
If you have a better explanation, please forward the same to us.
Hoping to hear from Oracle forms developer guys, we remain
for Windows7bugs
Hello Rajesh,
I don’t exactly understand your problem, but, by the work-around that you are suggesting, I guess that what happened is that
the “First Navigation Block” property having been set,
it maybe caused the form to initially navigate to a *different* block
from the one containing the initial values, and thus, those initial values were *not* assigned.
As we know, initial values are NOT assigned before you navigate to a (NEW) record.
Another possible scenario, though only for a GLOBAL variable
and probably not for a PARAMETER, could be that the respective
GLOBAL value is populated “later” than it being used as source
for the initial value of an item.
For example, if you populate a GLOBAL in a WHEN-NEW-FORM-INSTANCE trigger, then this fires AFTER the new record
was entered and the initial values (maybe empty) assigned to that record’s items.
In such a case, we usually performed a CLEAR_RECORD;
as the last step of the WHN-NEW-FORM-INSTANCE trigger,
after populating the GLOBALS, and then a new record is created
with the correct initial values in place.
I have not encountered this problem, or maybe something in my understanding of your scenario is not correct.
Thanks a lot for sharing this & Best Regards,
Iudith
Hello Iudith
Nice to see an immediate and lengthy explanation from one of geeks :) Well, apparently, this issue was discussed just “few” times over the forums, and the newest I could locate dates back to 2012!
Unfortunately, there are no other navigations happening during the forms load. With the first navigation block property set, the focus is automatically on the block specified and we had this issue with forms 10g from the beginning. As I mentioned with the POST, we are developing 10g applications only for Oracle E-Business Suite, however have decided to checkout forms 10g by developer a fresh form, without copying from the TEMPLATE.fmb
Please give me a day or two, I will do an extensive research on the same and confirm whether this behavior is as you have explained. I do believe the opposite because forms 6i does populate the value during the initial load itself and I conducted multiple tests on both developers prior posting.
regards,
rajesh
Hello Rajesh,
I would just add that in the meantime, out of curiosity, I performed
a very small test, creating a form which has one block, with
two items, as follows:
1. one item having the initial value set to a GLOBAL variable
that is populated in the PRE-FORM trigger ( usually this is done
by another calling or setup form ).
2. another item having the initial value set to a PARAMETER defined in the same form ( with a default value set for the parameter ).
Also, I set the “First Navigation Block” explicitly to the (single)
block in my form.
I executed the form (as part of my web deployed ) application,
and encountered no problems, both initial values were populated as expected.
I would just add that, if instead of populating the GLOBAL variable
in a PRE-FORM trigger, I was doing the same in the WHEN-NEW-FORM-INSTANCE trigger, then I got an error when trying to open the form, saying that the GLOBAL variable does not exist,
and the form does not open at all.
This is expected, because the initial values are populated
as part of the navigation sequence, when entering the block and thus creating a new record, while the WHEN-NEW-FORM-INSTANCE only fires *after* this navigation sequence is completed.
So, if not setting the GLOBAL in a calling form, then it should
be set in the PRE-FORM (or PRE-BLOCK or PRE-RECORD),
anyway, in a trigger that fires *before* the process of creating a new record attempts to use those values.
Just for your information … I will of course wait curiously on any of your further findings on this topic.
Thanks a lot & Best Regards,
Iudith
Hello Iudith
I just created a virtual machine to confirm the claim I made earlier. With developer suite 6i, you can assign a value (static or select statement) to a :PARAMETER.xyz element using the WHEN-NEW-FORM-INSTANCE and assign the PARAMETER to a text column and the value gets populated (Confirmed)
The same approach doesn’t work with Developer 10g Forms [32 Bit] Version 10.1.2.3.0 (Production)
I will check the possibility of assigning the values using PRE-FORM and confirm whether such provides the same functionality
regards,
rajesh
Hello Iudith
The test form populated the values while assigned through PRE-FORM trigger. I will check the same against ERP environment and confirm the earliest. Thank you very much for the pointers.
regards,
rajesh
Hello Rajesh,
I am not aware of any different behavior of Forms6i and Forms10g,
and even older versions regarding this issue.
Across all the versions, the WHEN-NEW-FORM-INSTANCE
( or KEY-STARTUP in versions 3.0 and lower ) always fired
AFTER the form is entered, just before the control is passed to the user, so it is “too late” to populate in this trigger variables that are used as source for initial values ( in older versions these could only be other form items, not GLOBAL or PARAMETER values,
but the behavior was still the same ).
I also performed a test in both Forms6i (client/server)
and in Forms10g, with adding a WHEN-NEW-FORM-INSTANCE
trigger that sets a value for the parameter (overriding its default value defined in the parameter properties),
and the behavior is still the same in the two versions,
namely:
1. the first new record gets its initial value from the PARAMETER-s default value, because this initialization happens BEFORE the WHEN-NEW-FORM-INSTANCE trigger is fired.
2. if I fill that first record and then navigate to another new record in the block, this second new record gets is initial value from the
newly assigned value in the WHEN-NEW-FORM-INSTANCE,
because this is the value of the PARAMETER when this second record is created and its items initial values are assigned.
So, the behavior I see is still the same one as I knew it across
ALL the versions.
Thanks a lot & Best Regards,
Iudith
Hello Iudith
Morning :) I’m still working on the same topic. I have installed 6i (hacked) once again and testing the scenarios. I had another post about PARAMETER elements here
http://windows7bugs.wordpress.com/2012/11/17/oracle-developer-10g-developer-6i-default-values-for-columns-using-parameter-name/
I will check those forms once again, I can’t recall using clear_record or any other methods, at the same not sure whether I used the PARAMETER VALUES as initial values.
Meanwhile I confirm, you are absolutely correct. Instead of WHEN-NEW-FORM-INSTANCE, PRE-FORM should be used to populate the PARAMETER elements values.
Thanks once again Iudith, as I always said, you never stop amazing me.
regards,
rajesh
Hello,
Excellent it worked perfect!!, I just set as initial value a global variable (:global.audit_year) in the display item. Then in the pre-form i set the dynamic value:
…
SELECT max(audit_year) into :global.audit_year
…
And that’s it.
Thanks a great article.