The problem I have is that the form seems not to "collect" existing data from the DB if there is a record existing.
When I call my page form (created with the wizard - only change was to make create/update buttons conditional on SQL (Rows returned/not returned, based on value passed in URL), not ITEM, I have the following problem: In "Edit" mode it always fails with an (Oracle) message "No data Found". This is because the form does NOT load data from the table (even if there is a match for the value passed on the URL).
So, the form needs to (1) create a new record if the value passed to it does NOT exist in the table yet. The Primary Key Field in the Table MUST be the value passed on the URL. This is working.
Otherwise the form needs to (1) edit an existing record if the value passed to it exists in the table. This part is where I get the error.
Notes:
(i) in my application the passed value will NEVER be empty. The first call to the form will NEVER expect a record that matched the passed value. IE this call is the ONLY way a record can be created in my table.
Any idea what I might be doing that is so messing me up? I spent 5 hours trying to make this work 🙁
Vinish Kapoor
In this case, you should call your form after the page submits and check the value using the process and call the form using the branch.
For example, when the user will click on the button/link, you submit the page and then check using the process that if the value exists or not. If it exists, then set the value of a hidden page item; else, set it to null.
Now you will have to create two branches to call the same form. One will execute when the hidden page item is not null, meaning call the form in edit mode. And the other one will execute when the page item is null, meaning in the Create mode.
Check the links I shared above to know how to create a branch and the process.
VFP George
Vinish, I must thank you for the clear response and additional instructions on branching and the reasons why to branch.
After much more research I am now clear that (for a record that does not yet exist in the DB) my FORM must NOT receive the PKID directly before the load is processed, but that I must populate it from a hidden field...
... and that the opposite is true if the record does exist in the DB. In this case I MUST populate the PKID field before the load.
All this makes sense so far, and it will work. BUT ...
My page does not "Submit" 🙁
In my case, I am using the gantt chart plug in that I mentioned to another user. This provides me only with the ability to specify a LINK. This calls the regular APEX link builder and provides a variable that contains the ID from the OBJECT in the Gantt that I am clicking on (this is equivalent to my PKID of course).
So, my supplemental question is: How can I set my link to "Drive" a branch process to test for an existing record in the db and then push/not push the PKID accordingly?
OR
Is there any way on the form itself to do the testing for an existing record and then behave appropriately? That way I can simply pass the PKID into the form?
Thanks again, I feel kinda dumb and am most grateful for the assistance.
George
VFP George
PS I learned a LOT of things onmy way to create the gantt for my application. When it is over do you want to host an article from me about how to do this? I would like to contribute this knowledge - it may just help others.
Vinish Kapoor
Sure, George. Go ahead, use the Write a Post button to share a tutorial. Thanks.
VFP George
Thanks Vinish, I will certainly do that. I wondered if you were able to consider the additional concerns I had raised. Right now I still cannot control the entry into the form as I need to, because I have a LINK, not a submit action.
Vinish Kapoor
You can submit through the link as follows. Specify the link type to URL and then specify the URL as javascript:pageSubmit()
Now create the below JavaScript function pageSubmit in the page's JavaScript global variable and function declare section:
VFP George
Hi, Thanks again.
I am not sure though that this will help though. The plug-in exposes a variable that is used to generate the PKID. Not that it matters, but they call it APEX$GANTT_PK. Do you think I can pass this variable on the URL, and have it captured somehow?
George ...
VFP George
Ok, Problem resolved. I was able to include the variable name in the JS Call and then assign the value to a hidden field on the calling page.
Next I used the Branching technique to pass that value to my form if the record exists in the DB. In the other branch I always pass it.
On the form submit I just added a DA to the Create button to capture and copy the PKID to the "Controlling field" so that the record is saved properly.
Now that it is all done it seems way easier than I made it in the first place!
Thanks for the pointer, calling the Submit as JS was the piece that I was completely missing!
Regards,
George ...
Vinish Kapoor
You've got this 👍