When creating a PRA ([Privileged Routine Application](https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls?KEY=TSQS_PRA_Overview); which by the way is not relevant just for Routines but also for Classes/Methods), it is important to make sure you include a [**new $ROLES**](https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls?KEY=RCOS_vroles#RCOS_vroles_new_roles), before calling [AddRoles()](https://docs.intersystems.com/irisforhealth20222/csp/documatic/%25CSP.Documatic.cls?LIBRARY=%25SYS&PRIVATE=1&CLASSNAME=%25SYSTEM.Security#AddRoles). For example:
 <span class="hljs-keyword">new</span> <span class="hljs-built_in">$ROLES</span>
 <span class="hljs-keyword">set</span> status=<span class="hljs-built_in">$System</span>.Security.AddRoles(<span class="hljs-string">"MyPrivilegedRoutineApplication"</span>)
This way you ensure that indeed the added (elevated) roles "evaporate" for the User running this code, once the User is out of the scope of that routine/method. [Thank you @Andreas.Dieckow for validating this]