question

Shri-6058 avatar image
0 Votes"
Shri-6058 asked Shri-6058 answered

SP List click new item Finish, read field value 'yes' to launch NewItem.aspx 'no' to Thank you.aspx

Hello,

I was trying this functionality in InfoPath and it was very easy to redirect based on value. I was asked to use the out of the box list Survey with 10 questions. The last question will be Want to add more? Yes/No, If value is Yes, I need to launch the same Survey newitem.aspx page. If no, redirect ThankYou.aspx page. Can you suggest some light?

I thought I can do it via Sharepoint workflow but its not smooth. I thought there may be a Javascript to handle upon 'Finish' to call one or the other aspx page. Any thoughts?

office-sharepoint-onlineoffice-sharepoint-server-developmentoffice-sharepoint-server-itpro
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

What's version of your SharePoint?And is NewItem.aspx a custom page ?

0 Votes 0 ·

Thank you for the response.
ISharePoint 2013 with latest SPs and security updated. The NewItem.aspx is out of the box page and dont want to create custom as there are tons of styles, formatting I already did.

Also, I tried with Javascript PreSaveAction() but the item not at all saving if I include launch NewItem.aspx moreover PreSaveAction() can be used only to show Thank you message. We have to return true to submit the page I beleive.
Please advise.

0 Votes 0 ·

Hi @ShridharHegde-2034,
How's going today?
Do you have further concerns regarding this issue?

0 Votes 0 ·
AmosWu-MSFT avatar image
0 Votes"
AmosWu-MSFT answered AmosWu-MSFT edited

You could use SharePoint Designer to add two new Finish buttons to newForm.aspx.
Detailed steps:https://sharepoint.stackexchange.com/questions/227917/sharepoint-2013-ootb-survey-redirect
In order to distinguish the two buttons, I used different names.
26026-image.png

Code for your reference:button-code.txt
Then we could display different finish buttons according to the selection status of the Want to add more question.
26015-test46.gif
Change button code for your reference:code.txt
-------------------------------------Updated---------------------------------------
Code to change Finsh button redirect page:28672-code.txt



If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



image.png (25.8 KiB)
test46.gif (19.4 KiB)
code.txt (903 B)
code.txt (596 B)
code.txt (550 B)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Shri-6058 avatar image
0 Votes"
Shri-6058 answered AmosWu-MSFT commented

Thank you so much. For some reason, the GenFireServerEvent __commit __redirect Newform does not fire. The error says its not defined.

Also, I was trying this in script editor instead of SharePoint designer. I was able to hide out of the box finish button but added custom button however I cant submit and launch newform.aspx

Also, I went through the reference and tried using eventListner but nothing fires(or no errors) for document.addEventListener Is there a specific feature needs to be enabled?

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

The button code is automatically generated by SharePoint designer. We need to set SharePoint action when we add SharePoint Form action button("Commit" and "Navigate to Page").
27831-image.png
And set the target page in Navigate to Page setting.
You could following the steps in the link which I share you to create two new finish button.
Tip: Remember to ensure that the element attribute is the same as the attribute used in the code.


0 Votes 0 ·
image.png (15.3 KiB)
Shri-6058 avatar image
0 Votes"
Shri-6058 answered AmosWu-MSFT commented

Uncaught ReferenceError: GenFireServerEvent is not defined

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

The button code is used in SharePoint Designer. SharePoint will compile the form page code in SharePoint designer, and the rendered page is the newform you see.Do not add the button code to script editor at the newForm page.
27823-image.png
27891-image.png
After you delete the old button and create the new button, add the change button code to the script editor.

0 Votes 0 ·
image.png (83.0 KiB)
image.png (69.9 KiB)
Shri-6058 avatar image
0 Votes"
Shri-6058 answered

The instructions provided in the link has a design view, code view with SharePoint 2013 5 years ago. SharePoint Designer design view no longer exist. If I delete existing button from code, and place the cursor within the td and try to insert form action button but no action result or popup appear. The code still shows no button code inserted, strange. It looks like no longer supported.

Is there a way to achieve this in Jquery Javascript? I know that we can hide out of the box buttons on the UI page and add custom Submit Cancel buttons.


Actually I have two source urls which is also working fine. Your method of adding two buttons to show according to the radio button selection might work just that I dont know how to hookup the url upon upon 'Finish' button and making sure that it submits the custom url.

List Survey Newform.aspx?source=Thankyou.aspx
List Survey Newform.aspx?source=NewFform.aspx

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Shri-6058 avatar image
0 Votes"
Shri-6058 answered AmosWu-MSFT edited

I cant change the existing structure. There are lots of automation already done and my company asked me to stick with the approach and do not create custom NewForm.aspx. The way I want to achieve is with Existing out of the box NewForm.aspx page. There must be a way to achieve this using Jquery or Javascript but some reason lot of options provided including presaveaction() doesnt work. I tried the SharePointdiary.com Javascript/Jquery approach and its no firing at all.

I can hide both existing UI Finish and Cancel and then I can add custom buttons using script editor. I thought, I can call Commit and then redirect options. Its not working. please advise.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

You do not need to create a newForm,you could modify the native new form.
I have tested all the methods you mentioned, but none of them succeeded.I will keep working on this issue.

0 Votes 0 ·

As a workaround,we could change the Finish button redirect page to ThankYou page with js,and ask thw user if he/she want to response the survey again.If he/she choose yes,then we could redirect he/she to the new form page.I will post the code in my first answer,you could get it in the updated information.

0 Votes 0 ·
Shri-6058 avatar image
0 Votes"
Shri-6058 answered

Thank you again. Both scripting for redirect and enable/disable button helped me.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.