AnsweredAssumed Answered

Get ID from currently logged user

Question asked by juan.segovia on Dec 11, 2013
Latest reply on Dec 12, 2013 by juan.segovia

Hi, I was wondering if you can tell me how can I get the user_id of the currently logged user to add this to a custom attribute on the project object.

The situation is this: I have a custom attribute and I want to kind of copy the audit functionality and every time someone changes a value on this filed get the user_id of that person and add that to another custom field on my project object.

I tried to achieved this with a GEL Script and actually usng the audits table. This is what i wrote:

<gel:script xmlns:core="jelly:core" xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary" xmlns:soap="jelly:com.niku.union.gel.SOAPTagLibrary"
  xmlns:sql="jelly:sql" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <gel:setDataSource dbId="niku" var="dataSource"/>
  <sql:update dataSource="${dataSource}">
   UPDATE niku.ODF_CA_INV
   set   osde_realizado01 = (select last_updated_by
from niku.cmn_audits
where table_name = 'odf_ca_inv'
and attribute_code = 'osde_estado01')
   where  ID = ${gel_objectInstanceId}
 </sql:update>
</gel:script>

This worked fine only the first time. Once I have more than one record on my cmn_audits table for that attribute if fails.

I was wondering if there is any easier way to achieve this (without envolving the audits table) o any modification I can make to this GEL so it works every time.

Regards,

Juan

Outcomes