### Run Development Server Source: https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/quick-start-js-spa Starts the development server for the JavaScript SPA. Ensure you have Node.js and npm installed. ```bash npm start ``` -------------------------------- ### Query Contacts by User Query GUID Source: https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/web-api-query-data-sample This example demonstrates how to retrieve contact details by providing a GUID to the userQuery parameter in a GET request. ```APIDOC ## GET [Organization Uri]/api/data/v9.2/contacts ### Description Retrieves contact information by filtering with a user query GUID. ### Method GET ### Endpoint [Organization Uri]/api/data/v9.2/contacts ### Query Parameters - **userQuery** (GUID) - Required - The GUID to filter contacts. - **odata.maxpagesize** (integer) - Optional - Sets the maximum number of records to return per page. - **odata.include-annotations** (string) - Optional - Specifies annotations to include in the response. ### Request Headers - **Prefer**: odata.maxpagesize=[integer]; odata.include-annotations="*" - **OData-MaxVersion**: 4.0 - **OData-Version**: 4.0 - **If-None-Match**: null - **Accept**: application/json ### Response #### Success Response (200) - **@odata.context** (string) - Metadata context for the response. - **@Microsoft.Dynamics.CRM.totalrecordcount** (integer) - Total number of records found. - **@Microsoft.Dynamics.CRM.totalrecordcountlimitexceeded** (boolean) - Indicates if the total record count limit was exceeded. - **@Microsoft.Dynamics.CRM.globalmetadataversion** (string) - The global metadata version. - **value** (array) - An array of contact objects. - **@odata.etag** (string) - The entity's etag. - **fullname** (string) - The full name of the contact. - **contactid** (string) - The unique identifier for the contact. - **jobtitle** (string) - The job title of the contact. - **annualincome@OData.Community.Display.V1.FormattedValue** (string) - The formatted annual income. - **annualincome** (number) - The annual income of the contact. - **_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue** (string) - The formatted transaction currency. - **_transactioncurrencyid_value@Microsoft.Dynamics.CRM.associatednavigationproperty** (string) - Associated navigation property for transaction currency. - **_transactioncurrencyid_value@Microsoft.Dynamics.CRM.lookuplogicalname** (string) - Logical name of the lookup for transaction currency. - **_transactioncurrencyid_value** (string) - The transaction currency ID. ### Request Example ```http GET [Organization Uri]/api/data/v9.2/contacts?userQuery=00aa00aa-bb11-cc22-dd33-44ee44ee44ee HTTP/1.1 Prefer: odata.maxpagesize=3; odata.include-annotations="*" OData-MaxVersion: 4.0 OData-Version: 4.0 If-None-Match: null Accept: application/json ``` ### Response Example ```json { "@odata.context": "[Organization Uri]/api/data/v9.2/$metadata#contacts(fullname,contactid,jobtitle,annualincome,_transactioncurrencyid_value,transactioncurrencyid,transactioncurrencyid())", "@Microsoft.Dynamics.CRM.totalrecordcount": -1, "@Microsoft.Dynamics.CRM.totalrecordcountlimitexceeded": false, "@Microsoft.Dynamics.CRM.globalmetadataversion": "1144249", "value": [ { "@odata.etag": "W/\"1147979\"", "fullname": "Jim Glynn (sample)", "contactid": "f36e86e2-a228-ed11-9db1-000d3a320482", "jobtitle": "Senior International Sales Manager", "annualincome@OData.Community.Display.V1.FormattedValue": "$81,400.00", "annualincome": 81400.0, "_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue": "US Dollar", "_transactioncurrencyid_value@Microsoft.Dynamics.CRM.associatednavigationproperty": "transactioncurrencyid", "_transactioncurrencyid_value@Microsoft.Dynamics.CRM.lookuplogicalname": "transactioncurrency", "_transactioncurrencyid_value": "daf76074-6820-ed11-b83b-00224802b2ac" }, { "@odata.etag": "W/\"1147945\"", "fullname": "Nancy Anderson (sample)", "contactid": "db6e86e2-a228-ed11-9db1-000d3a320482", "jobtitle": "Activities Manager", "annualincome@OData.Community.Display.V1.FormattedValue": "$55,500.00", "annualincome": 55500.0, "_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue": "US Dollar", "_transactioncurrencyid_value@Microsoft.Dynamics.CRM.associatednavigationproperty": "transactioncurrencyid", "_transactioncurrencyid_value@Microsoft.Dynamics.CRM.lookuplogicalname": "transactioncurrency", "_transactioncurrencyid_value": "daf76074-6820-ed11-b83b-00224802b2ac" } ] } ``` ``` -------------------------------- ### Install Sample Data using SDK for .NET Source: https://learn.microsoft.com/en-us/power-apps/developer/data-platform/sample-data Use the InstallSampleDataRequest class with the IOrganizationService to install a pre-defined set of sample data. The response class has no properties to examine. ```csharp static void InstallSampleData(IOrganizationService service) { var request = new InstallSampleDataRequest(); service.Execute(request); } ``` -------------------------------- ### Create Web Resource in Solution using SDK for .NET Source: https://learn.microsoft.com/en-us/power-apps/developer/data-platform/optional-parameters This C# code snippet demonstrates how to create a web resource and associate it with a solution named 'ExampleSolution' using the SDK for .NET. Ensure you have an IOrganizationService instance. ```csharp static void CreateWebResourceInSolution(IOrganizationService service) { Entity webResource = new("webresource"); webResource["displayname"] = "Simple HTML web resource"; webResource["content"] = "PCFET0NUWVBFIGh0bWw+CjxodG1sPgogIDxib2R5PgogICAgPGgxPkhlbGxvIFdvcmxkPC9oMT4KICA8L2JvZHk+CjwvaHRtbD4="; webResource["webresourcetype"] = new OptionSetValue(1); webResource["name"] = "sample_SimpleHTMLWebResource.htm"; webResource["description"] = "An example HTML web resource"; CreateRequest request = new(); request.Target = webResource; request["SolutionUniqueName"] = "ExampleSolution"; service.Execute(request); } ``` -------------------------------- ### Example Verification Output Source: https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/quick-start-ps This is an example of the expected output when verifying your PowerShell and Az module installation. If your output differs, update your prerequisites. ```powershell PowerShell Version: 7.4.0 PowerShell Az version: 11.1.0 ``` -------------------------------- ### Retrieve AADUser records whose givenname does NOT start with 'test' Source: https://learn.microsoft.com/en-us/power-apps/developer/data-platform/aaduser-entity This example demonstrates retrieving AADUser records where the givenname does not start with 'test'. ```APIDOC ## GET /api/data/v9.1/aadusers?$filter=not startswith(givenname, 'test') ### Description Retrieves AADUser records where the givenname does not start with 'test'. ### Method GET ### Endpoint https://[Organization URI].crm.dynamics.com/api/data/v9.1/aadusers ### Query Parameters - **$filter** (string) - Required - Filter expression to retrieve records where givenname does not start with 'test'. ``` -------------------------------- ### InstallSampleData Source: https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/reference/actions Installs the sample data. This action is useful for setting up a demonstration or testing environment. ```APIDOC ## InstallSampleData ### Description Installs the sample data. ### Method POST ### Endpoint /InstallSampleData ``` -------------------------------- ### Retrieve AADUser records whose givenname starts with 'test' Source: https://learn.microsoft.com/en-us/power-apps/developer/data-platform/aaduser-entity This example demonstrates retrieving AADUser records where the givenname starts with 'test'. ```APIDOC ## GET /api/data/v9.1/aadusers?$filter=startswith(givenname, 'test') ### Description Retrieves AADUser records where the givenname starts with 'test'. ### Method GET ### Endpoint https://[Organization URI].crm.dynamics.com/api/data/v9.1/aadusers ### Query Parameters - **$filter** (string) - Required - Filter expression to retrieve records where givenname starts with 'test'. ``` -------------------------------- ### Install dependencies and initialize code app Source: https://learn.microsoft.com/en-us/power-apps/developer/code-apps/how-to/create-an-app-from-scratch Install the necessary npm packages for the Power Apps client library and initialize your code app with a display name using the Power Platform CLI. ```Bash npm install pac code init --displayname "App From Scratch" ``` -------------------------------- ### Get Saved Query GUID Source: https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/web-api-query-data-sample Retrieve the savedqueryid GUID for a saved query by its name. This is the first step before executing the saved query. ```http GET [Organization Uri]/api/data/v9.2/savedqueries?$select=name,savedqueryid&$filter=name eq 'Active Accounts' HTTP/1.1 OData-MaxVersion: 4.0 OData-Version: 4.0 If-None-Match: null Accept: application/json ``` -------------------------------- ### Initialize Code App (Direct Options) Source: https://learn.microsoft.com/en-us/power-apps/developer/code-apps/how-to/npm-quickstart Initialize your code app by providing the display name and environment ID directly as command-line arguments. ```Bash power-apps init --display-name "App From Scratch" --environment-id ``` -------------------------------- ### GET Search Status Request Source: https://learn.microsoft.com/en-us/power-apps/developer/data-platform/search/statistics-status Example HTTP GET request to retrieve the search status for an organization. This endpoint is used to check if search is provisioned. ```http GET [Organization URI]/api/data/v9.2/searchstatus HTTP/1.1 OData-MaxVersion: 4.0 OData-Version: 4.0 If-None-Match: null Accept: application/json ``` -------------------------------- ### SDK Style Project File Example Source: https://learn.microsoft.com/en-us/power-apps/developer/data-platform/build-and-package This is an example of an SDK-style .csproj file for a plug-in project. Ensure your project file includes the `` line and appropriate target framework and assembly version information. ```xml net462 $(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\PowerApps 1.0.0.0 1.0.0.0 {4C25E9B5-9FA6-436c-8E19-B395D2A65FAF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ... ``` -------------------------------- ### Install Sample Data (Web API) Source: https://learn.microsoft.com/en-us/power-apps/developer/data-platform/sample-data Installs a pre-defined set of sample data using the InstallSampleData Web API action. ```APIDOC ## POST [Organization URI]/api/data/v9.2/InstallSampleData ### Description Installs a pre-defined set of sample data. ### Method POST ### Endpoint [Organization URI]/api/data/v9.2/InstallSampleData ### Request Body This action does not require a request body. ### Response #### Success Response (204) No Content is returned upon successful execution. ### Response Example HTTP/1.1 204 No Content OData-Version: 4.0 ``` -------------------------------- ### Filtered Collections Example Source: https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/query-data-web-api Retrieve data from a collection-valued navigation property for a specific record. This example shows how to get the 'name' of accounts owned by a specific user. ```APIDOC ## GET systemusers()/user_accounts ### Description Retrieves a collection of entities related to a specific record through a collection-valued navigation property. ### Method GET ### Endpoint [Organization URI]/api/data/v9.2/systemusers()/user_accounts ### Parameters #### Query Parameters - **$select** (string) - Optional - Specifies the columns to return. Example: `name` ``` -------------------------------- ### Debug Output Log Source: https://learn.microsoft.com/en-us/power-apps/developer/component-framework/implementing-controls-using-typescript This is an example of the output you can expect when running the 'npm start watch' command. It shows the build process, compilation status, and the control harness starting. ```bash > pcf-project@1.0.0 start > pcf-scripts start "watch" [2:09:10 PM] [start] [watch] Initializing... [2:09:10 PM] [start] [watch] Validating manifest... [2:09:10 PM] [start] [watch] Validating control... [2:09:11 PM] [start] [watch] Generating manifest types... [2:09:11 PM] [start] [watch] Generating design types... [2:09:11 PM] [start] [watch] Compiling and bundling control... [Webpack stats]: asset bundle.js 6.56 KiB [emitted] (name: main) ./LinearInputControl/index.ts 4.9 KiB [built] [code generated] webpack 5.75.0 compiled successfully in 2060 ms [2:09:13 PM] [start] [watch] Generating build outputs... [2:09:13 PM] [start] [watch] Starting control harness... Starting control harness... [Browsersync] Access URLs: ---------------------------- Local: http://localhost:8181 ---------------------------- [Browsersync] Serving files from: C:\repos\LinearInput\out\controls\LinearInputControl [Browsersync] Watching files... ``` -------------------------------- ### Download and launch Plug-in Registration Tool (PRT) Source: https://learn.microsoft.com/en-us/power-apps/developer/data-platform/download-tools-nuget Installs and launches the Plug-in Registration Tool. If the tool is already installed, this command launches the latest installed version. ```bash > pac tool prt Installing 9.1.0.155 version of PRT.... Shortcut in start menu created for 'Plugin Registration Tool' Installation complete Launched PRT (9.1.0.155). ``` -------------------------------- ### Run Local Development Server Source: https://learn.microsoft.com/en-us/power-apps/developer/code-apps/how-to/npm-quickstart Start a local development server to test your code app. Open the provided 'Local Play' URL in your browser. ```Bash npm run dev ``` -------------------------------- ### HTTP GET Request for RetrieveMetadataChanges Source: https://learn.microsoft.com/en-us/power-apps/developer/data-platform/column-level-security This is an example of a URL-encoded HTTP GET request to the RetrieveMetadataChanges API endpoint. It's used to fetch metadata changes, specifically filtering for secured columns. ```http GET [ORGANIZATION URI]/api/data/v9.2/RetrieveMetadataChanges(Query=@p1)?@p1=%7b+%22Properties%22%3a+%7b+%22AllProperties%22%3a+false%2c+%22PropertyNames%22%3a+%5b%22SchemaName%22%2c%22Attributes%22%5d+%7d%2c+%22Criteria%22%3a+%7b+%22FilterOperator%22%3a+%22And%22%2c+%22Conditions%22%3a+%5b%5d+%7d%2c+%22AttributeQuery%22%3a+%7b+%22Properties%22%3a+%7b+%22AllProperties%22%3a+false%2c+%22PropertyNames%22%3a+%5b+%22SchemaName%22%2c+%22IsSecured%22+%5d+%7d%2c+%22Criteria%22%3a+%7b+%22FilterOperator%22%3a+%22And%22%2c+%22Conditions%22%3a+%5b+%7b+%22ConditionOperator%22%3a+%22Equals%22%2c+%22PropertyName%22%3a+%22IsSecured%22%2c+%22Value%22%3a+%7b+%22Type%22%3a+%22System.Boolean%22%2c+%22Value%22%3a+%22true%22+%7d+%7d+%5d+%7d+%7d HTTP/1.1 Accept: application/json Authorization: Bearer [REDACTED] OData-MaxVersion: 4.0 OData-Version: 4.0 ``` -------------------------------- ### Open a Quick Create Form Source: https://learn.microsoft.com/en-us/power-apps/developer/component-framework/reference/navigation/openform This example demonstrates how to open a quick create form for a new record. Set 'useQuickCreateForm' to true. ```typescript context.navigation.openForm({ entityName: "account", useQuickCreateForm: true }); ``` -------------------------------- ### Get Control Type Example Source: https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/controls/getcontroltype This snippet demonstrates how to retrieve the control type for a specific control on a form. You need to first get the control object using `Xrm.Page.getControl` and then call the `getControlType` method on it. ```javascript var control = Xrm.Page.getControl("control_name"); if (control != null) { var controlType = control.getControlType(); // controlType will be a string representing the control type // e.g., "standard", "lookup", "subgrid", "customcontrol:." } ``` -------------------------------- ### Failing GET request with unsupported character in alternate key Source: https://learn.microsoft.com/en-us/power-apps/developer/data-platform/use-alternate-key-reference-record This example demonstrates a GET request that fails when an unsupported special character is included in the alternate key value within the URL path segment. ```http GET [Organization URI]/api/data/v9.2/new_skts(new_name='M%26M') ``` -------------------------------- ### Install Sample Data using Web API Source: https://learn.microsoft.com/en-us/power-apps/developer/data-platform/sample-data Make a POST request to the InstallSampleData action endpoint to install sample data. The response is HTTP 204 No Content. ```http POST [Organization URI]/api/data/v9.2/InstallSampleData HTTP/1.1 Accept: application/json Content-Type: application/json; charset=utf-8 OData-MaxVersion: 4.0 OData-Version: 4.0 ``` ```http HTTP/1.1 204 No Content OData-Version: 4.0 ``` -------------------------------- ### Create Publisher and Solution Source: https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/samples/multi-table-lookup-powershell This section demonstrates querying for and creating a publisher and a solution if they do not already exist. It uses GET and POST requests to the /publishers and /solutions Web API endpoints. ```powershell # Query for an existing publisher with the unique name 'examplepublisher' GET /publishers?$filter=UniqueName eq 'examplepublisher' # Create the publisher if it doesn't already exist # POST to /publishers # Query for an existing solution named 'polymorphiclookupexamplesolution' GET /solutions?$filter=SolutionPackageName eq 'polymorphiclookupexamplesolution' # Create the solution if it doesn't already exist # POST to /solutions ``` -------------------------------- ### RetrievePrincipalAccess Web API Example Source: https://learn.microsoft.com/en-us/power-apps/developer/data-platform/security-access-coding This example demonstrates how to retrieve the access rights a user has for a specific account record using the Web API. It shows the HTTP GET request and the expected JSON response. ```APIDOC ## GET [Organization Uri]/api/data/v9.2/systemusers(4026be43-6b69-e111-8f65-78e7d1620f5e)/Microsoft.Dynamics.CRM.RetrievePrincipalAccess(Target=@p1)?@p1={'@odata.id':'accounts(e41ac31a-dcdf-ed11-a7c7-000d3a993550)'} ### Description Retrieves the access rights a user has for a specific record. ### Method GET ### Endpoint [Organization Uri]/api/data/v9.2/systemusers(guid)/Microsoft.Dynamics.CRM.RetrievePrincipalAccess(Target=@p1)?@p1={'@odata.id':'entity(guid)'} ### Parameters #### Query Parameters - **@p1** (object) - Required - A complex type representing the target record for which to retrieve access rights. - **@odata.id** (string) - Required - The OData ID of the target record. ### Request Example HTTP ``` GET [Organization Uri]/api/data/v9.2/systemusers(4026be43-6b69-e111-8f65-78e7d1620f5e)/Microsoft.Dynamics.CRM.RetrievePrincipalAccess(Target=@p1)?@p1={'@odata.id':'accounts(e41ac31a-dcdf-ed11-a7c7-000d3a993550)'} OData-MaxVersion: 4.0 OData-Version: 4.0 If-None-Match: null Accept: application/json ``` ### Response #### Success Response (200) - **@odata.context** (string) - The metadata context URL. - **AccessRights** (string) - A comma-separated list of access rights the user has for the record. #### Response Example HTTP ``` HTTP/1.1 200 OK OData-Version: 4.0 { "@odata.context": "[Organization Uri]/api/data/v9.2/$metadata#Microsoft.Dynamics.CRM.RetrievePrincipalAccessResponse", "AccessRights": "ReadAccess, WriteAccess, AppendAccess, AppendToAccess, CreateAccess, DeleteAccess, ShareAccess, AssignAccess" } ``` ``` -------------------------------- ### Get Resource Example Source: https://learn.microsoft.com/en-us/power-apps/developer/component-framework/reference/resources/getresource This example demonstrates how to use the getResource function to load a default image. It includes setting an image and handling potential output changes. Ensure DefaultImageFileName, NoImageClassName, and the controlContainer are defined. ```typescript private setDefaultImage(): void { this._context.resources.getResource( DefaultImageFileName, this.setImage.bind(this, false, "png"), this.showError.bind(this) ); this.controlContainer.classList.add(NoImageClassName); // If it already has value, we need to update the output if (this._context.parameters.value.raw) { this._value = null; this._notifyOutputChanged(); } } ``` -------------------------------- ### Verify tool installation after launch Source: https://learn.microsoft.com/en-us/power-apps/developer/data-platform/download-tools-nuget Re-list the installed tools to confirm that the Plug-in Registration Tool has been successfully installed and is ready for use. ```bash > pac tool list ToolName Installed Version Nuget Status CMT No N/A 9.1.0.80 not yet installed; 'pac tool CMT' will install on first launch PD No N/A 9.1.0.104 not yet installed; 'pac tool PD' will install on first launch PRT Yes 9.1.0.155 9.1.0.155 ok ``` -------------------------------- ### Initialize a New Solution Project Source: https://learn.microsoft.com/en-us/power-apps/developer/component-framework/import-custom-controls Use this command to create a new solution project for bundling code components. Ensure the publisher name and prefix are unique to your environment. ```CLI pac solution init --publisher-name developer --publisher-prefix dev ``` -------------------------------- ### Autocomplete Search Example Source: https://learn.microsoft.com/en-us/power-apps/developer/data-platform/search/legacy A basic autocomplete request to get input suggestions for the search term 'mar'. ```http POST [Organization URI]/api/search/v1.0/autocomplete { "search": "mar" } ``` -------------------------------- ### GET Request with User Query Parameter Source: https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/web-api-query-data-sample This HTTP GET request demonstrates how to pass a GUID value using the userQuery parameter to retrieve specific contact data. It includes headers for pagination and OData versioning. ```http GET [Organization Uri]/api/data/v9.2/contacts?userQuery=00aa00aa-bb11-cc22-dd33-44ee44ee44ee HTTP/1.1 Prefer: odata.maxpagesize=3; odata.include-annotations="*" OData-MaxVersion: 4.0 OData-Version: 4.0 If-None-Match: null Accept: application/json ``` -------------------------------- ### Example build output Source: https://learn.microsoft.com/en-us/power-apps/developer/component-framework/implementing-controls-using-typescript This is an example of the output you can expect after successfully running the build command. It shows the build progress and final success message. ```bash > pcf-project@1.0.0 build > pcf-scripts build [2:05:41 PM] [build] Initializing... [2:05:41 PM] [build] Validating manifest... [2:05:41 PM] [build] Validating control... [2:05:42 PM] [build] Running ESLint... [2:05:43 PM] [build] Generating manifest types... [2:05:43 PM] [build] Generating design types... [2:05:43 PM] [build] Compiling and bundling control... [Webpack stats]: asset bundle.js 6.56 KiB [emitted] (name: main) ./LinearInputControl/index.ts 4.9 KiB [built] [code generated] webpack 5.75.0 compiled successfully in 2049 ms [2:05:45 PM] [build] Generating build outputs... [2:05:45 PM] [build] Succeeded PS C:\repos\LinearInput\LinearInputcontrol> ``` -------------------------------- ### Insert Sample Projects Source: https://learn.microsoft.com/en-us/power-apps/developer/code-apps/how-to/connect-to-azure-sql Populates the Projects table with sample data. This script is useful for testing and demonstration purposes. ```sql INSERT INTO [dbo].[Projects] ([Name], [Description], [StartDate], [EndDate], [Status], [Priority], [Budget], [ProjectManagerEmail], [CreatedBy]) VALUES ('Website Redesign', 'Complete redesign of company website with modern UI/UX', '2025-06-01', '2025-08-31', 'Active', 'High', 75000.00, 'sarah.johnson@company.com', 'admin@company.com'), ('Mobile App Development', 'Develop iOS and Android mobile application for customer portal', '2025-07-01', '2025-12-31', 'Planning', 'Critical', 150000.00, 'mike.chen@company.com', 'admin@company.com'), ('Database Migration', 'Migrate legacy database to cloud infrastructure', '2025-05-15', '2025-09-30', 'Active', 'Medium', 50000.00, 'lisa.williams@company.com', 'admin@company.com'); GO PRINT 'Projects-only database schema created successfully with sample data!'; ``` -------------------------------- ### Get the Grid object Source: https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/grids/grid Retrieve the Grid object from the grid context. This is the starting point for using Grid methods. ```javascript let myGrid = gridContext.getGrid(); ``` -------------------------------- ### Configure Environment Variables Source: https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/quick-start-js-spa Set up the .env file with your application's client ID, tenant ID, and redirect URI. This file should not be committed to version control. ```text # The environment this application will connect to. BASE_URL=https://.api.crm.dynamics.com # The registered Entra application id CLIENT_ID=11112222-bbbb-3333-cccc-4444dddd5555 # The Entra tenant id TENANT_ID=aaaabbbb-0000-cccc-1111-dddd2222eeee # The SPA redirect URI included in the Entra application registration REDIRECT_URI=http://localhost:1234 ``` -------------------------------- ### Invoke WhoAmI Unbound Function (Request) Source: https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/use-web-api-functions Example HTTP GET request to invoke the WhoAmI unbound function. ```http GET [Organization URI]/api/data/v9.2/WhoAmI HTTP/1.1 Accept: application/json OData-MaxVersion: 4.0 OData-Version: 4.0 ``` -------------------------------- ### Get PAC CLI Version Source: https://learn.microsoft.com/en-us/power-apps/developer/code-apps/troubleshoot-zscaler-issues Retrieve the installed version of the Power Apps CLI. This is a basic diagnostic step for troubleshooting. ```bash pac --version ``` -------------------------------- ### Create Web Resource with Solution Association (SDK for .NET) Source: https://learn.microsoft.com/en-us/power-apps/developer/data-platform/optional-parameters This C# code example demonstrates how to create a web resource and associate it with a solution using the SDK for .NET. The SolutionUniqueName is passed as a property of the request. ```APIDOC ## CreateWebResourceInSolution (SDK for .NET) ### Description Creates a web resource solution component and associates it with a specified solution using the SDK for .NET. ### Method Signature `static void CreateWebResourceInSolution(IOrganizationService service)` ### Parameters - **service** (IOrganizationService) - Required - The service proxy to execute the operation. - **SolutionUniqueName** (string) - Required - Passed as a request property, this is the unique name of the solution to associate the component with. ### Request Body (Conceptual) An `Entity` object representing the web resource with its properties, and a `CreateRequest` object with the `Target` set to the web resource and the `SolutionUniqueName` property set. ### Code Example ```csharp static void CreateWebResourceInSolution(IOrganizationService service) { Entity webResource = new("webresource"); webResource["displayname"] = "Simple HTML web resource"; webResource["content"] = "PCFET0NUWVBFIGh0bWw+CjxodG1sPgogIDxib2R5PgogICAgPGgxPkhlbGxvIFdvcmxkPC9oMT4KICA8L2JvZHk+CjwvaHRtbD4="; webResource["webresourcetype"] = new OptionSetValue(1); webResource["name"] = "sample_SimpleHTMLWebResource.htm"; webResource["description"] = "An example HTML web resource"; CreateRequest request = new(); request.Target = webResource; request["SolutionUniqueName"] = "ExampleSolution"; service.Execute(request); } ``` ### Response This method executes the create operation. A successful execution does not return a specific object but implies the web resource was created and associated with the solution. ``` -------------------------------- ### Get Process ID Source: https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/formcontext-data-process/process/getid Use the getId method on a process object to retrieve its unique identifier. This method returns a string that is a GUID. ```javascript var processId = procObj.getId(); ``` -------------------------------- ### Create Account using Early-bound Programming Source: https://learn.microsoft.com/en-us/power-apps/developer/data-platform/org-service/early-bound-programming This example demonstrates how to create an account record using early-bound classes. It shows setting various attribute types including string, boolean, datetime, double, integer, money, and option sets. ```csharp var account = new Account(); // set attribute values // string primary name account.Name = "Contoso"; // Boolean (Two option) account.CreditOnHold = false; // DateTime account.LastOnHoldTime = new DateTime(2017, 1, 1); // Double account.Address1_Latitude = 47.642311; account.Address1_Longitude = -122.136841; // Int account.NumberOfEmployees = 500; // Money account.Revenue = new Money(new decimal(5000000.00)); // Picklist (Option set) account.AccountCategoryCode = new OptionSetValue(1); //Preferred customer //Create the account Guid accountid = svc.Create(account); ``` -------------------------------- ### Get Node.js Version Source: https://learn.microsoft.com/en-us/power-apps/developer/code-apps/troubleshoot-zscaler-issues Retrieve the installed version of Node.js. This is useful for compatibility checks when troubleshooting Power Apps CLI issues. ```bash node --version ```