Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Getting the Current User

Avatar

Former Community Member
Hi



I am trying to obtain the id of the current user. This is a topic that has come up several times before, such as http://www.adobeforums.com/webx/.3bc480d1 and http://www.adobeforums.com/webx/.3bc6f7a8.



I want to be able to adapt my render service, so that I can copy the current user's id into the AWS_ASSIGNED_ID field.



The first post (http://www.adobeforums.com/webx/.3bc480d1) suggests modifying the render service by creating a new variable "to which you could pass Task -> User's ID.".



Can somebody please explain how I "pass Task -> User's ID" to a variable?



Many thanks.
8 Replies

Avatar

Level 10
Add a new in parameter of type string to the Render service you're using.



Then pass Task->User's ID for it.



That new IN varibale will contain the User's ID.



Jasmin

Avatar

Former Community Member
Thanks for your reply.



I still do not understand how I pass the user's id.



I am using the standard "Render PDF Form - 1.0" process (under Samples - Forms) to render the form, which has three steps (Set params for Forms, render Form and Workspace enable Form), along with some variables.



I can create a new variable, but do not understand how I can set it to the User's id. Should I be setting the value in the "set Params for Forms" step? This allows me to set the variable to an XPath expression, which provides me with a series of options, such as creator_id, formURL etc, however none of these represent the user's id.



Can't see what am I missing.

Avatar

Former Community Member
First off, you should create a new service based on "Render PDF Form - 1.0" rather than modifying the original.



Add the new variable and make it input. In your main map, you should have a variable for your form. Edit that variable and click advanced. Enable Render Service. By default, it will choose "Render PDF Form - 1.0". Take a screen shot of that so you can see all the parameters then browse to the new service you created. All the parameters will be blank which is where the screen shot comes in. It will have one extra parameter, the input variable you added. Set it to task, User's ID or User's Name.



Note that if you use the form variable in later User Assignment steps, the same Render Service will be used there as well. In my custom render, I have a conditional route so the form is only pre-filled the first time.

Avatar

Former Community Member
"Default Render ES Update1" already maps the variable assignedUserID. You would only have to add one if you wanted name. If you want anything else, you can add a lookup in a custom service based on ID.

Avatar

Former Community Member
Thanks for the email. I have successfully followed your instructions, however I am still unclear how to get the user id from the rendering service to the process or form.



I did try your suggestion of using the Default Render ES Update1 service to render the form, however this causes the form to crash with the error ALC-WKS-007-040, after which I had to reboot my server.



What I would like to do is to use the technique in the Default Render ES Update1 rendering service in the service I am using (Render PDF Form Extended, which I have based on Render PDF Form as you suggested), however I am unable to understand exactly how to do this.



I did try another approach which was to use a simple process which simply passes back the @creatorid variable, which I then wrap up into a web service that I call from the form, on the hope that the creator of this small process when called in this way will be the current user. However, if I run this process as Invoker, it fails to work (in the log there is the error No credentials or Context set while invoking service), whilst if I specify that it should run as System or Named User, the creator id comes back as the id of the system account/name user.



Another approach would be to query the tables. I would assume that the id of the user to which a process is currently assigned must be available somewhere, however I have been unable to find any suitable documentation on the database structure.



Can you please advise where to go from here.



Can I please suggest that Adobe produce and make available a standard rendering service which covers all the most common basic requirements.

Avatar

Former Community Member
If you are getting the information you want over to the render service then you would use an XPath expression in a SetValue step to put it into the form. Here are some examples in one I wrote:



Location: /process_data/tempXML/xdp/datasets/data/Formdata/requestor

Expression: /process_data/@userName

Location: /process_data/tempXML/xdp/datasets/data/Formdata/date

Expression: current-date()

Location: /process_data/@inDocData

Expression: /process_data/tempXML



I'm not sure why I put the values into tempXML first as opposed to directly into inDocData. It may just have been because I have a schema associated with the tempXML variable making it easier to use in the XPath builder.

Avatar

Former Community Member
Hi



Would it be possible to make an example available somewhere? - It looks like this is something a number of people are struggling with.



I think all we need is an extension of an extension of the Render PDF form service, plus a small process which reads the current user's id into a variable. This could then be made available as an archive.



As I say, I think it would be sensible to include this as a standard part of the default rendering service in future releases.



Many thanks

Avatar

Former Community Member
Are you using an XDP or a PDF? I did not realize when I posted about it that using an XDP with 'Default Render ES Update1' will give ALC-WKS-007-040 when opening the form. Follow the steps in my first post based on 'Default Render' unless you have installed Patch 1 and now 'Default Render ES Update1' and 'Default Render' are the same. Samples - Forms, Render PDF Form is similar to the original Default Render.



Realize that your main workflow map is not run until you hit complete on the form. Your main map has a form variable (probably xfaForm) that is defined as input and required. The render service defined in the advanced tab of that variable defines the service that is run when you click on the item in workspace. Turn on record in workbench on both your process and on the render service you are using. Then you can play them back and understand the sequence of steps.