Automated Testing with Permissions

This is the first part of Automated testing with Permissions, in this post I’ll visualize and explain the way it’s described on msdn and in part two I’ll go for a more practical approach which will support permissions per test function and partially executing code with a permission set.
(more…)

MS Connect Suggestion: Select multiple records on a TestPage object

Here’s another suggestion for the automated testing framework: a select function on a TestPage object.

In some cases you might face a (runmodal) page where a user has to select one or more records and based on that selection an action is performed, right now it’s not possible (correct me if I’m wrong) to actually simulate this with a TestPage object.

Please vote here or leave a comment.

 

NAV2017 Notifications Part 3: more about the ID

So today a colleague referred me to this page on MSDN where it states the following about the ID:
If left unassigned the notification will be assigned an ID when the SEND method is called. For more information, see SEND Function (Notification).

So this sounds like giving your own unique ID to the notification is not that necessary at all, right?

After some testing it appears not to be that easy..
As I mentioned in my first blog post about notifications a notification without a unique ID can cause a huge stack of duplicate notifications on your screen and we DO NOT want that at all.

If you leave the ID empty and you let the SEND function generate an ID for you, the ID will be kept in memory BUT only if the notification variable is kept somewhere global (I hope you won’t even consider doing this)
You can think of all kind of fancy functions that will return the ID that the SEND function has generated for you, but in my perception the way to go is to create a function per notification to retrieve the hard coded guid.
P.S. this is also the way Microsoft is doing it.

MS Connect Suggestion: Disable GUI in Test Functions

Since C/AL unit tests run in a client session GUIALLOWED will always be TRUE, if code behaves differently in case of GUIALLOWED = FALSE it’s not possible to actually test that code.

Especially when testing web services it would be great if you could just disable the UI in a test function.

Please vote here!

A bit off topic but in my opinion it should be possible to run unit tests without UI, how cool would it be if you can just call the Invoke-NAVCodeunit Cmdlet to test your code!?
Technically this is possible but a lot of standard NAV tests will fail because of unexecuted UI handlers…

Web Client dynamic visibility of fields and page actions

Dynamic visibility of fields and page actions behave different in the web client, make sure you are aware of the following limitations.

Fields:
– Code in the visibility property will not work
– Using a variable to determine visibility only works once
– On a group this works as expected, workaround is to give those fields their own ‘invisible’ group

Page Actions:
– Code in the visibility property only works once
– Using a variable to determine visibility only works once
– Giving these page actions their own group works but images are not shown correctly, no-go
– Use the enabled property as a workaround, this behaves as expected (Microsoft is doing the same)

Also check out this post from Arend Jan Kauffmann

Responsibility Center fun! :)

A colleague of mine came across this issue which looked like a bug at first.
When I for example have two posted credit memos within a different resposibility center than I’ve set up in for myself or in the company information, this will happen…
funwithresponsibilitycenter

This is probably in the application for ages but shouldn’t NAV be intuitive? Since we’ve got notifications now, I would at least expect a notification why some documents are not shown when for example navigating to the Posted Sales Credit Memos list OR completely integrate responsibility centers and let the factbox take the responsibility centers into account (which is a lot of work since this cannot be done with the current FlowFields)

NAV2017 Notifications Part 2: Adding a notification to table 1518 My Notifications

Now we have to decide wheter or not we want add our new notification to table 1518, adding it means we give the user the possibility to disable and add extra conditions (depending on the function we use to add it) to the notification.
notificationspart2-2

In order to add our new notification in table 1518 we have to create a new subscriber function which subscribes to the event called OnInitializingNotificationWithDefaultState in page 1518.
Now we’ve got two functions in table 1518 to choose from:
InsertDefault (basic notification)
InsertDefaultWithTableNum (conditional notification)

If we decide to give the user the possibility to disable the notification we should also check if the notification is enabled before sending it.
We can do that by one of the following functions in table 1518:
– IsEnabled (checks if present/enabled)
– IsEnabledForRecord (checks if present/enabled and if conditions were met)
Note: if the notification is not present in table 1518 the functions will return TRUE.

After implementing all of the logic above our codeunit will now look like this:
notificationspart2-3