I have a form that is sometimes launched directly from the list, and sometimes from a List/Library control in a Dialog.
I have the following code which works when launched directly:
fd.spSaved(function(result) {
result.RedirectUrl = https://mysharepointsite.sharepoint.com/sales/_layouts/15/listform.aspx?PageType=6&ListId=${fd.spFormCtx.ListAttributes.Id}&ID=${result.Id}
;
});
However, when the form is in a Dialog the Dialog just closes.
How do I prevent the Dialog from closing automatically on save?
Hello @sphilson,
And what do you want to do when the from is opened in a dialog and saved? Do you need to redirect a user to the newly created item or open it in a new tab?
In this particular scenario, I have a "New" Form, that upon saving I want to redirect to the Edit Form after they save.
@sphilson,
In this case you can open a new dialog with the edit form when the item is created using the code:
fd.control('SPDataTable1').$on('change', function(changeData) {
if (changeData.type === 'add') {
Dialog.open("https://plumsail.sharepoint.com/sites/SiteName/SitePages/PlumsailForms/ListName/Item/EditForm.aspx?item=" + changeData.itemId, { }, { }, { width: 400, height: 400 });
}
});
Update the URL in the code before using it on the form.
Getting closer
I have the Dialog opening but, something is not loading right.
After launching the Dialog, the Close Button does not work, and it throws an error:
Blockquote
spform.js:51 TypeError: Cannot read property 'map' of undefined
I have removed all of my code on the Dialogs to make sure it is not something I am doing, and there is no change,
One thing I tried was to redirect to the Display form, and the close button throws the error, but the Edit button worked, so I clicked on that, which worked, and the Dialog form went to the Edit version, but then the Save and Close both throw the error. WHen I redirect to teh Edit, neither the Close or Save buttons work
Hello @sphilson,
Yes, I see. Please try out the code below.
fd.control('SPDataTable1').$on('change', function(changeData) {
if (changeData.type === 'add') {
var newItemID = changeData.itemId;
setTimeout(function(){
Dialog.open("https://mycompany.sharepoint.com/sites/mysite/ListName/Item/EditForm.aspx?item=" + newItemID,
{ args: 'something' }, function(hasSaved) {
if(hasSaved){
alert('Form in dialog has saved and closed.');
}
else{
alert('Dialog form was closed without saving!');
}
}, { width: 600, height: 600 });
}, 3000);
}
});
1 Like
This worked. Thank you!!!!!
1 Like