web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / How do I create new bu...
Power Pages
Unanswered

How do I create new buttons for a basc form?

(0) ShareShare
ReportReport
Posted on by 26

Hello community!


I need to add additional buttons to my basic form to meet my customers' needs.

How can I create new buttons and add them to my form?

 

oussouss_0-1697185816795.png

 

Categories:
I have the same question (0)
  • Saud Ali Profile Picture
    812 Super User 2024 Season 1 on at

    Hi @oussouss ,

     

    If you want to create custom buttons in Power Portals that perform actions beyond what the built-in action buttons offer, you can achieve this by using JavaScript or Liquid Templates. Here are the steps to do:

     

    • Navigate to your Power Portal Management App.
    • Inside the App, navigate to the page where you want to add the custom button. This might be a Web Page or a Web Template, depending on your portal setup.
    • To create a custom button, you can add HTML and JavaScript code to your Page.
    <button id="customButton">Custom Action</button>
    

     

    • You'll need to add JavaScript to handle what happens when the button is clicked. You can do this by either embedding the script directly within the page (if it's a simple action) or by referencing an external JavaScript file.
    <script>
     document.getElementById("customButton").addEventListener("click", function () {
     // Add your custom action here
     // For example, navigate to a different page or perform a specific action.
     });
    </script>
    
    • Save your changes, visit your Power Portal and navigate to the page where you added the custom button. Test to ensure that the button performs the desired custom action.

     

    Thanks,

    Saud

     

    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.

     

  • domliu37 Profile Picture
    314 Super User 2024 Season 1 on at

    Hi @oussouss ,

     

    I'm not exactly sure where you want to add the new custom buttons, but I usually create buttons using custom JavaScript. Here's an example:

     

    var button = `<button type="button" id = "customId" class="btn-custom btn btn-default" onclick="customFunction()">my custom button</button>`

     

    When creating a custom button, I typically add a unique ID and my custom CSS class, and then use JavaScript to define the method triggered on click, for example, customFunction.

     

    Finally, depending on where you'd like to place the button on the form, simply use the jQuery append method (or a similar method) to position the button.

    --------------

    If you found this post helpful, consider clicking the thumbs-up button. If it solved your issue, mark it as a solution so that others can easily find it.

     

    Cheers,
    Dom

  • oussouss Profile Picture
    26 on at

    Hello

    @saudali_25   @domliu   thank your for your retrurn

     

    can you help me and grant me a full code , since i am a power pages Maker not a Pro-devlopper

     

    So the idea is to create 2 more buttons on From ( like mentionned on my first Post ) to allow an portal user to change status of a case from the form

    for exemple in Screenshot, the 1st button for make the case's status to "in progress", the 2nd button to make the case's status on "resolved"

     

     

    Note:: i use custom Case's status , so thos defaults button can not be useful for my needs

     

    oussouss_0-1697462734060.png

     

     

     

    Thanks; 
    Oussama

     

  • Anwarluck Profile Picture
    113 on at

    Hi @oussouss, you can add button as suggested by @domliu and @saudali_25. I will try to provide the javascript functions. 

     

    1. Add button to the form directly or using JavaScript.

    <button type="button" id = "InProgressStatus" class="btn-custom btn btn-default" onclick="UpdateCase('In-Progress')">In-Progress</button>
    <button type="button" id = "ResolvedStatus" class="btn-custom btn btn-default" onclick="UpdateCase('Resolved')">Resolved</button>

    2. Add the webapi helper functions along with our custom function to the form. 

    $(function () {
    	// #region Webapi methods
    
    	// Web API ajax wrapper
    	(function (webapi, $) {
    		function safeAjax(ajaxOptions) {
    			var deferredAjax = $.Deferred();
    			shell
    				.getTokenDeferred()
    				.done(function (token) {
    					// Add headers for ajax
    					if (!ajaxOptions.headers) {
    						$.extend(ajaxOptions, {
    							headers: {
    								__RequestVerificationToken: token
    							}
    						});
    					} else {
    						ajaxOptions.headers["__RequestVerificationToken"] = token;
    					}
    					$.ajax(ajaxOptions)
    						.done(function (data, textStatus, jqXHR) {
    							validateLoginSession(data, textStatus, jqXHR, deferredAjax.resolve);
    						})
    						.fail(deferredAjax.reject); // ajax
    				})
    				.fail(function () {
    					deferredAjax.rejectWith(this, arguments); // On token failure pass the token ajax and args
    				});
    			return deferredAjax.promise();
    		}
    		webapi.safeAjax = safeAjax;
    	})((window.webapi = window.webapi || {}), jQuery);
    
    	// Notification component
    	var notificationMsg = (function () {
    		var $processingMsgEl = $("#processingMsg"),
    			_msg = "Processing...",
    			_stack = 0,
    			_endTimeout;
    		return {
    			show: function (msg) {
    				$processingMsgEl.text(msg || _msg);
    				if (_stack === 0) {
    					clearTimeout(_endTimeout);
    					$processingMsgEl.show();
    				}
    				_stack++;
    			},
    			hide: function () {
    				_stack--;
    				if (_stack <= 0) {
    					_stack = 0;
    					clearTimeout(_endTimeout);
    					_endTimeout = setTimeout(function () {
    						$processingMsgEl.hide();
    					}, 500);
    				}
    			}
    		};
    	})();
    
    	// Applicaton ajax wrapper
    	function appAjax(processingMsg, ajaxOptions) {
    		notificationMsg.show(processingMsg);
    		return webapi
    			.safeAjax(ajaxOptions)
    			.fail(function (response) {
    				if (response.responseJSON) {
    					alert("Error: " + response.responseJSON.error.message);
    				} else {
    					alert("Error: Web API is not available... ");
    				}
    			})
    			.always(notificationMsg.hide);
    	}
    	function updateRecord(recordObj, recordObjId) {
    		appAjax("Updating...", {
    			type: "PATCH",
    			url: `/_api/incidents(${recordObjId})`,
    			contentType: "application/json",
    			data: JSON.stringify(recordObj),
    			success: function (res) {}
    		});
    	}
    
    	
    });
    
    function UpdateCase(status) {
    	const incidentid = "{{request.params.id}}";
    
    	let data = {};
    
    	if (status == "In-Progress") {
    		data = { statecode: ChangeItAccordingly, statuscode: ChangeItAccordingly };
    	} else if (status == "Resolved") {
    		data = { statecode: ChangeItAccordingly, statuscode: ChangeItAccordingly };
    	}
    
    	updateRecord(data, incidentid);
    }

    3. Make sure to add the table that you're updating to the site settings.

    anwarluck_0-1697521344253.png

     

     

    Please let me know if you have any questions.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
DP_Prabh Profile Picture

DP_Prabh 51

#2
rezarizvii Profile Picture

rezarizvii 35

#3
oliver.rodrigues Profile Picture

oliver.rodrigues 33 Most Valuable Professional

Last 30 days Overall leaderboard