Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

Entity form custom "Save and Close" button


I have a webpage which includes an Entity Form. I have default submit button for this form but I want to add a new button for "Save and Close" process.

I know that I can go different pages under "On Success Settings" tab. But this works for only default submit button. I need this for custom button.

I can add buttons with JavaScript. But how can I redirect to a custom URL after submitting the form by clicking custom button.

Super User
Super User

Hi @ArifSarikaya , 

 Based on your problem statement, all you need to do is in the Javascript way, once you added the button, then you can simply call the "Onclick" method to redirect to any URL of your choice you want. Posting the example below for your kind reference. 


<button type="button" onclick="document.location=';forceUCI=1&amp;navbar=off&amp;newWindow=true&amp;pagetype=entityrecord&amp;etn=cr63b_employee'" class="btn btn-primary">Primary</button>


Place this under the div or modify according to your need. 


Hope it helps.


If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Hi @ragavanrajan ,

Thank you for your answer. But I don't want to add a button with link. I know how to do it. Actually I want a custom button for submitting the Entity form on portal and after submit, it should redirect to parent page.

There is a default submit button for entity forms. I can set it to redirect to another page. But I need another button for "Save and Close". Sometimes users need just only saving but sometimes they need save and go back. They don't want to make it with two steps. 

How can I add that custom button to the portal?

Solution Sage
Solution Sage

  • Entity Form: Set the Label on the standard submit to Save and Close, Include a checkbox (or dropdown) etc on your form for an I want to submit the form now, when ticked change the text on the button to Submit Now (or reverse it so that the tickbox is for save and submit later), or
  • Web Form:  Use the last step as the Submit (set the status reason on the last step using metadata), the earlier steps are automatically saved.  With JavaScript you can add another button to redirect to a different page if desired, or
  • Web Api: Use the Web Api (still in preview) and it will allow you to create your own data entry form save data with your own custom buttons - use fetchxml to populate your intial data values

Hi @Fubar ,
I could not understand how to make with Entity Form. Can you please explain a bit more?
I was thinking that I can add a new hidden field, for example Yes or No field with label "Save and Close". When I click on "Save and Close" button, this new field will set to "Yes" and save it. After saving, form will load. After load, there will be javascript code for checking if "Save and Close" field set to Yes or No. If Yes, go back to parent URL.

But I need to change the "Save and Close" field to "No" before going back to parent URL. So I need to have submit and change the URL algorithm here again. I could not find a way to do it.

Hi Arif,

yes we can do it using the yes/no field approach. On click of custom button you need to click the oob submit button and a small workflow will run on change of those fields and create of record which will set the field back to no when it is yes.

Which bits do you not understand?

  • On the entity form definition you can change the displayed label of the default button (Submit by default)
  • You add JavaScript (jQuery) to the Entity Form in the spot provided that onchange of the Checkbox/dropdown changes the label on the button
  • You add JavaScript to the Entity Form for when it loads to clear the Yes/No Dropdown

On the CDS/Dataverse side of things, you know when it was submitted as on create or update the checkbox is set Yes and you can use that to change the Status Reason (via a realtime workflow).


It is not clear from the detail you have provided, if there is a need to redirect to 2 different pages e.g. if you are coming off an Entity List then just redirect on submit/save to the List (use the Status Reason to stop people editing something that is Submitted).  Other than the OnSuccess redirect, you can only redirect using JavaScript so what you can also do is OnSuccess redirect to Page X (passing the entity reference/id), and on Page X put some logic and use Javascript redirect to push to the page you want them on.  

For this type of situation, you may find Web Form is a better construct to use, as each Step saves the record, on the last step you just put some text saying submitting this page is the actual submit (and attach a Metadata item to the last Step that changes the Status Reason to Submitted), and then append another button using jQuery that they can click to redirect somewhere else.  - Hit Submit then the records Status Reason is updated, hit the other button redirect to another page (in both cases the data is saved).


Helpful resources

UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (3,853)