How can I create a Link in an email that opens a specific page in the Role Tailored Client?
In the Classic Client for Dynamics NAV, and in older versions (4.X, 5.x) when creating emails from C/AL code, we had the possibility to use the Form.URL method and include it into the body of an email. Whenever someone then clicked on the Link, the Classical Client would be opened and the corresponding Form was shown.
In Dynamics NAV 2009, in the Role Tailored Client, the Form.URL method is no longer supported. The RTC does not display Forms, it uses Pages and Pages do not have an URL method.
So, how can we then create a Link towards a specific Page?
To solve this, you have to create the URL as follows: dynamicsnav:////runpage?page=<Page No>&bookmark=<URL>.
But how can we get the BookmarkURL for a specific Page?
Well, what you need to do is use a RecordRef variable that points towards the specific Page and use its RecordId property. The problem might then be that your code is in a Codeunit and can sometimes be called from within a Form or from within a Page. How can you make your code compatible with both environments?
To solve these kinds of issues, in C/AL there's a new function available: ISSERVICETIER:
- If you call ISSERVICETIER from the Classic client, then the function returns false.
- If you call ISSERVICETIER from the RoleTailored client, then the function returns true.
This allows you to execute different code that is based on the client that you are running.
Here's an example of how you can write your code, to be compliant with the Classical Client and the Role Tailored Client:
Keep in mind that in the past (before Dynamics NAV 5.0 and 2009) you could use the"Mail" Codeunit to create and send emails. As from Dynamics NAV 5 and 2009 it is also possible to use SMTP (Codeunit "SMTP Mail") to do this.
In the code example above I used a Mail Codeunit variable to send mail in the Classic Client and I used SMTP for the Role Tailored Client. But of course you can also use SMTP from within the Classical Client.
Recent Comments