In this blog we can see how to populate a custom page based on Command button using java script action. 

Step 1

Login into power apps using “make.powerapps.com”.

Navigate to solutions and select  your solution.

 

Step 2 :

In Solutions navigate to apps in apps select your model drive app.

Step 3

In  apps go to your form and edit command bar.

Step 4:

After step 3 select main grid and click on next.

Step 5 :

After step 4 add a new column with java script action .

Now create a web resource win dynamics 365 using the below code.

function onChange(selectedItems) {
    var selectedItem = selectedItems[0];
    var pageInput = {
        pageType: “custom”,
        name: “Schema name of the custom page”,
        entityName: “crmonce_account”,
        recordId: selectedItem.Id,
    };
    var navigationOptions = {
          target: 1,
          height: { value: 80, unit: “%” },
          width: { value: 70, unit: “%” },
          position: 1
 
    };
 Xrm.Navigation.navigateTo(pageInput, navigationOptions).then(
        function (sucess) {}
    ).catch(
        function (error) {}
    );
 

After creating a web resource add to command libraries and give inputs as shown below.

In the above picture on change is a function we need to pass our java script function in this column.

Save and publish the customizations .

After publishing navigate to custom page from the solution .

In the page on app on start write the patch given below.

Set(RecordItem,
If(IsBlank(Param(“recordId”)),First(Account),
LookUp(Account,Account = GUID(Param(“recordId”))))
);

At last select the three dots beside the app and select RunOnStart.

Now Save and Publish the Page.

Now test it in your Model-driven app.

For any Help or Queries Contact us on info@crmonce.com or +918096556344