on 09-02-2021 11:40 AM
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?
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.