{"id":251,"date":"2019-11-01T13:55:59","date_gmt":"2019-11-01T13:55:59","guid":{"rendered":"https:\/\/sdf-docs.mansystems.com\/docs\/acr-rules\/reliability\/system-processes-using-currentuser\/"},"modified":"2020-03-20T08:44:58","modified_gmt":"2020-03-20T08:44:58","slug":"usersystemcontext","status":"publish","type":"docs","link":"https:\/\/sdf-docs.clevr.com\/?docs=acr-rules\/reliability\/usersystemcontext","title":{"rendered":"Variable CurrentUser should only be used in a user context"},"content":{"rendered":"\n<p>Microflows in Mendix have access to two special variables, <em>currentUser,<\/em> and <em>currentSession<\/em>. The value for these variables is based on the user that initiated the microflow by clicking a button for example. <br>However, microflows can also be initiated by the system such as in scheduled events or integration endpoints such as rest. <\/p>\n\n\n\n<p>When microflows are called by the system the value for currentUser and currentSession is empty so they should not be used.<\/p>\n\n\n\n<p><strong>Noncompliant example:<\/strong><\/p>\n\n\n\n<p>(assuming a microflow called from a scheduled event)<br><code>if $currentUser\/HasFlag then 'Foo' else 'Bar'<\/code><\/p>\n\n\n\n<p><strong>Compliant example:<\/strong><\/p>\n\n\n\n<p>Not using the currentUser or currentSession variable in any way in microflows called by the system.<\/p>\n","protected":false},"featured_media":0,"parent":97,"menu_order":34,"comment_status":"open","ping_status":"closed","template":"","doc_tag":[],"class_list":["post-251","docs","type-docs","status-publish","hentry"],"comment_count":0,"_links":{"self":[{"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/251"}],"collection":[{"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/types\/docs"}],"replies":[{"embeddable":true,"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=251"}],"version-history":[{"count":5,"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/251\/revisions"}],"predecessor-version":[{"id":975,"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/251\/revisions\/975"}],"up":[{"embeddable":true,"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/97"}],"next":[{"title":"Variables should not be self-assigned","link":"https:\/\/sdf-docs.clevr.com\/?docs=acr-rules\/reliability\/variableassignedtoself","href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/606"}],"prev":[{"title":"Type parameters in a java\/script action should be used","link":"https:\/\/sdf-docs.clevr.com\/?docs=acr-rules\/reliability\/unusedtypeparameter","href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/655"}],"wp:attachment":[{"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=251"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=%2Fwp%2Fv2%2Fdoc_tag&post=251"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}