Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

Pass String Parameter from Command Editor to Custom Page

(1) ShareShare
ReportReport
Posted on by 100

Hi everyone,

I have the following JS function applied to a Command Button. This is being used to open a Custom Page dialog in a Model Driven App. All working fine.

function openStrategicApproval(primaryControl, firstSelectedItemId, selectedEntityTypeName)
{
    // Centered Dialog
    var pageInput = {
        pageType: "custom",
        name: "new_requeststrategiccaseapproval_ad938",
        entityName: selectedEntityTypeName, // "sample_review"
        recordId: firstSelectedItemId // "{087AA308-B321-E811-A845-000D3A33A3AC}" 
    };
    var navigationOptions = {
        target: 2,
        position: 1,
                height: {
                    value: 300,
                    unit: "px"
                },
                width: {
                    value: 12,
                    unit: "%"
                }
    };
    Xrm.Navigation.navigateTo(pageInput, navigationOptions).then(
        function () {
            // Refresh the main form when the dialog is closed
            primaryControl.data.refresh();
        }
    ).catch (
        function (error) {
            // Handle error
        }
    );
}

Problem:

What I would like to do is pass a String parameter into this function so that I can leverage it in the Custom Page.

3857.Picture1.png

However, I cannot identify what I would need to revise in the JS function in order to accommodate the additional String parameter. In the example below, I have added the parameter into the openStrategicApproval function (primaryControl, firstSelectedItemId, selectedEntityTypeName, String). However, I am not well versed enough in JS to know where I need to place it. For example, I have added it into the Custom page object, but I do not think this is correct.

JS Code:

function openStrategicApproval(primaryControl, firstSelectedItemId, selectedEntityTypeName, String)

{

    // Centered Dialog

    var pageInput = {

        pageType: "custom",

        name: "new_requeststrategiccaseapproval_ad938",

        entityName: selectedEntityTypeName, // "sample_review"

        recordId: firstSelectedItemId, // "{087AA308-B321-E811-A845-000D3A33A3AC}"

        powerautomateflow: String

    };

    var navigationOptions = {

        target: 2,

        position: 1,

                height: {

                    value: 300,

                    unit: "px"

                },

                width: {

                    value: 12,

                    unit: "%"

                }

    };

    Xrm.Navigation.navigateTo(pageInput, navigationOptions).then(

        function () {

            // Refresh the main form when the dialog is closed

            primaryControl.data.refresh();

        }

    ).catch (

        function (error) {

            // Handle error

        }

    );

}

 

Custom Page Formula

0121.picture2.png

Best regards,

  • BethV Profile Picture
    BethV 3 on at
    Pass String Parameter from Command Editor to Custom Page
    I realize this is an old post, but I was wondering if you ever figured out how to make this work.
  • Ami K Profile Picture
    Ami K 100 on at
    RE: Pass String Parameter from Command Editor to Custom Page

    Thanks Haig Liu but it is not the recordId I am having trouble with. As mentioned in my post everything is working fine.

    What I want to do is return a different String parameter.

  • Haig Liu Profile Picture
    Haig Liu Microsoft Employee on at
    RE: Pass String Parameter from Command Editor to Custom Page

    Hi ImranAmi,

    Please take a look at the following link: 

    https://dynatecon.com/2022/07/25/call-custom-page-with-parameters-from-model-driven-app-using-new-command-editor/

    I'm not sure if the mid() function is being used correctly,

    as I use JS rarely, usually like the following:

    Set(RecordItem,
    If(IsBlank(Param("recordId")),
    Blank(),
    LookUp(Accounts, Account = GUID(Param("recordId")))
    )
    )

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans