2 Replies Latest reply: Aug 11, 2014 3:29 PM by Jo_2013 RSS

    Delete Data Connection for merged record form via scripting

    Jo_2013 Community Member


      I have a livecycle designer form connected to a OLEDB data base (data base connection name is MailMerging).

       

      This form is required to merge multiple fields of data and then create new forms to be distributed for each client to fill in and return.

       

      I have a button on the form which loops through the records, saves the form for each record and makes the mail merging buttons invisible to the end user.

       

      This part of the script works ok.

       

      I need for the data connection to be deleted/disabled for the newly generated forms which are to be issued to the client.

       

      I used the xfa.sourceSet.MailMerging.close(); type of javscript but when the newly generated form is opened the data connection is still there.

       

      Can anyone please provide assistance in how to correctly remove the data connection via scripting, any help most appreciated.

       

      thank you.

       

      Script as follows for the Merge records button:

       

      var count = 0;

      while (!xfa.sourceSet.MailMerging.isEOF())

      {

      \\  Make merging buttons invisible

      First.presence = "invisible";

      Next.presence = "invisible";

      Previous.presence = "invisible";

      Last.presence = "invisible";

      Mergebutton.presence = "invisible";

       

      \\ this is the part that does not work the data connection is still connected in the saved form

      xfa.sourceSet.MailMerging.close();

       

      \\ saves the record as a new form (this is part of a folder level script)

      event.target.savemydocs(event.target);

       

      count++;

       

      xfa.sourceSet.MailMerging.next();

      }

        • 1. Re: Delete Data Connection for merged record form via scripting
          radzmar Community Member

          Hi,

           

          there is no scripting method to delete a data connection I'm afraid.

          The only thing that will work is printing the form as a new static PDF:

          • 2. Re: Delete Data Connection for merged record form via scripting
            Jo_2013 Community Member

            Thank you for your reply.

             

            With the "while" loop I have found it will iterate through the records remove the buttons and save the form but does not stop at the last record, it wants to continue and the following error message appears in the console.

            GeneralError: Operation failed.

            XFAObject.next:28:XFA:form1[0]:RFT1[0]:MailMerge[0]:click

            next operation failed.  [Microsoft][ODBC Excel Driver] Cannot update '(expression)'; field not updateable.

             

            Can you advise how I would revise the while loop statement please?

             

            I am not sure what I am going to do about the data connection, the form fields need to stay live as the client needs to fill in the pdf form, but the data connection cannot stay live as this information is not for the client.

            If I canot think of a solution I may need to redo the form in the front end of Adobe professional and use the "import data" scripting method.

             

            thanks again for taking the time to help.