Clarity

Expand all | Collapse all

Gel script: How to get the resource ID of the currently logged in user?

  • 1.  Gel script: How to get the resource ID of the currently logged in user?

    Posted Oct 12, 2010 07:08 AM
     Anyone know how to get   the resource ID of the currently logged in user?(I need to look up his/her email address so I can email to them)  Thanks in advance!  BG  


  • 2.  Re: Gel script: How to get the resource ID of the currently logged in user?

    Posted Oct 12, 2010 07:08 AM
     Hi - the processes are not run by the "logged in user", but by the BG server, so you actually need to find the ID of the resource who "triggered" the process.  I'm sure there was a caforums thread on here in the past about this (but I have done a search and can't immediately find it?) - if my memory is right, the resolution was that you had to SELECT it from the process tables on the database.  (and if my memory is wrong; I'm sure that that is the solution anyway!   :-) )  Dave.


  • 3.  Re: Gel script: How to get the resource ID of the currently logged in user?

    Posted Oct 12, 2010 07:08 AM
     Ouch. That's more complex... anyone know what that query would look like?  


  • 4.  Re: Gel script: How to get the resource ID of the currently logged in user?

    Posted Oct 12, 2010 07:08 AM
    Hi,  Pls check the below queries...              
                  -- query to get the user who initiated the process
                  select INITIATED_BY from BPM_RUN_PROCESSES where id= (pass the process id)
                 
                  -- query to get the email of that user            
                  select email from SRM_RESOURCES S where   S.USER_ID = (pass the INITIATED_BY )  cheers,sundar


  • 5.  Re: Gel script: How to get the resource ID of the currently logged in user?

    Posted Oct 12, 2010 07:08 AM
     I tried that query to get the ID of the person who triggered the process... however when I search against id=${gel_processId} I don't get anything...Is there another built in variable that gives the correct ID to search into the BPM_RUN_PROCESSES table.  I'm trying this:   select INITIATED_BY from BPM_RUN_PROCESSES where id=${gel_processId}   and that doesn't work.  Ideas?  


  • 6.  Re: Gel script: How to get the resource ID of the currently logged in user?

    Posted Oct 12, 2010 07:08 AM
    Bump... I've tried a bunch of stuff.. the process ID doesn't appear in the BPM_RUN_PROCESSES record anywhere...    


  • 7.  Re: Gel script: How to get the resource ID of the currently logged in user?
    Best Answer

    Posted Oct 12, 2010 07:08 AM
    Hi Gibson,                                 I have tested in my machine who is initiating the process. please look at the below query.    
        
                  SELECT BRP.ID ID, SRM.UNIQUE_NAME UNIQUE_NAME, SRM.FIRST_NAME FIRST_NAME, SRM.LAST_NAME LAST_NAME FROM BPM_RUN_PROCESSES BRP, SRM_RESOURCES SRM WHERE SRM.ID = BRP.INITIATED_BY
    AND BRP.ID = ${gel_processInstanceId}   
                  ${INITBY.rows[0].ID}
                  ${INITBY.rows[0].UNIQUE_NAME}
                  ${INITBY.rows[0].FIRST_NAME}
                  ${INITBY.rows[0].LAST_NAME}   Process Initiated:     ${UNIQUE_NAME}
    Process Initiated By: ${LAST_NAME}, ${FIRST_NAME}     ThanksSenthil.


  • 8.  Re: Gel script: How to get the resource ID of the currently logged in user?

    Posted Oct 12, 2010 07:08 AM
    the trick here is gel_process INSTANCE id  see: =${gel_processInstanceId}  in Sentil's code above    


  • 9.  Re: Gel script: How to get the resource ID of the currently logged in user?

    Posted Oct 12, 2010 07:08 AM
     Ah yes, perfect!!  The Gel_processInstanceId was the trick. I was using gel_ProcessId.  Is there a list of these available environment variables somewhere?  Thanks all!  B  


  • 10.  RE: Re: Gel script: How to get the resource ID of the currently logged in u

    Posted May 05, 2011 03:37 AM
    Please check if the relation is SRM_Resources.user_id = bpm_run_processes.initiated_by, instead of SRM_Resources.id = bpm_run_processes.initiated_by as stated above.
    I got correct results with SRM_Resources.user_id = bpm_run_processes.initiated_by


  • 11.  RE: Re: Gel script: How to get the resource ID of the currently logged in u

    Posted May 31, 2011 04:58 AM
    The sql can be written to get the resource ID from srm_resource table.
    The user_id can be passed by two ways (select id from srm_resources where user_id =${user_id});
    1.The last_updated_by user can be used in the above query at the user_id.
    2.process initiated by can be taken from the process table.

    I recommend to go with the second option.