Page 1 of 2

open other forms after saving

Posted: Fri Oct 12, 2018 7:03 am
by marc
Guys, the following scenario:
I'm trying to create some kind of wizard, similar to what you can see on Google Forms. You open a form and depending on which selection you made, another form is opened.
I searched the wiki and forum and came across a function called nuReturnNewRecord. This is almost what I'm looking for. The only piece of the puzzle missing is to be able to specify a form to be opened.

I have in mind a function that can accept a second parameter (form id)

nuReturnNewRecord("-1";"4a5172732c4ae31");

@param1: record id (-1 or empty => open blank record)
@param2: form id (if not specified, open same form)

For a better understanding I created a small diagram
diagram.png

Re: open other forms after saving

Posted: Fri Oct 12, 2018 7:59 am
by admin

Re: open other forms after saving

Posted: Fri Oct 12, 2018 8:19 am
by marc
Where would I add it? The other form should be opened immediately after saving, without user interaction.

Re: open other forms after saving

Posted: Sat Oct 13, 2018 11:43 pm
by admin
marc,

You'll need to put something like this in the Javascript section of the Form to redirect it once the Form has been saved.

eg.

Code: Select all

if(nuHasBeenSaved() == 1){

   if($('#question1').val() == 1){
      nuForm("4a5172732c4ae31", '-1');     //--  redirect to this Form.
   }else{
      nuForm("4a5172732c4ae66", '-1');     //--  redirect to this Form.
   }

}


Steven

Re: open other forms after saving

Posted: Wed Oct 17, 2018 8:39 am
by marc
This works very well in most cases. After intensive testing it turned out that the function nuHasBeenSaved sometimes returns a 1 even though the form was not saved.
After rearranging objects or refreshing the form (via the Options menu) nuHasBeenSaved obvisouly a wrong result. Can you look into it? Thank you in advance!

Re: open other forms after saving

Posted: Wed Oct 17, 2018 10:54 pm
by admin
marc,

Can you explain how to reproduce that error?

Steven

Re: open other forms after saving

Posted: Fri Oct 19, 2018 1:47 am
by marc
So I added the code to my form. I open it, use Arrange Objects from the option menu, hit save in the dialog.
Then nuHasBeenSaved() returns 1 and another form is opened with nuForm(.....). This behavior is not correct because the form has not yet been saved.

Re: open other forms after saving

Posted: Fri Oct 19, 2018 2:30 am
by admin
marc,

If this doesn't work you could set and increment a global variable as you move through your different choices eg. window.myVariable


Steven

Re: open other forms after saving

Posted: Sat Oct 27, 2018 12:16 pm
by marc
admin wrote:marc,

If this doesn't work you could set and increment a global variable as you move through your different choices eg. window.myVariable


Steven
Steven, could you explain in more detail how this would work and where do I have to declare the variable and where do I increment it?

Actually, I just need a reliable way to discover when a record has just been saved. I also searched the forum and found many posts describing the same issue. But there seems to be no solution.

Re: open other forms after saving

Posted: Mon Oct 29, 2018 3:32 am
by admin
marc,

I'm still trying to understand the things you did to make nuHasBeenSaved() not work.


Is this right...

1. So I added the code to my form.
2. I open it.
3. Use Arrange Objects from the option menu.
4. Hit save in the dialog.


I don't understand Use Arrange Objects.

I thought you were editing and saving records when the problem happened.


Steven