cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Axal
Impactful Individual
Impactful Individual

Cannot call a Custom Page from a Custom Main Grid

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...  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

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Axal
Impactful Individual
Impactful Individual

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

 

View solution in original post

9 REPLIES 9
Mira_Ghaly
Dual Super User
Dual Super User

@Axal 

For troubleshooting can you add an alert at the beginning of your JavaScript function to see if it is called from the command or not?

If this post helps you with your problem, please mark your as Accepted solution.If you like my response, please give it a Thumbs Up.

Blog: here
Axal
Impactful Individual
Impactful Individual

Hi @Mira_Ghaly or anyone 

 

I'm sorry, I'm not really understand Javascript, where actually I can put the Alert ? of this code :

 

 

function OpenCanvasExpense()
{
var pageInput = {
	pageType: "custom",
	name: "new_newexpensecustom_e990e",
};
var navigationOptions = {
	target: 1
};
Xrm.Navigation.navigateTo(pageInput, navigationOptions)
	.then(
		function () {
		{
	).catch(
		function (error) {
		}
	);
}

 

 

Thanks

 

@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) {
		}
	);
}

 

 

If this post helps you with your problem, please mark your as Accepted solution.If you like my response, please give it a Thumbs Up.

Blog: here
Axal
Impactful Individual
Impactful Individual

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.

 

@Axal 

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

 

If this post helps you with your problem, please mark your as Accepted solution.If you like my response, please give it a Thumbs Up.

Blog: here
Axal
Impactful Individual
Impactful Individual

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

Axal
Impactful Individual
Impactful Individual

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.

v-xiaochen-msft
Community Support
Community Support

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
Impactful Individual
Impactful Individual

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

 

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (3,130)