Save Wizard on any step without redirection (on new Form)

Dear Plumsail team,

On new record and In order to get a record ID as i need it to continue a wizard step where a sub lists is implemented i tried the following script :

	/*On Step II in Wizard save witout redirection 
	to get ID and complete wizard with sub parent lists
	0 is the index of the first step */
	    fd.container("WizardNewPerson").widget.$on("update:startIndex", function() {
	        if (fd.container("WizardNewPerson").widget.activeTabIndex == 1){
				//Save
					fd.save()
	        	}
	   		 });
			 
			 

	// force form to stop redirection if save is requested on second step
		fd.spSaved(function(res) {
		if (fd.container("WizardNewPerson").widget.activeTabIndex == 1){
				//Save no redirectioon
    			res.RedirectUrl = null;
				}
		});
  • First the script is validating i need to save without validation just on wizard step index(1).
  • Second even if i fill the requested validation rules the form is saving and doing redirection.

So i need to save and get ID without validation and stop redirection when i am on wizard step index(1)

This process is to access Parent/Child sub form lists and create new sub lists records and force it to get the parent form ID unless you have another solution (On New form) kindly share it.

Thank you for your urgent reply.

Dear Georges,

As a workaround, you can redirect to the Edit form, then a record ID will be available.

Dear AlexZever,

What do you mean there is no solution on new record form to get ID without redirection to the edit form???
As my need is to keep user working in wizard mode on new record but on edit mode no wizard process and i will show all the controls possibilities to fill.

Dear Georges,

I’m sorry, I’m not sure I understand what you try to implement :disappointed_relieved: Could you please provide some screenshots so I could take a closer look?

Foregive me for my bad clarification.
I am developing this application in Arabic interface for an Arabic church.
I am afraid if i sent you screenshots you will not understand the contents.

I will try to give you more info as follow:

I am creating forms for a certain list 3 modes:
New, edit and display forms.

  • The New form is a wizard steps form( contains the minimum primary fields for data entry that users must fill with multiple sublist “parent/child lists”).

  • Edit and display form are normal forms no wizard steps availabe and contains the hole list fields.

On the new form wizard:
I need to be sure that the parent list will create or have an ID before entering data in the sub child lists.
To get an ID i need to save without redirection as for the wizard steps are only available in the new form where the end user must continue to the end of the steps.

More explanation:
The new form wizard has 10 steps
the third, 4th and the 5th steps has sub child lists.
When the user press next on the second step
I need to save the form in order to get ID without redirection where user can continue the rests of the wizard steps.
After the user press finish (last wizard step) it will save again and redirect to edit form.

How to save the new form and get ID without redirection to the edit form as for the wizard is only available in the new form.

Hope i gave you the right information.
Thank you again for your patient.

Dear Georges,

Please consider this code:

fd.rendered(function() {        
    window.wizardFlag = false; 
    fd.container("WizardNewPerson").widget.$on("update:startIndex", function() {
        if (fd.container("WizardNewPerson").widget.activeTabIndex == 1){
            wizardFlag = true;
            fd.save();
        }
    })
}) 

fd.spSaved(function(result) {
    if (wizardFlag) {
        console.log(result.Id);
        result.RedirectUrl = null;
    }   
});

Notice that “result.Id” is the ID of the saved item.

Dear AlexZver,
i want to thank you for your precious help.
I couldn’t have time to test this scripts i was focusing on something else.

for the code i tested it with a small correction:

window.wizardFlag = false;
fd.container("WizardNewPerson").widget.$on("update:startIndex", function () {
    if (fd.container("WizardNewPerson").widget.activeTabIndex === 1) {
        wizardFlag = true;
        fd.save();
    }
});

fd.spSaved(function (result) {
    if (wizardFlag) {
        console.log(result.Id);
        result.RedirectUrl = null;
    }
});

it works thanks but how to prevent or disable validation during the save process on the second wizard step only for sure?!
I am using multiple validation codes like:

//Validation marital Status
//fd.field('PersonMaritalStatus').validators;
fd.field('PersonMaritalStatus').validators.push({
    name: 'ValidateMaritalStatus',
    error: '',
    validate: function (value) {
        if (value === 8 || value === null) {
            this.error = 'Select Marital Status';
            return false;
        }
        return true;
    }
});

thank you

Dear Georges,

As a workaround, you can add a condition fd.container("WizardNewPerson").widget.activeTabIndex == 1 to your validators to disable validation if the tabIndex equals 1.

Please notice that you can’t disable the global validation like the Sharepoint required fields but you can turn it off and override it in the custom validators.

it works like a charm… very excited thanks a lot dear AlexZver.

@gkhadra & @AlexZver , I have a similar problem. I have a multi step wizard with some related list and library controls in the 2 step. I'd like to save the form between the first and second step of the wizard so that I can have the ID to wire the related items to the parent as they are created. I know that the list and library control will handle that for you on the new form (after save), but relying on this method can lead to orphaned items (if someone doesn't save the new form).

My problem is that when you invoke the fd.save() action, it nulls out fd.data() which empties all the fields. If the user goes back to change something, the fields are now empty. Anyone figure a way around this yet?

Bottom line, I want folks to enter some basic data on step one, then between step one and two, have the item save. Then in the following steps we can have the ID for association. I have all of this working, but the aforementioned nulling of fd.data(). Any idea on how to address this?

I understand that I can do a complete redirect to the edit form, but the user experience on that is sort of awful...

Dear @C2C,
The issue is the New Form itself - if data is not cleared, each submit will create an identical item. Right now, you need to redirect users to Edit Form, or this will not work as far as I can see.

We might be able to add some adjustments, or give you new tools to work with here - let me know what exactly you need to make this work. We might also be able to offer paid support to improve the API.