Appian Community and Appian Academy are being upgraded. From July 24–August 3, the Appian Community will be in read-only mode. During this time, the site will be read-only and user registration will be disabled. We apologize for any inconvenience this may cause, but a more secure, stable, and performant Community experience is coming soon!
The new Appian Community launches August 3, followed by Appian Academy on August 7. During the migration, Appian Community Edition, Appian Academy, Documentation, Certifications, Instructor-led Customer Training, Partner Sales Training & Accreditation, and Forum (for Appian Partners and Customers only) will remain available.
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
Discussion posts and replies are publicly visible
After exploring different plugins, it appears that the only context injectable in custom functions is com.appiancorp.services.ServiceContext.
Since then, it's possible to retrieve the caller like shown in the next reply.
@Function public TypedValue sysInfo(ServiceContext sc,UserProfileService ups_) throws AppianException { HashMap<TypedValue, TypedValue> ret = new HashMap<TypedValue, TypedValue>(); try { UserProfile profile = ups_.getUser(sc.getName()); if (!profile.getUserTypeId().equals(UserProfile.USER_TYPE_SYS_ADMIN)) { String errorText = "User " + profile.getUsername() + " is not a System Administrator. You must run sysInfo as an administrator."; LOG.error(errorText); throw new Exception(errorText); } .....