Hi All,
I have a button with onClick event that's supposed to navigate me to the page in another form.
I have tried the following code but it does not seem to work
var myform = app.getForm('F_AnotherForm');
myform.selectPage(‘P_SomePageInAnotherForm’);
Am I doing it wrong, or is it something that can even be done? I have no issue navigating to different pages within the same form.
Thanks in advance! :)
The volt documentation (https://help.hcltechsw.com/domino_volt/1.0/ref_jsapi_user_interface_objects.html) says below about app.getForm(formID)
"Returns the user interface form object for the provided formID. If used to return a form that is not shown or loaded, then the object that is returned is not fully operational and should be used for hooking up dynamic event handlers only"
So it says "If used to return a form that is not shown or loaded, then the object that is returned is not fully operational". It seems that it will return null for another FORM but it will return object for the FORM form where we call this code. Looks like it will not work for another form. If you want to access different page in same form, then check if below code helps.
var myform = app.getForm("F_Form1");
var myPage = myform.getPage('P_Page2');
if(myPage !== null) {
myform.selectPage(myPage);
}
Alternatively, for accessing different page in same form, you can also use "Navigation" under Pallete in the App Editor. But it will not work for page in another Form.
If you want to access page in another Form, you can try below.
Use HTML in Pallete and use below sample code on "OnShow" event of HTML to create an anchor tag. Now use some CSS to make this anchor link to appear as a Button. This will open another Form.
var url = "/volt-apps/secure/org/app/" + app.getUID() + "/launch/index.html?form=F_AnotherForm";
<a href='" + url + "' class='css_class' target='_blank' style='text-decoration:none'>Click Here</a>";
Thanks for your detailed reply! I guess I must have missed out the part regarding form which is not shown or loaded. Although I think it should be allowed, since navigating between forms is a common requirement.
And thanks for the advice on using HTML. I managed to create this navigation "button" using Link instead (plus some CSS).
Cheers
Here's a useful example of page and form navigation. It can be done many ways.
page and form navigation