cancel
Showing results for 
Search instead for 
Did you mean: 

MDK Dynamic Page

guile_cardoso
Explorer

I have a scenario here where I need to create dynamic pages based on a entity set.

The app will have a Form with N pages (with next, previous actions). And my goal is to create dynamically (with infos from the server via odata) some of these pages, depending on the answer in a field on the very first page.

Is it possible to do that? Or I will need to create all the form pages via metadata?

Accepted Solutions (1)

Accepted Solutions (1)

bill_froelich
Product and Topic Expert
Product and Topic Expert

Yes, it is possible to do that with MDK. You will need to use rules to generate the final page metadata used by the navigation action.

In the Navigation action, there is a PageMetadata property where your rule can return the page JSON to render instead of loading a page from metadata. Note you still need to specify a PageToOpen. For my dynamic pages I just create an Empty.page and use that.

{
    "NavigationType": "Cross",
    "PageMetadata": "/SalesOrder/Rules/GetDynamicSectionTestPage60.js",
    "PageToOpen": "/SalesOrder/Pages/Empty.page",
    "_Type": "Action.Type.Navigation"
} 

You have the option of generating your page completely from scratch, or starting with MDK 6.0 you can create a partial page "template" in the editor and load that as a starting point for your dynamic pages. To make use of this you can call the new clientAPI method getPageDefinition() to return the page as a JSON object. Then insert / update the JSON with the dynamic elements as needed and return the updated JSON.

export default function GetDynamicSectionTestPage60(context) {
    let page = context.getPageProxy().getPageDefinition('/SalesOrder/Pages/SectionTest.page');
    page.Caption = 'Dynamic Section Test Page';
    return page;
}

Please note, that if you are using that MDK page names need to be unique so if you are using the same partial page to generate multiple dynamic page in sequence you will want to change the _Name to be unique and then make sure any target paths reference the dynamic page name.

--Bill

guile_cardoso
Explorer
0 Kudos

Thank you so much!

This is exactly what I expected to have.

-- Guile

Answers (0)