<?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 to retrieve the calling User in a custom function without passing it as a parameter ?</title><link>https://community.appian.com/discussions/f/plug-ins/20330/how-to-retrieve-the-calling-user-in-a-custom-function-without-passing-it-as-a-parameter</link><description>Hello, 
 Could you please tell me how can i retrieve the caller of a custom function inside this function (in java) ? I would like to check at least if he has the sysadmin rights. 
 Thanks in advance 
 David</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: How to retrieve the calling User in a custom function without passing it as a parameter ?</title><link>https://community.appian.com/thread/79323?ContentTypeID=1</link><pubDate>Wed, 03 Feb 2021 13:57:36 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e4565c49-a758-4a03-b189-e232537fa5c9</guid><dc:creator>davidl0016</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="java"&gt;
	@Function
	public TypedValue sysInfo(ServiceContext
			  sc,UserProfileService ups_) throws AppianException {
		HashMap&amp;lt;TypedValue, TypedValue&amp;gt; ret = new HashMap&amp;lt;TypedValue, TypedValue&amp;gt;();
		try {
			
			UserProfile profile = ups_.getUser(sc.getName());
			if (!profile.getUserTypeId().equals(UserProfile.USER_TYPE_SYS_ADMIN)) {
				String errorText = &amp;quot;User &amp;quot; + profile.getUsername()
						+ &amp;quot; is not a System Administrator.  You must run sysInfo as an administrator.&amp;quot;;
				LOG.error(errorText);
				throw new Exception(errorText);
			}
			
	.....		
	
	&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to retrieve the calling User in a custom function without passing it as a parameter ?</title><link>https://community.appian.com/thread/79322?ContentTypeID=1</link><pubDate>Wed, 03 Feb 2021 13:56:41 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:1acf9840-1106-4be7-8f60-56e97a99736b</guid><dc:creator>davidl0016</dc:creator><description>&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;After exploring different plugins, it appears that the only context injectable in custom functions is&amp;nbsp; com.appiancorp.services.ServiceContext.&lt;/p&gt;
&lt;p&gt;Since then, it&amp;#39;s possible to retrieve the caller like shown in the&amp;nbsp;next reply. &lt;/p&gt;
&lt;p&gt;&lt;u&gt;&lt;span style="font-size:small;"&gt;&lt;/span&gt;&lt;/u&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>