Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Pages - Power Apps Portals
Answered

Text input with custom button in Entity Form

(0) ShareShare
ReportReport
Posted on by 40

Hello, 

 

I'm looking for some advice on how best to set up coupon functionality in Portals. I have a Dataverse table for coupon codes, and basically when a user is goes to complete their registration, they have the opportunity to apply coupons to that registration to reduce the cost (they are allowed to enter more than one coupon)

I thought I could set up a text input, with a custom button beside it to 'verify coupon', which could then use fetch xml, but I'm not sure that will work because A) I don't know if I can add a button right below a field in an entity form, and B) if it is a valid coupon it needs to then add a relationship to that coupon and display it in a subgrid, I'm just not sure it's possible to refresh the session to display the applied coupons. 

If you're a pro out there and you have any suggestions for how to go about adding this functionality please comment. I would really appreciate some help on this.

  • ragavanrajan Profile Picture
    7,036 Most Valuable Professional on at
    Re: Text input with custom button in Entity Form

    Hi @5by5T 

    Adding my two cents here. Even though there is no direct way to refresh the subgrid automatically. If you are planning to use only subgrid ( not SharePoint subgrid) then there is a way. 

     

    In your  page localized >custom javascript 

    $(document).ready(function() {
     console.log(555, "console loading");
     $(".entitylist.entity-grid").on("loaded", function() {
     setInterval(function () {
     $(".view-grid th:first a:first").trigger("click");
     }, 10000);
     });
    });
    
    
    

    Note: you can change the set interval function logic to make a refresh.

     


    Hope it helps. 
    ------------

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

     

     

     

  • 5by5T Profile Picture
    40 on at
    Re: Text input with custom button in Entity Form

    @chleverenz  last I heard it isn't possible to force refresh the subgrid unfortunately. Thank you! Your thoughts have been super helpful and I really appreciate the input. 

  • Christian Leverenz Profile Picture
    1,214 on at
    Re: Text input with custom button in Entity Form

    Hi @5by5T ,

    this is an excellent point. When you make a request over the api, you create or modify data in the dynamics environment. The page will not be reloaded and therefor the subgrid will stay as it is.

     

    I actually do not know, whether there is a method to refresh the subgrid. When you create entries for the subgrid, it is refreshed without page reload. So i assume there is a method but i have no idea, whether ithis one is official.

    Another point on this is, that the web api and the table must not be on the same cache track. It happens frequently to me, that i change data via the webapi and reaload the page and do not see a diffrence, because the tabledata is still assumed to be valid. I thing this is not happening for subgrids as the data will always be read (hopefully). For this i have an easy workaround (but a workaround 🙂 )

     

    You could (but i do not know whether i should recommend this) read the coupondata by your own and render the couponstuff with your own code. Then you do not have this problems at all but loose the standard subgrid stuff.

     

    Hope this helps to sort your or architectural ideas,

      Christian

     

    PS if you know how to refresh the subgrid i would be curious to know 🙂

  • 5by5T Profile Picture
    40 on at
    Re: Text input with custom button in Entity Form

    @chleverenz  Thank you for this! This is a helpful start. 

    My follow up question would be if using the Web API would allow for automatic refresh? If the coupon is valid, I want it to add to the subgrid, but when I have tried this before using HTTP Request with Power Automate, I was able to get a response to the portal, but even though the record was added to the subrid, it didn't show on the screen unless you navigated away and the back again. Does it work differenlty with the Web API to your knowledge?

  • Verified answer
    Christian Leverenz Profile Picture
    1,214 on at
    Re: Text input with custom button in Entity Form

    Hi @5by5T ,

    basically, you store your coupons in a custom table, i suppose. May be, they have a lifetime and box which says, that this coupon was already used or something like that.

     

    You can verify and check the coupons via the web api of portals ( https://docs.microsoft.com/en-us/powerapps/maker/portals/web-api-overview ). This enables you to to everything via javascript. And this already is the problem. If the user checks the traffic he knows, how coupons are treated and could just try out a lot of them via custom clientcode.

    A better approach would be for me to create a new custom table for generating the couponrequests (this table may/should be linked to the table where the coupons are applied to). When a new entry is created in that table you could run a plugin or workflow or whatever to verify the coupon and check the coupon on the new table as valid (or not 🙂 ) and also mark the coupon as used in your coupontable.

    The result of this could be shown in a subgrid of your table. You should setup creation and editing of the coupons because when there was a misspelling in the couponcode, the user should be able to correct it 🙂

     

    So, a lot of text, hopefully it points you in solution direction,

     have fun,

      Christian

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Pages

#1
Lucas001 Profile Picture

Lucas001 60 Super User 2025 Season 1

#2
Fubar Profile Picture

Fubar 55 Super User 2025 Season 1

#3
surya narayanan Profile Picture

surya narayanan 35