Skip to main content

Notifications

Power Apps - Microsoft Dataverse
Answered

Cannot call a Custom Page from a Custom Main Grid

(0) ShareShare
ReportReport
Posted on by 945

Hi guys,

 

I created a custom page and after published, I'm planning to call this page (entry form) from a Main Grid of my Model-driven menu.

Following Reza's video -> https://www.youtube.com/watch?v=XMopL0r8k3k especially on minute 25:40 for the command designer, also this Microsoft Doc https://docs.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/navigate-to-custom-page-examples#open-as-an-inline-full-page-without-context  here is my step :

  • Get my logical name of Custom Page         

Axal_1-1651542941748.png

  • Create new Web Resource
function OpenCanvasExpense()
{
var pageInput = {
	pageType: "custom",
	name: "new_newexpensecustom_e990e",
};
var navigationOptions = {
	target: 1
};
Xrm.Navigation.navigateTo(pageInput, navigationOptions)
	.then(
		function () {
		{
	).catch(
		function (error) {
		}
	);
}
  • Save and Publish
  • Go to my Model-driven, Edit in Preview, look for my menu (Subarea), click three dots for Edit command bar

Axal_2-1651543217575.png

  • Choose Main Grid
  • Choose Add Command for new command button in that main grid.
  • Set for calling the Web resource ->

Axal_3-1651543429120.png

  • Save and Publish

 

The new button appear in my App, but nothing showing when I click the button. 

 

Anyone can help what did I missed ?

 

Thanks

 

 

 

  • FemaleMarvel365 Profile Picture
    FemaleMarvel365 55 on at
    Cannot call a Custom Page from a Custom Main Grid
    This is the code i tried from benedicts blog the button does nothing; all of the parameters are correct : 
    function idWithoutBrackets(id) {
    if (id.slice(0, 1) === "{") {
    return id.slice(1, -1);
    } else {
    return id;
    }
    }
    function convertToSize(input, defaultSize) {
    let result = defaultSize;
    if (typeof input === "number") {
    if (input > 0) {
    result = input;
    }
    }
    else {
    const parsedInput = Number(input);
    if (isNaN(parsedInput)) {
    if (input.endsWith("px")) {
    const numberPart = Number(input.substring(0, input.length - 2));
    if (!isNaN(numberPart)) {
    result = { value: numberPart, unit: "px" };
    }
    }
    else if (input.endsWith("%")) {
    const numberPart = Number(input.substring(0, input.length - 1));
    if (!isNaN(numberPart)) {
    result = { value: numberPart, unit: "%" };
    }
    }
    }
    else {
    if (parsedInput > 0) {
    result = parsedInput;
    }
    }
    }
    return result;
    }
    async function openCustomPage(pageName, title, entityName = "", id = "", width = 600, height = 400, target = 2, position = 1) {
    const defaultWidth = 600;
    const defaultHight = 400;
    const recId = idWithoutBrackets(id);
    const pageInput = {
    pageType: "custom",
    name: pageName,
    entityName: entityName,
    recordId: recId,
    };
    const navigationOptions = {
    target: target,
    width: convertToSize(width, defaultWidth),
    height: convertToSize(height, defaultHight),
    position: position,
    title: title,
    };
    Xrm.Navigation.navigateTo(pageInput, navigationOptions)
    .then(function () {
    // Called when page opens
    return true;
    })
    .catch(function (error) {
    // Handle error
    console.log(error.message);
    });
    }
  • FemaleMarvel365 Profile Picture
    FemaleMarvel365 55 on at
    Cannot call a Custom Page from a Custom Main Grid
    I'm having the same issue. I've tried several different scripts to open this custom page, and it is not opening.  I have added the following script as a .js file to the web resources. The page is added to the app. it was originally created from the app. I've tried the script from Microsoft learn as well as the script from the following videos. NOTHING happens and i'm wondering if it's just being blocked somehow or if this feature just doesn't work in gov cloud?  
     
     
     
    I've tried this from Microsoft learn and the button does nothing: 
    // Side Dialog
    var pageInput = {
        pageType: "custom",
        name: "<logical page name>",
    };
    var navigationOptions = {
        target: 2, 
        position: 2,
        width: {value: 500, unit: "px"},
        title: "<dialog title>"
    };
    Xrm.Navigation.navigateTo(pageInput, navigationOptions)
        .then(
            function () {
                // Called when the dialog closes
            }
        ).catch(
            function (error) {
                // Handle error
            }
        );
     
     
     
     
  • AleMar Profile Picture
    AleMar 4 on at
    Re: Cannot call a Custom Page from a Custom Main Grid

    Man just wanted to thank you, you saved my life. I had the very same experience (but with Ribbon Workbench for parameters management), and struggled a lot to make it work. Cheers!

  • Verified answer
    Axal Profile Picture
    Axal 945 on at
    Re: Cannot call a Custom Page from a Custom Main Grid

    Hi @v-xiaochen-msft 

     

    Yeah, actually curios why the script not working. As those two thing you're pointed out, I can confirmed I already did. And since all the related object are in my Solution, I did using the Publish all customization to make sure nothing left behind.

     

    FYI, after the re-create and succeeded with other script, I tried to re-do again and this time still using the non-working script, but it turns out still not working.

     

    I will close it after a while later.

     

    Thanks

     

  • Re: Cannot call a Custom Page from a Custom Main Grid

    Hi @Axal ,

     

    Glad to see the issue has been solved.

    You could mark the correct reply to close the case.

    Besides, I think the error may be caused by the following points:

    1\ After you have applied the js for your mda, you may need to refresh the page a few times for it to work due to the cache.

    2\ Maybe you didn't publish all your components correctly, like your js resources...

     

    Best Regards,

    Wearsky

  • Axal Profile Picture
    Axal 945 on at
    Re: Cannot call a Custom Page from a Custom Main Grid

    Hi,

     

    Not sure what happened, but I re-do all my work again including create new Custom Page and Web Resource, but I changed the script with the one with the context ->

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

     

    This one is working.

    Since the previous script is actually for testing only so probably I can say it is solved. Although I'm still curios why it is not working. 

     

    @Mira_Ghaly Thanks for your help.

  • Axal Profile Picture
    Axal 945 on at
    Re: Cannot call a Custom Page from a Custom Main Grid

    Hi @Mira_Ghaly 

     

    I think there is no such question a silly question to me, in fact I did remember there was once we need to register first the Web Resource in the related Model-driven form, do I still need that ? For the "edit main grid" it self, I can't see any register except the "+ Add Library" button which the place I select my newly created Web resources.

     

    For the solution, I add the new Web resources from my solution, so it already inside my solution. And I also try to "Publish all customization" from the solution, just to try my luck, but none of this work. It seems the new button really do nothing.

     

    Appreciate any help and suggestion, so feel free to ask anything as I ran out of idea now. It is very easy if looking at Reza's video or other same video about this "commanding"

     

    Thanks

  • Mira Ghaly Profile Picture
    Mira Ghaly 11,409 on at
    Re: Cannot call a Custom Page from a Custom Main Grid

    @Axal 

    It might be a silly question have you added the Javascript as a web resource first to the solution?

     

  • Axal Profile Picture
    Axal 945 on at
    Re: Cannot call a Custom Page from a Custom Main Grid

    Thanks, I changed the script accordingly, It looks like the script has never been called as the alert not shown. 

    Anything wrong with step ? 

    • Go to my Model-driven, Edit in Preview, look for my menu (Subarea), click three dots for Edit command bar

    Axal_0-1651701463107.png

     

    • Choose Main Grid
    • Choose Add Command for new command button in that main grid.
    • Set for calling the Web resource ->

    Axal_1-1651701463624.png

     

    • Save and Publish

     

    I tried to just change the command (button) text to just make sure this Model-driven is published and it is opened the new one, which it did. But the button still nothing when it is click.

     

  • Mira Ghaly Profile Picture
    Mira Ghaly 11,409 on at
    Re: Cannot call a Custom Page from a Custom Main Grid

     

    @Axal 

    I noticed a syntax error and add a bit of modification as well as the Alert so that you can try at your side and trouble shoot it  a bit further

    function OpenCanvasExpense()
    {
    alert("Function Open Canvas App Called");
    var pageInput = {
    	pageType: "custom",
    	name: "new_newexpensecustom_e990e"
    };
    var navigationOptions = {
    	target: 1,
     width: 800, // value specified in pixel
     height: 700, // value specified in pixel
     position: 1
    };
    Xrm.Navigation.navigateTo(pageInput, navigationOptions)
    	.then(
    		function () {
    		{
    	).catch(
    		function (error) {
    		}
    	);
    }

     

     

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

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

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,475

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,767

Leaderboard

Featured topics