{"id":44594,"date":"2026-05-14T16:40:55","date_gmt":"2026-05-14T11:10:55","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=44594"},"modified":"2026-05-14T16:40:55","modified_gmt":"2026-05-14T11:10:55","slug":"accelerate-power-pages-development-using-server-logic-part-2","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2026\/05\/accelerate-power-pages-development-using-server-logic-part-2\/","title":{"rendered":"Accelerate Power Pages Development Using Server Logic: Part 2"},"content":{"rendered":"<p><img decoding=\"async\" class=\"alignnone size-full wp-image-44598\" style=\"border: 1px solid #000000; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/05\/Accelerate-Power-Pages-Development-Using-Server-Logic-Part-2.png\" alt=\"Accelerate Power Pages\" width=\"2100\" height=\"1200\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/05\/Accelerate-Power-Pages-Development-Using-Server-Logic-Part-2.png 2100w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/05\/Accelerate-Power-Pages-Development-Using-Server-Logic-Part-2-300x171.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/05\/Accelerate-Power-Pages-Development-Using-Server-Logic-Part-2-1024x585.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/05\/Accelerate-Power-Pages-Development-Using-Server-Logic-Part-2-768x439.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/05\/Accelerate-Power-Pages-Development-Using-Server-Logic-Part-2-1536x878.png 1536w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/05\/Accelerate-Power-Pages-Development-Using-Server-Logic-Part-2-2048x1170.png 2048w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/05\/Accelerate-Power-Pages-Development-Using-Server-Logic-Part-2-660x377.png 660w\" sizes=\"(max-width: 2100px) 100vw, 2100px\" \/>In the previous <a href=\"https:\/\/www.inogic.com\/blog\/2025\/11\/how-to-accelerate-power-pages-development-using-server-logic\/\" target=\"_blank\" rel=\"noopener\">blog<\/a>, the &#8220;what&#8221; and &#8220;why&#8221; of <strong>Server Logic<\/strong> were explored. This entry takes the concept further by demonstrating the implementation of a full <strong>CRUD (Create, Read, Update, Delete)<\/strong> interface that communicates with an external OData service.<\/p>\n<p>The goal here is simple: move the &#8220;heavy lifting&#8221; to the server so your frontend stays clean and API calls stay secure.<\/p>\n<h3>Prerequisites:<\/h3>\n<p>Before beginning, ensure the following are available:<\/p>\n<ul>\n<li>An active <strong>Microsoft Dataverse<\/strong><\/li>\n<li>A valid <strong>Power Pages license<\/strong> and access to a Power Pages site.<\/li>\n<\/ul>\n<h3><strong>Getting Started<\/strong><\/h3>\n<ol>\n<li><strong>Open Power Pages<\/strong> and select your desired <strong>environment<\/strong> and <strong>site<\/strong>.<\/li>\n<li>Navigate to <strong>Setup \u2192 Server logic (Preview)<\/strong>.<\/li>\n<\/ol>\n<p style=\"padding-left: 40px;\"><img decoding=\"async\" class=\"alignnone size-full wp-image-44597\" style=\"border: 1px solid #000000; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/05\/Accelerate-Power-Pages.jpg\" alt=\"Accelerate Power Pages\" width=\"1431\" height=\"581\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/05\/Accelerate-Power-Pages.jpg 1431w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/05\/Accelerate-Power-Pages-300x122.jpg 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/05\/Accelerate-Power-Pages-1024x416.jpg 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/05\/Accelerate-Power-Pages-768x312.jpg 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/05\/Accelerate-Power-Pages-660x268.jpg 660w\" sizes=\"(max-width: 1431px) 100vw, 1431px\" \/><\/p>\n<p>Using the built-in Visual Studio Code editor, you can define your standard HTTP methods.<\/p>\n<p>The beauty of this approach is that you don&#8217;t need separate scripts for every action; everything is handled within the get(), post(), put(), and del() functions.<\/p>\n<blockquote><p><em><u>Note:<\/u><\/em><u> Server Logic assigned to a higher web role won\u2019t be accessible to lower roles.<\/u><\/p><\/blockquote>\n<h3><strong>Authoring Server Logic<\/strong><\/h3>\n<p>Below is a look at how the get() and del() methods appear inside the Server Logic file using the HttpClient object:<\/p>\n<pre class=\"lang:css gutter:true start:1\">JavaScript\r\n\r\nconst baseUrl = \"https:\/\/services.odata.org\/TripPinRESTierService\";\r\n\r\n\u00a0\r\n\r\nasync function get() {\r\n\r\ntry {\r\n\r\nServer.Logger.Log(\"GET called\");\r\n\r\nconst id = Server.Context.QueryParameters[\"username\"];\r\n\r\n\/\/ If username exists, fetch specific; else fetch all\r\n\r\nconst url = id ? `${baseUrl}(${id})\/People` : `${baseUrl}\/People`;\r\n\r\nreturn await Server.Connector.HttpClient.GetAsync(url, {'content-type':'application\/json'});\r\n\r\n} catch (err) {\r\n\r\nServer.Logger.Error(\"GET failed: \" + err.message);\r\n\r\n}\r\n\r\n}\r\n\r\n\u00a0\r\n\r\nasync function del() {\r\n\r\nServer.Logger.Log(\"DEL called\");\r\n\r\nconst username = Server.Context.QueryParameters[\"username\"];\r\n\r\nconst url = `${baseUrl}\/People('${username}')`;\r\n\r\nreturn await Server.Connector.HttpClient.DeleteAsync(url, {'content-type':'application\/json'});\r\n\r\n}\r\n\r\n}<\/pre>\n<h3><strong>Building the Interactive Frontend<\/strong><\/h3>\n<p>Once the server-side logic is prepared, add a page in the <strong>Pages<\/strong> workspace.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-44595\" style=\"border: 1px solid #000000; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/05\/Accelerate-Power-Pages-1.jpg\" alt=\"Accelerate Power Pages\" width=\"1428\" height=\"646\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/05\/Accelerate-Power-Pages-1.jpg 1428w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/05\/Accelerate-Power-Pages-1-300x136.jpg 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/05\/Accelerate-Power-Pages-1-1024x463.jpg 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/05\/Accelerate-Power-Pages-1-768x347.jpg 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/05\/Accelerate-Power-Pages-1-660x299.jpg 660w\" sizes=\"(max-width: 1428px) 100vw, 1428px\" \/><\/p>\n<p>jQuery and the webapi.safeAjax wrapper are utilized to interact with the new endpoint at <em>\/_api\/serverlogics\/services.odata.org<\/em>.<\/p>\n<blockquote><p><strong><u>Note:<\/u><\/strong> <u>services.odata.org<\/u><u> refers to the internal name of the Server Logic component.<\/u><\/p><\/blockquote>\n<p><strong>Sample Code Link:<\/strong> <a href=\"https:\/\/learn.microsoft.com\/en-gb\/power-pages\/configure\/server-logic-external-services\" target=\"_blank\" rel=\"noopener\"><em>https:\/\/learn.microsoft.com\/en-gb\/power-pages\/configure\/server-logic-external-services<\/em><\/a><\/p>\n<p>Create a Contact with the required role, log in to the site, and navigate to the page. Below is how it will look.<\/p>\n<h3><img decoding=\"async\" class=\"alignnone size-full wp-image-44596\" style=\"border: 1px solid #000000; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/05\/Accelerate-Power-Pages-2.jpg\" alt=\"Accelerate Power Pages\" width=\"1427\" height=\"544\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/05\/Accelerate-Power-Pages-2.jpg 1427w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/05\/Accelerate-Power-Pages-2-300x114.jpg 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/05\/Accelerate-Power-Pages-2-1024x390.jpg 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/05\/Accelerate-Power-Pages-2-768x293.jpg 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/05\/Accelerate-Power-Pages-2-660x252.jpg 660w\" sizes=\"(max-width: 1427px) 100vw, 1427px\" \/><\/h3>\n<h3><strong>What the UI does:<\/strong><\/h3>\n<ul>\n<li><strong>Read<\/strong>: Automatically loads data into a responsive table on page load.<\/li>\n<li><strong>Create<\/strong>: A &#x2795; button generates a new record and sends a POST<\/li>\n<li><strong>Update<\/strong>: Double-click any row to edit fields (like First Name or Age) and save with a &#x2705;.<\/li>\n<li><strong>Delete<\/strong>: A simple &#x1f5d1;&#xfe0f; button triggers the DELETE logic on the server.<\/li>\n<\/ul>\n<h3><strong>Advantages of This Approach<\/strong><\/h3>\n<p>The Server Logic provides several critical benefits for enterprise-level Power Pages deployments:<\/p>\n<ul>\n<li><strong>Enhanced Security<\/strong>: Business logic and external URLs are executed on the server, meaning they are never exposed in the browser &#8220;Network&#8221; tab. This prevents end users from viewing or tampering with sensitive integration details.<\/li>\n<li><strong>Centralized Management<\/strong>: If an external API URL or business rule changes, updates are made in a single Server Logic file rather than across multiple individual web pages.<\/li>\n<li><strong>Robust Debugging<\/strong>: Developers can utilize Logger to capture detailed logs of server-side operations, making it much easier to diagnose and resolve failures.<\/li>\n<li><strong>Performance Optimization<\/strong>: By handling heavy data transformations and computations on the server, only the necessary JSON is returned to the client. This results in a faster, more responsive user experience.<\/li>\n<\/ul>\n<h3>Conclusion<\/h3>\n<p>Moving from client-side scripting to Server Logic is a big step forward in how we build Power Pages sites. While it takes a few extra steps up front, the security and maintenance benefits are huge for any enterprise project.<\/p>\n<p>By keeping sensitive business rules and API keys on the server, you build more trust with your users and make your own life easier as a developer. Just don&#8217;t forget to Sync your code in the designer after editing in VS Code to make sure your changes are live!<\/p>\n<h3>FAQs<\/h3>\n<p><strong>What is Server Logic in Power Pages?<\/strong><\/p>\n<p>Server Logic in Power Pages is a backend feature that allows developers to execute HTTP operations such as GET, POST, PUT, and DELETE on the server. It is used to securely handle API calls and business logic without exposing them to the browser.<\/p>\n<p><strong>Why is Server Logic used in Power Pages?<\/strong><\/p>\n<p>Server Logic is used to move business logic and API processing from the client to the server. This improves security, performance, and maintainability by keeping sensitive operations hidden from end users.<\/p>\n<p><strong>Is Server Logic secure in Power Pages?<\/strong><\/p>\n<p>Yes. Server Logic is secure because all API calls and business rules run on the server. Sensitive information such as API URLs and logic is not exposed in the browser network tab.<\/p>\n<p><strong>How do you debug Server Logic in Power Pages?<\/strong><\/p>\n<p>You can debug Server Logic using Server.Logger. It allows developers to log execution flow, capture errors, and monitor API calls directly from the server-side script.<\/p>\n<p><strong>Do changes in Server Logic require publishing?<\/strong><\/p>\n<p>Yes. After editing Server Logic in VS Code, changes must be synced or published in Power Pages for them to reflect on the live site.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the previous blog, the &#8220;what&#8221; and &#8220;why&#8221; of Server Logic were explored. This entry takes the concept further by demonstrating the implementation of a full CRUD (Create, Read, Update, Delete) interface that communicates with an external OData service. The goal here is simple: move the &#8220;heavy lifting&#8221; to the server so your frontend stays\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2026\/05\/accelerate-power-pages-development-using-server-logic-part-2\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":15,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2763,2361],"tags":[3352],"class_list":["post-44594","post","type-post","status-publish","format-standard","hentry","category-power-pages","category-technical","tag-server-logic"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/44594","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/comments?post=44594"}],"version-history":[{"count":1,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/44594\/revisions"}],"predecessor-version":[{"id":44599,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/44594\/revisions\/44599"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=44594"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=44594"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=44594"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}