Skip to main content
Post a question

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id : v8A+dlObBp/hg/ZAKKKd1W
Customer experience | Sales, Customer Insights,...
Suggested answer

Passing parameter from Model-driven to Custom Page not working

Like (0) ShareShare
ReportReport
Posted on 7 May 2022 08:29:41 by 312

Hello guys,

In my Model-driven app, I've added a command button to which will open Custom Page. A Javascript has been created, something like this :

function openPageInlineWithContext(selectedItems)
{
    var selectedItem = selectedItems[0];

    if (selectedItem) {     
        let pageInput = {
            pageType: "custom",
            name: "new_accountpage_d32ca",
            entityName: selectedItem.TypeName,
            recordId: selectedItem.Id,
        };
        let navigationOptions = {
            target: 1
        };
        Xrm.Navigation.navigateTo(pageInput, navigationOptions)
            .then(
                function () {
                    // Handle success
                }
            ).catch(
                function (error) {
                    // Handle error
                }
            );
    }
}



Which in one of the lines is this code -> recordId: selectedItem.Id

It is mentioned that is to "handle" the record id to be passed to Custom Page when it is called.

Now in my Custom Page, I have this code in OnStart method :

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



But if I tested this Param("recordid") in some Label inside my app, it always empty. May I know how to pass the record from Model-driven View to Custom Page ?

 

The command button in the main grid, when setting the Javascript, I put the parameter to "SelectedControlAllItemReferences"

pastedimage1651912145271v1.png

Is this option wrong for me to choose ? or is there anything else that make the record id is not going to my Custom Page ?

 

Thanks

  • Teevo Profile Picture
    Teevo 312 on 07 May 2022 at 18:29:10
    RE: Passing parameter from Model-driven to Custom Page not working

    Hi Pedro,

    Sorry, I guess my picture accidentally deleted in my thread. I was actually select "SelectControlAllItemReference"

    And I just tried, if using the one that you suggested, the button will not open anything if no row selected, and if select 1 row, Custom Page is in New Formmode. I tried to change parameter setting again and think the working one is "SelectControlSelectedItemReferences"

    But this is also have some flaws, is that when I didn't select any row, the button will do nothing, not open my Custom Page, whereas if I select 1 row, the Custom Page is shown with the correct record which is selected.

    My initial idea was :

    1. If I didn't select any row, the button press will open Custom Page which is in New Form Mode (to insert new)
    2. If I select, then it will open Custom Page with the corresponding row (record) selected. Edit Form Mode. This one is now done.

    This is possible, right?

    What are actually the meaning of each selection ? I've read this -> https://docs.microsoft.com/en-us/power-apps/developer/model-driven-apps/pass-data-page-parameter-ribbon-actions#grid-values but too bad it looks not clear what what is the meaning of each. 

    But it is getting better and better, Thank You Very Much.

  • Suggested answer
    Pedro Azevedo Profile Picture
    Pedro Azevedo 830 User Group Leader on 07 May 2022 at 18:03:05
    RE: Passing parameter from Model-driven to Custom Page not working

    Hi,

    Was the parameter that you choose, you are getting all the records and choose the first one, to have only the one you selected you need to choose this parameter:

    SelectedControlSelectedItemIds

    Can you mark the reply as an Answer please.

    Thanks,

    Pedro Azevedo

  • Teevo Profile Picture
    Teevo 312 on 07 May 2022 at 16:36:23
    RE: Passing parameter from Model-driven to Custom Page not working

    Oo man, I'm new to this, never thought it is case sensitive, also didn't realized it. You bring a new hope !

    It's showing something now. It's still wrong though, as now Not selected or have 1 record selected, my Custom Page showing the 1st record.

    So I guess, now this setting is the one which also incorrect ?

    Anyway I should thanks, first ! 

  • Suggested answer
    Pedro Azevedo Profile Picture
    Pedro Azevedo 830 User Group Leader on 07 May 2022 at 16:20:16
    RE: Passing parameter from Model-driven to Custom Page not working

    Hello,

    I think you have a typo in your code, where you have:

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

    Should be:

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

    The difference in on the work recordid, where you need to capitalize the "i", should be recordId.

    Thanks,

    Pedro Azevedo

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,489 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans
Loading started