Friday, September 7, 2012

PerfectForms – Getting Link to API created Instace

Getting Link to API created Instance.


 

Here are the steps to get this accomplished.

  1. Get the API link for the form.
  2. Get the FormID from the API link. FormID is the one that you will see in the API url after forms/ until the first _ (underscore)
    http://app.perfectforms.com/api/forms/3yjHAlggAggA-gwM_API_Add_Instace.asmx?wsdl In this 3yjHAlggAggA-gwM is the FormID.
  3. First Login to the Application using API login method. On success you will be returned a token, please store that.
  4. Connect to the Forms API and do a ADD passing in the required fields data and the token that you received on the login success.
  5. On success from the Add, instance ID is returned. Store that and the token.
  6. <GetFormInstanceMetaData2Response xmlns="http://www.PerfectForms.com/API" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

      <GetFormInstanceMetaData2Result>0</GetFormInstanceMetaData2Result>

      <tokenOut>gAgC1BItJpQ0PJwa</tokenOut>

      <formInstanceName/>

      <formInstanceNumber>1</formInstanceNumber>

      <formInstanceGUID>50c59769d2f44701956b99cc183941</formInstanceGUID>

      <link>http://app.perfectforms.com/p.aspx?f=od8DhjAgAgAgpAQR</link>

      <stageId/>

      <stageName/>

      <majorVersion>1</majorVersion>

      <minorVersion>0</minorVersion>

    </GetFormInstanceMetaData2Response>


  7.  


     

    This will open the instance that you created.

PerfectForms – Create and Save Form PDF

Getting Form Printed to PDF and Storing in DB or File System.


 

http://app.perfectforms.com/api/api.asmx?op=GetFormInstancePDF


 

Here is the process to get this accomplished.

  1. Create a Webservices Connection to AP. http://app.perfectforms.com/api/api.asmx
    1. Create a new action for Login. Test it with Username, password and the Security Key. Auto complete the Response.
    2. Create a new action for GetFormInstancePDF. Test it and pass in the parameters. Token from the previous login test response, Form ID (how to get it is stated in point 2 below, Specify the width and Height in inches (Typlical 600 by 600 Pixel would be 8 by 8 inches), instanceID as 1 (assuming you have at-least 1 form submitted), section would be complete. You can find the documentation here: http://www.perfectforms.com/Documentation/manual/html/fg_getforminstancepdf.htm , once you test it, do the auto complete on the response.
  2. Create a webservices connection to your webservice which will take string as Parameter. (I guess you need to create this).
  3. Get the Form ID of the form that needs to be printed. You can get it from the API URL of the form, see below. The highlighted one in the URL is the Form ID. http://app.perfectforms.com/api/forms/3yjHAlggAggA-gwM_API_Add_Instace.asmx
  4. Goto the form that needs to be printed automatically.
    1. Add a helper Text fields for the following.
      1. InstanceID
      2. Form ID = Assign the value that you got in step 2.
      3. Multiline text with max chars as 90,000.
      4. tokenOut
      5. FormPrintSubmit and set its default value to 0.
    2. In the Form Load add simple branch behavior to check if the FormPrintSubmit text is empty or 0.
      1. If true don't do anything.
      2. if its false then have a connect command which points to the API connection that was create in step 1.
        1. Do a set field and choose InstanceID field and the value as instance number from the special dropdown.
        2. In the action command choose Login.
          1. In the send parameters – choose formula for all and have the userid, password and Security key entered for each field in the formula window which will pop when you double click on the source against the field.
          2. In the return parameters, choose the tokenout to save the value in tokenout field that you create in Step 3,I,iv.
      3. Add another connection and connect from the above connection to this. Choose the API service on the connection and PDFPrint on the Action.
        1. In the send parameters, choose the tokenin value with the tokenout field.
        2. Assign the formID from the FormID field.
        3. Assign InstanceId from the InstanceID field.
        4. Choose Formula for the section, width and height and set the value in the formula window.
        5. In the return parameters, choose tokenout to be set to tokenout field and pdf value to the pdf multiline text.
      4. Add another connection which will connect to your webservice.
        1. In the send parameters sent the text from the multiline text.
        2. In your webservices it has to convert it as file with pdf extension and then you can save it or send it to another service.
      5. Now add a behavior close which will close the form.


       

  5. in the Button which submits the form choose to re-open the same instance once submitted. Before that add a set field which will set the value 1 to FormPrintSubmit. This will trigger the PDF creation.


 


 

Let me know if this is clear enough to get things done.