Null pointer exception from policy xpress iterator object

We have a policy which fetches provisioning roles for a user and processes it further. Things work fine as long as the user has 1 or many roles but when the user has no role and the policy fires, it ends in exception.

Each criterion is evaluated in sequence, so testing Role_Admin_Email value is the first criterion.

But this Role_Admin_Email value is taken from the Custom Field of each role into the iterator. So when the list is empty it fails on the first condition.

Resolution:

Understanding the cause of this issue; you must put the major test against get_Role_List ahead into the AND conditions sequence because if get_Role_List equals "" then the next test will not be done and so you will not get any exception.