6 Replies Latest reply on Apr 8, 2008 11:52 AM by Jasmin Charbonneau

    Prepopulating Flex application

      Hi,

      I am using flex applications for designing forms for Licecycle ES.
      I have a problem about prepopulation of forms.

      For XDP forms, I could prepopulate forms using render pdfform service.
      But for rendering Flex forms, I could only see Read resource content service which only gets the application from defined resource.
      And as I know, it has no capability of merging template and form data as I did for XDP forms.

      For example my current problem is when process creator opens a form to initiate a process, I want to prepopulate the form with some userss
      İnformation like name, departmet etc..

      Is there any method to propose to solve this problem?

      Note : As my flex form is opened in workspace (which is also a flex application ), and in workspace application I could see the username (commonname), may be it is possible to get this variable of parent applications from my flex form. If it is defined public..
      Anyone knows how can I reach this variable?

      Thanks in advance

      Regards

      Cihan
        • 1. Re: Prepopulating Flex application
          Jasmin Charbonneau Level 4
          There is a way to do that. This is an extract from an email one of my colleague on the subject:

          In your Flex form you will make use of the FormConnector (see Flex Language Reference under lc.core.FormConnector which is used to simplify communication between Flex app and Workspace ES) that exposes three events (formInitiallData, formSaveDataRequest, formSubmitDataRequest). This will let you run a function when the Flex form initializes in Workspace - -the goal of that function will be to make a call to retrieve the data required and merge it into the Flex form.

          In order to retrieve the data required for pre-population a common need would be to retrieve data related to the logged in user making the start form request. This information is not known to your Flex Form but is known to the Workspace ES Flex application that is hosting the form. So what you will need to do here is gain access into the Workspace application to retrieve the current session. From that current session you can extract the id (sessionManager.authenticatedUser.oid) of the current user. This will be an argument to your function calling some external source for data to be pre-populated.

          You can now make a call to the data source to retrieve the data you want. For example, call a LC process that is exposed as a Web Service taking as its input a users id (the oid you retrieved from the session) whose steps will make the call to the directory server and get the info you need (e.g. department, manager, employee id, etc.) to prepopulate and return it back to the Flex form.

          I do not have a working sample of this but below is a portion of sample code that would be in the Flex form and reflects what was discussed above.

          <mx:Application

          xmlns:mx="http://www.adobe.com/2006/mxml"
          xmlns:lc="http://www.adobe.com/2006/livecycle" creationComplete="connector.setReady()" width="100%" height="100%">

          <lc:FormConnector id="connector"
          formInitialData="initialData(event)"
          formSaveDataRequest="returnFormData(event)"
          formSubmitDataRequest="returnFormDataForSubmit(event)"/>

          <mx:Script>
          <![CDATA[

          import lc.domain.SessionMap;
          import lc.core.ISessionManager;

          private function getUserId():string

          {
          var session:SessionMap = SessionMap(Application.application.session);
          var sessionManager:ISessionManager = ISessionManager (session.getObject("lc.core.ISessionManager"));

          return sessionManager.authenticatedUser.oid;

          }

          Private function prepop(userId:String):XML
          {
          \\add code to call Web Service and retrieve info to prepopulate (in our example à name, dept, mgr)
          }

          private function initialData(event:DataEvent):void
          {
          if (event.data != null && event.data != "")
          {
          xmldata = new XML(event.data);
          }
          else
          {
          var myUID:String = getUserId();
          xmldata = prepop(myUID);
          }
          }
          ]]>

          </mx:Script>



          <mx:VBox horizontalCenter="0" verticalCenter="0" width="100%" height="100%">

          <mx:Form id="theForm" backgroundColor="0xffffff" width="100%" height="100%">

          <mx:FormHeading label="My form"/>
          <mx:FormItem label="Name" required="true">
          <mx:TextInput id="userName" text="{xmldata.name}" change="xmldata.name = userName.text; connector.setDirty()"/>

          </mx:FormItem>

          <mx:FormItem label="Name" required="true">
          <mx:TextInput id="userDepartment" text="{xmldata.dept}" change="xmldata.dept = userDepartment.text; connector.setDirty()"/>
          </mx:FormItem>

          <mx:FormItem label="Name" required="true">

          <mx:TextInput id="userManager" text="{xmldata.mgr}" change="xmldata.mgr = userManager.text; connector.setDirty()"/>
          </mx:FormItem>
          </mx:Form>
          </mx:VBox>
          </mx:Application>

          I hope that helps.

          Jasmin
          • 2. Re: Prepopulating Flex application
            Level 1
            Hi Jasmin,

            Thank you very much for your great help.
            This realy helped much.

            King regards

            Cihan Aydın
            • 3. Re: Prepopulating Flex application
              Hi Jasmin,

              from what I know, the WebService object only accepts username and password in setCredentials() method.

              How do you pass in oid for credentials then?
              • 4. Re: Prepopulating Flex application
                Jasmin Charbonneau Level 4
                I'm not sure I know what oid is?

                Jasmin
                • 5. Re: Prepopulating Flex application
                  Level 1
                  Hi Jasmin,

                  As you mention in the above reply that, you use getUserId() function
                  to return " sessionManager.authenticatedUser.oid ". This is the "oid" that i mention above.

                  you said in the above explaination that
                  "You can now make a call to the data source to retrieve the data you want. For example, call a LC process that is exposed as a Web Service taking as its input a users id (the oid you retrieved from the session) whose steps will make the call to the directory server and get the info you need (e.g. department, manager, employee id, etc.) to prepopulate and return it back to the Flex form"

                  So i am keen to know , how should i pass in oid for credentials then?

                  Thanks
                  • 6. Re: Prepopulating Flex application
                    Jasmin Charbonneau Level 4
                    Sorry Asus,

                    I read the post again and the oid now makes sense!

                    So, that code I posted will give you the oid of the user. If you need to get other information about the user, you'll need to call a service that will take a iod as an input parameter and return you the desired value.

                    How you build that service to get additional information about the user is up to you. It could be LiveCycle process that queries the database based on that iod and returns you other values. It could be a servlet that calls the user manager API. Bottom line you would pass the iod as an input parameter to a service. You wouldn't user the iod as a method of authentication against a web service.

                    Jasmin