<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>How fast loggedInUser() function is?</title><link>https://community.appian.com/discussions/f/rules/14187/how-fast-loggedinuser-function-is</link><description>I have some UI elements that depends on current user. 
 Should I use loggedInUser() function every time or it&amp;#39;s better to have it saved within load() function and passing as a parameter into inner rules?</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: How fast loggedInUser() function is?</title><link>https://community.appian.com/thread/64144?ContentTypeID=1</link><pubDate>Tue, 22 Jan 2019 16:03:10 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:5e2caf94-0873-4748-9696-04769c06f429</guid><dc:creator>Mike Schmitt</dc:creator><description>I would also add that using a local variable can be very helpful when it comes time to test - in other words, if you need to test a rule or interface&amp;#39;s behavior when it sees a specific username, if you have &amp;quot;loggedinuser()&amp;quot; at several places in your rule/interface, you would need to replace those with the username you want to test, then undo that later.  If you have 1 local variable set, however, you just need to quickly swap in the username to test, then switch it back, all in that one spot.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How fast loggedInUser() function is?</title><link>https://community.appian.com/thread/64143?ContentTypeID=1</link><pubDate>Tue, 22 Jan 2019 15:43:44 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:1410a407-d3de-42f2-82f7-a1801334ba46</guid><dc:creator>Robert Shankin</dc:creator><description>&lt;p&gt;I like how&amp;nbsp;&lt;a href="/members/sriranjanir"&gt;sriranjanir&lt;/a&gt;&amp;nbsp; explains it.:&lt;br /&gt; In general, smart reuse of load variables is an important design practice to be mindful of as unnecessary reevaluation of the same expression or function comes with a cost.&lt;br /&gt; &lt;br /&gt; Another common offender is over use of fn!isUserMemberOfGroup(). This function can get expensive when it&amp;#39;s overused - if a design has this in multiple sections on the same interface, or multiple interfaces in the same process, it might be a good idea to consider how you can test for this early, once, and retain the answer for later use.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How fast loggedInUser() function is?</title><link>https://community.appian.com/thread/64130?ContentTypeID=1</link><pubDate>Tue, 22 Jan 2019 12:09:49 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:90f1a72c-e22a-4bc1-9aba-63c276e6f6f2</guid><dc:creator>sriranjanir</dc:creator><description>Hi Sergeiz,&lt;br /&gt;
&lt;br /&gt;
I would say it&amp;#39;s better to save in local variable and re-use in all places.&lt;br /&gt;
Please paste the below code in expression rule and check time taken.&lt;br /&gt;
CODE 1:&lt;br /&gt;
&lt;br /&gt;
with(&lt;br /&gt;
  local!userLogged: loggedInUser(),&lt;br /&gt;
  local!email: user(&lt;br /&gt;
    local!userLogged,&lt;br /&gt;
    &amp;quot;email&amp;quot;&lt;br /&gt;
  ),&lt;br /&gt;
  local!firstName: user(&lt;br /&gt;
    local!userLogged,&lt;br /&gt;
    &amp;quot;firstName&amp;quot;&lt;br /&gt;
  ),&lt;br /&gt;
  {&lt;br /&gt;
    local!email,&lt;br /&gt;
    local!firstName&lt;br /&gt;
  }&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
Time take : &amp;lt;5ms&lt;br /&gt;
&lt;br /&gt;
CODE 2:&lt;br /&gt;
&lt;br /&gt;
with(&lt;br /&gt;
  local!userLogged: loggedInUser(),&lt;br /&gt;
  local!email: user(&lt;br /&gt;
    loggedInUser(),&lt;br /&gt;
    &amp;quot;email&amp;quot;&lt;br /&gt;
  ),&lt;br /&gt;
  local!firstName: user(&lt;br /&gt;
    loggedInUser(),&lt;br /&gt;
    &amp;quot;firstName&amp;quot;&lt;br /&gt;
  ),&lt;br /&gt;
  {&lt;br /&gt;
    local!email,&lt;br /&gt;
    local!firstName&lt;br /&gt;
  }&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
Time Taken: 5ms&lt;br /&gt;
&lt;br /&gt;
Hope this helps.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>