cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dennisb88
Responsive Resident
Responsive Resident

Open a custom page from the main form bar

Hi all,

 

I'm trying to open a custom page as side dialog from my main form.

Does anyone know how to achieve that?

 

I just find out how to do that from the grid view, but I don't know what kind of javascript I need to use to open the custom page from my main form (with the current id in a variable, so that I can use it in my custom page).

 

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions

8 REPLIES 8
rampprakash
Super User
Super User

Hello @dennisb88 

 

Hope you are doing good.

 

Edit the Model Driven App --> Click EDIT --> ADD New Sub Group --> Add URL --> Input the URL Value.

 

Please mark as Answer if it is helpful and provide Kudos


Subscribe : https://www.youtube.com/channel/UCnGNN3hdlKBOr6PXotskNLA
Blog : https://microsoftcrmtechie.blogspot.com

Hi @rampprakash ,

 

Thanks, I'm now able to open the page, but I cannot have the correct GUID of the opened record in my custom page.

Do you know how to achieve that?

function opencanvaspage()
{
var pageInput = {
    pageType: "custom",
    name: "wam_kaartservices_2cb7b",
    entityName: "wam_maatregel",
    recordId: "wam_maatregel",
};
var navigationOptions = {
    target: 2, 
    position: 2,
    width: {value: 500, unit: "px"}
};
Xrm.Navigation.navigateTo(pageInput, navigationOptions)
    .then(
        function () {
            // Called when page opens
        }
    ).catch(
        function (error) {
            // Handle error
        }
    )};

 

THis is the script I use right now, but that will not pass me the correct GUID/ID of my record. 

@dennisb88 ,

I hope you might be using the js library to call the function to open custom page. In terms of getting an ID of the record you need to pass formcontext as parameter. Attaching screenshot for your reference. select add parameter->PrimaryControl.

Prakash4691_0-1647905138580.png

To pass formcontext as method parameter and getting ID from context, please find below screenshot and make necessary modifications in your method.

Prakash4691_1-1647905344179.png

I hope it answers your question. If so, kindly give kudo and accept it as solution.

 

 

Regards,

Prakash

Hi @Prakash4691 ,

 

Thank you for your reply.

I just changed something to the js file and changed the parameter but since I've changed that, the page is not opening anymore. Any idea what's wrong?

 

My control settings:

dennisb88_0-1647942760668.png

 

The script I used:

 

function openCustomPage()
{
var pageInput = {
    pageType: "custom",
    name: "wam_kaartservices_2cb7b",
    //entityName: "wam_maatregel",
    //recordId: "wam_maatregel",
    recordId: formContext.data.entity.getId().replace(/[{}]/g, ""),
};
var navigationOptions = {
    target: 2, 
    position: 2,
    width: {value: 500, unit: "px"}
};
Xrm.Navigation.navigateTo(pageInput, navigationOptions)
    .then(
        function () {
            // Called when page opens
        }
    ).catch(
        function (error) {
            // Handle error
        }
    )};

 

FYI When I changed this values, the page is starting but without the GUID of the specific record:

var pageInput = {
    pageType: "custom",
    name: "wam_kaartservices_2cb7b",
    //entityName: "wam_maatregel",
    recordId: "wam_maatregel",
    //recordId: formContext.data.entity.getId().replace(/[{}]/g, ""),

 

Do you know what I need to change to get the current GUID and let start the page?

 

Thanks in advance.

@dennisb88 ,

You are referring formContext but you are not passing in method.

 

In opencustompage method you need to pass formcontext parameter.

 

openCustomPage(formContext) as per screenshot below.

 

Regards,

Prakash

Hi @Prakash4691 ,

 

I guess you forgot the printscreen, can you add the printscreen so I can see what you mean?

 

Thanks.

@dennisb88 ,

Prakash4691_1-1647947874468.png

 

Hi @Prakash4691 ,

 

Thank you. Thanks. I just fixed it. Thanks again.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (2,541)