Alert user on successful submission of form data

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
User avatar
WinstonPinto
Posts: 4
Joined: Mon Aug 28, 2017

09 Feb 2018

Hi,

I want to alert the user on successful saving of data in the form and show him the id of the saved item on alert so that he can track the status of it in future.I have searched for this but found code to redirect him to display/edit form but i want to redirect him to custom page.Any help on this regard?

Regards,
Winston.

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

12 Feb 2018

Dear Winston,
You can actually use the same code to redirect users to any page, like this:

Code: Select all

fd.onsubmit(function() {
    var uri = fd.setUrlParam(decodeURIComponent(window.location.href), 'FDRedirectWithID', 'https://domain.sharepoint.com/sites/dev/subsite/SitePages/page.aspx?redirectedID=');
    fd.sourceFormParam(uri);
    return true;
});
This should open the page with the parameter in URL, on the page if it's in SharePoint you can add Script Editor web-part with the following code:

Code: Select all

<script  type="text/javascript">
function getUrlParameter(sParam) {
    var sPageURL = decodeURIComponent(window.location.search.substring(1)),
        sURLVariables = sPageURL.split('&'),
        sParameterName,
        i;

    for (i = 0; i < sURLVariables.length; i++) {
        sParameterName = sURLVariables[i].split('=');

        if (sParameterName[0] === sParam) {
            return sParameterName[1] === undefined ? true : sParameterName[1];
        }
    }
};

alert('Item created! ID is ' + getUrlParameter('redirectedID'));
</script>
Cheers

User avatar
WinstonPinto
Posts: 4
Joined: Mon Aug 28, 2017

19 Feb 2018

Hi,
Thanks for your reply.Let me explain you the problem in detail:

I have a reference number field in the form which is hidden from the user. On submit i want to inform user about the this reference number using alert but the problem is that this alert should be displayed only after the record is saved in sharepoint list.
If the alert message is displayed and the user closes the window data is not saved in the list hence there is no point in showing this reference number without data been saved to list.

Regards,
Winston.

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

19 Feb 2018

Dear Winston,
You have two options here:
1) Either redirect user as described above, that would definitely work. Instead of just redirecting with ID, you can also include value from the hidden field in the URL, then use alert() to show user this value on the next page.
2) You can use JavaScript to check that all conditions for saving are met, that all required field are filled and just before saving an item, show an alert(). This happens before saving an item, but there shouldn't be any issues if you've checked all the required conditions first, unless something happens with the connection, of course, but that's unlikely.
Cheers

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 11 guests