Skip to main content

Notifications

Power Platform Community / Forums / Design & Build / Power Pages Basic form...
Design & Build
Suggested answer

Power Pages Basic forms ("save and create new" button)

Posted on by 4
I have a requirement where a basic form exists and I want to include a list of related records (maybe using liquid code/fetchxml so I have full control of the design?)  that the user can repeatedly add to, e.g. perhaps through an inline or modal form, or redirecting to a second page wiith an insert form.

This "add" form might have a "Save and close", which saves and returns to the previous form, and a "Save and create new" which just saves and stays on the same form but cleared so you can continue to add more records with fewer clicks. But not sure if this functionality is actually possible?

I can see I can do things like redirect to another page on success or stay on the page with a success message and keep the form present (but not empty), but not really seeing the ability to have both types of buttons on the same form.

I'm thinking it might be possible to hook into the save success in some way, and do something clever there with javascript?

I'm also wondering if subgrids are the way forward because they seem to have the ability to create, edit and delete sub  records, but I think I'd lose control of the look and feel of the list if I did this approach? Are there any examples of customised subgrids?

I have a pro code background, so I'm also thinking I could just use complete custom forms if really necessary, but I'm trying to explore other options first.
Categories:
  • Suggested answer
    Fubar Profile Picture
    Fubar 7,458 on at
    Power Pages Basic forms ("save and create new" button)
    You can't properly add in your own Save & New to the existing functionality - the problem is that you can't adequately pickup when the save has completed. 
     
    You will probably need to build it yourself and make use of the portals Web API to Create the record (as you will get a success response back from the create).
     
    Just a couple of other things:
    • The Redirect is only really for when you use the form in a Web Page (not where it is used as a modal popup)
    • People have tried to pickup the success text message on the form (after save) e.g. using a JS mutation observer (or Timer), 
    • Have seen people do things like add their own buttons using JS, then save to local storage, then click/call the out of the box save, then try and pick up the local storage on the other page etc
    • After save, the subgrid on the parent page will reload and has a 'loaded' event. E.g. may be possible to save to local storage on the create form, then pickup on the subgrid loaded and in JS click the subgrids create button (but not a great user experience)
     
    You can apply/override styling on the subgrids or lists, they use Bootstrap for the general layout/responsive design etc and CSS media to style at different screen widths. But you can't really customize them a lot.
     
  • Suggested answer
    SaiRT14 Profile Picture
    SaiRT14 317 on at
    Power Pages Basic forms ("save and create new" button)
    1. Custom Modal or Inline Form with Liquid/FetchXML
    Example
    function saveRecord(action) {
      Xrm.WebApi.createRecord("relatedEntityName", data).then(
        function success(result) {
          if (action === 'close') {
            // Redirect back to main form
          } else if (action === 'new') {
            // Clear form fields for the next entry
          }
        },
        function (error) {
          console.log(error.message);
        }
      );
    }
     
     
    2. Subgrid with Customization
    • Subgrid Layouts: If you want to adjust the design, you could override some styling using JavaScript and CSS, though customization is limited.
    • Form Behavior: You could add custom buttons or scripts that trigger different behaviors (like a custom modal for adding records), but it would still involve some degree of UI control trade-offs compared to a fully custom solution.
    3. Custom Web Resources
    • Build a completely custom HTML form with full control over styling and logic.
    • Use JavaScript to handle interactions with the backend (Dataverse or another API).
    • Implement your own logic for "Save and Close" vs. "Save and Create New."
    Chekcout and let me know.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

September 2024 Newsletter…

September 2024 Community Newsletter…

Community Update Sept 16…

Power Platform Community Update…

Tuesday Tip #2 Global Search…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 142,008

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,531

Leaderboard

Featured topics