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.

Get current Workspace user

Avatar

Former Community Member
Hello



I'm trying to prepopulate the form which is opened in Workspace with current user data.

I guess it could be done by modifying the Workspace to "inject" user data to the form but I feel there should be an easier way.

Is it possible to get the user data from PDF's JavaScript?



Thanks,

Bartek
12 Replies

Avatar

Level 10
Since the user information is probably on the a DB or something, you want to do that server side.



Now, in order to show your form in workspace, you need to create a variable of xfaForm set to IN (I'm making the assumption you're using an XDP). If you go under Advanced Settings when you create that variable, you can associate a render service that will take care of rendering the form back to workspace.



You can use the Sample Form/Render PDF Form service to render your XDP. What you can do is add a new parameter to the Sample Form/Render PDF Form called User ID and then from the Advanced setting pass the Task -> User's Id value to the render service.



The render service can use that value a make a database call or something to create a XML that can be pass to the renderPDFForm operation to merge with you form template to create the appropriate PDF.



The PDF will then be returned back into workspace, already pre-filled with information.



Jasmin

Avatar

Former Community Member
We've tried modifying the rendering service but I it seems there were some bugs in 8.0.0.



I'll try again with 8.0.1. Thanks :)

Avatar

Former Community Member
Hi,



I am newby on Livecycle,

and currently trying the same thing. Prepopulating my form with user information when first user (starter) opens the form from workspace.



I did the things proposed by Jasmin.

Now I set

userID -- task -- user's id



as proposed, in Sample Form/Render PDF Form.



It's ok. I mean no error. I can open the form from workspace.

What I want to do is to get the username from user ID, and put it

in a field in the form that user can see his name when he/she opens

the form.



Could you please tell me how can use this variable to get the user name and how to set it to the field in my form.



Thanks in advance



Cihan

Avatar

Level 10
Cihan,



Instead of using task--user's id you can choose task--User's Common Name



Jasmin

Avatar

Former Community Member
Hi Jasmin,



Ok, I changed it to Users'common name.

As far as I understand, I pass this parameter to the Render PDF Form

service. But the thing that I could not imagine is how can I assign this variable to a field in my XDP form?



Let me explain a bit my case.

I have created a variable on (userID) Render PDF Form. Than, from my

workflow, I choose that service as rendering service. Than, using advanced settings, I set this parameter that it has user's common name. Now at the PDF rendering service, I have tih input parameter filled with user's name. So, how can I assign this value to a field in my form?



Thanks&Regards



Cihan

Avatar

Level 10
First a little bit of theory on LC Forms.



The Forms service essentially take a template (XDP) and data (XML) and merge it together to create an output (PDF, Form Guide, HTML, etc).



Now the xml that corresponds to the data need to follow a certain structure to merge properly with the template. This is defined when you create your XDP by either choosing a schema or to ensure the XML matched your XDP structure.



Now, when you define the Sample- Forms/RenderPDFForm Service parameter, you pass the Form URL and the data is passed as part of the inDocData. At that point the inDocData might be empty because you don't have the user name yet and it's the first step of the process. The user name is being passed through another parameter that you probably defined in your RenderPDFForm service (create a new IN variable of type string called UserName).



So when you get in the Sample - RenderPDFForm service, you have a form URL (formURL), a data variable (inDataDoc) that's probably blank and a string variable that contains the name of the user. You need to put that user name in the InDataDoc variable because that's what Render Form uses to merge with the template.



It is up to you to populate the inDataDoc variable with valid XML data that once merge with the template will put the value in the appropriate fields. I would recommend to use a SetValue operation to set the inDataDoc variable with valid XML which would contain the name of the user you passed as a parameter.



There is a lot of information in here. I'll let you digest it and let me know if you're not clear on some aspect.



Jasmin

Avatar

Former Community Member
Hi Jasmin,



Thank you very much for your great help.

Now I got the idea. I tried a sample and it'is successfull



Best regards



Cihan

Avatar

Former Community Member
Does anyone have more detailed info they could share on doing this? I am very very new at this and running LCES 8.1.



I have tried with no luck.



Thanks in advance!



John

Avatar

Level 8
Level 8
Hi all,



This post was very helpul to me - however I am just wondering if it is a good idea to populate the "Samples - RenderPDF Form" service with all kinds of database lookup and other stuff.



Would it be a good idea to create separate copies of the "Samples RenderPDF form" service and assign them to the specific xfaforms that I use (eg. one for the input form (which can add username and other stuff) and another one for other xfaforms). Or couldn't it be an idea to change the "inDocData" from "Form Data" to an XML variable with the specific user settings already inserted (in your own process I mean). Off course you have to update your XML-variable with the "new" values after each "Assign User Task" service.



What is best practice here?



Sincerely

Kim Christensen

Avatar

Former Community Member
I got everything to working using an example. MY problem is when I am submitting this form and it is received by another user they are not getting any data in this form. I believe it is trying to use rendering service not only when you are rendering form for the firsttime but every single time after that.

Avatar

Level 2
Hi Ashish I am facing with the same issue. did you manage to get the data in the subsequent stages?



Thank you in advance

Avatar

Level 10
Make sure the inDataDoc parameter of the render service is set to Task-> Form Data.



Jasmin