I am unsure whether I understood your posting, but I guess you want to create objects of type "Page" with NAV code?
In this case I have some ideas for you.
If you are trying to copy pages from one version (prior to 2013) of NAV to another, it is sufficient to export the pages as text file and delete / modify all references that will make the object incompatible with newer versions (LookupFormID instead of LookupPageID for example) and import the same objects again. You can realize this with a simple text editor. After importing, try to compile and resolve eventual errors.
If you want to create completely new pages (based on which information? records?), you can code a function that generates text files (https://msdn.microsoft.com/en-us/library/hh167550(v=nav.90).aspx). I don't know whether you'll have all information needed to create the file - in order to verify the feasibility of this method, create your page object manually in the Development Environment, export the object and take a look at the structure of this file.
Since the introduction of the NAV Development Shell (Windows PowerShell), you might be able to completely automate such operations, but I have not tried this for NAV objects yet. (cf. https://navscripts.codeplex.com/ ). I can also recommend Waldo's Blog to get familiar with PowerShell (waldo.be/tag/powershell/)
Hi Sebastien_Konsbruck,
Thanks by your help, but i think I have not explained well after all.
My problem was so simple, i just wanted open an existing page with the RUNMODAL function, but i needed that this new page opened was a blank page for insert a new record.
I solved this creating by code the new header and filtering by the last record, before call the RUNMODAL function.
If somebody have any idea for nex time would be great!
But really thanks by trying help Sebastien.
Best Regards
Jon.
Unfortunately the RunPageMode property is only available in the action designer and is completely left out for access through code.
I am not aware of any way to achieve your goal properly, so doing what you did seems to be the only option left.
I had been in your situation before, and I did as you did, with additional cleanup if the user changed his mind and did not enter a "new" record.
OK, it was the title of your posting that got me confused.
I also don't know a proper way to solve this through code, however, you could use the following work-around which I found here: vjeko.com/blank-by-default
Step 1: Impossible filter condition
Place a filter on the underlying record for the page that is impossible to return results in your scenario.
Example from vjeko: Record.SETFILTER("No.",'<>A&A')
Step 2: Flag the page
Create a flag variable (boolean for instance) on the page (by default FALSE).
When opening the page with your filter from Step 1, set the flag to TRUE, in any other case leave it FALSE.
Step 3: Insert a new record
In the OnInsert trigger of the page, clear the filter again and set the flag to FALSE.
Not sure whether this will still work in newer versions and whether it can be recommended, but apperently it worked in older versions of NAV.
Answers
I am unsure whether I understood your posting, but I guess you want to create objects of type "Page" with NAV code?
In this case I have some ideas for you.
Best regards,
Sebastien
Thanks by your help, but i think I have not explained well after all.
My problem was so simple, i just wanted open an existing page with the RUNMODAL function, but i needed that this new page opened was a blank page for insert a new record.
I solved this creating by code the new header and filtering by the last record, before call the RUNMODAL function.
If somebody have any idea for nex time would be great!
But really thanks by trying help Sebastien.
Best Regards
Jon.
I am not aware of any way to achieve your goal properly, so doing what you did seems to be the only option left.
I had been in your situation before, and I did as you did, with additional cleanup if the user changed his mind and did not enter a "new" record.
OK, it was the title of your posting that got me confused.
I also don't know a proper way to solve this through code, however, you could use the following work-around which I found here: vjeko.com/blank-by-default
Step 1: Impossible filter condition
Place a filter on the underlying record for the page that is impossible to return results in your scenario.
Example from vjeko: Record.SETFILTER("No.",'<>A&A')
Step 2: Flag the page
Create a flag variable (boolean for instance) on the page (by default FALSE).
When opening the page with your filter from Step 1, set the flag to TRUE, in any other case leave it FALSE.
Step 3: Insert a new record
In the OnInsert trigger of the page, clear the filter again and set the flag to FALSE.
Not sure whether this will still work in newer versions and whether it can be recommended, but apperently it worked in older versions of NAV.
Best regards,
Sebastien