Providing Copy & Paste functionality - Can it be done? - InfoPath Dev
in

InfoPath Dev

Providing Copy & Paste functionality - Can it be done?

Last post 12-04-2007 01:39 PM by Greg Collins. 9 replies.
Page 1 of 1 (10 items)
Sort Posts: Previous Next
  • 10-31-2007 09:11 AM

    Providing Copy & Paste functionality - Can it be done?

    Hi All,

    A NOOBIE question for you.

    We have a series of infopath forms (hosted on Sharepoint), designed to be firstly completed the customer, and then emailed around various managers seeking approval. At the end of the process, when the form is approved, it is required to be transfered into our Helpdesk system, which is completely standalone.

    The previous system is used by having a text file generated, which the operator opens, and takes the contents, and pastes it into the helpdesk.

    Essentially, all I want to know is, is there an easy way to create a view that allows COPY and PASTE?

    I have seen the export to HTML, which is great, but is quite longwinded and will slow our operators down.

    I've tried creating a text box, and setting the default value to concat("Field = ", field, ", another = ", anotherfield) etc, but this would take FOREVER to do (as the forms are quite big) and doesn't work with repeating tables.

    Any help would be greatly appreciated.

    Thanks,

    James

    Filed under: , ,
  • 10-31-2007 09:48 AM In reply to

    Re: Providing Copy & Paste functionality - Can it be done?

    It sounds like what you want is a view with a single field that can be copied in one transaction.

    Obviously you know you can create a view with all the fields set to readonly, and then the fields can be copied one-by-one... but it sounds like you want one concatenated field.

    Truely, using concat() is not the right answer. However, you could do this using code, selecting every node in the DOM, using the XPath "//*" and then looping through them, getting each value and concatenating into a large string which is then put into a field... or if you are more adventurous, creating your own XHTML document which is then appended to a rich text field.

    My point, however, is that this can be done, but at some cost. You will need to evaluate whether the cost is worth the effort.

  • 10-31-2007 09:54 AM In reply to

    Re: Providing Copy & Paste functionality - Can it be done?

    Greg,

    Thanks for your reply.

    Yes, you are correct, we just want to place all the text into the one large text box ready for copy and paste.

    I did look into using the JScript environment behind Infopath (I may be wrong, but isn't infopath 2003 only JScript, not C# etc?) so that when the view loaded, it copied all the elements into the box programatically.

    Trust me, the effort is not an issue, if you could provide me with some pointers of where to start with the programatic side?

    I'm not used to JScript at all, and I am willing to learn, but time is not on my side.

    Any Noobie pointers you could share?

    Really, a big thankyou for the reply.

    James.

     

  • 10-31-2007 10:20 AM In reply to

    Re: Providing Copy & Paste functionality - Can it be done?

    You can use C# with InfoPath 2003. You will need: Visual Studio (Express edition should work), and the InfoPath 2003 Toolkit for Visual Studio .NET (see the InfoPathDev.com homepage for links).

    There are different toolkits depending on which version of Visual Studio you are running. I think the homepage link is expecing 2003 and not 2005.

  • 11-01-2007 01:28 AM In reply to

    Re: Providing Copy & Paste functionality - Can it be done?

    Greg,

     Again, thanks for the advice, i'll download those and give it a go.

    Any tips or links on how to work with the XPath enumeration as well?

     Thanks,

    James.

  • 11-01-2007 09:44 AM In reply to

    Re: Providing Copy & Paste functionality - Can it be done?

    IXMLDOMNodeList nodes = thisXDocument.DOM.selectNodes("//*"); // Note: this XPath only accounts for elements, and not attributes.
    foreach(IXMLDOMNode node in nodes)
    {
        string val = node.text;
        // do whatever you want with the text value here.
    }

  • 11-02-2007 01:05 AM In reply to

    Re: Providing Copy & Paste functionality - Can it be done?

    Greg,

     Again, many thanks for your help.

    Best regards,

    James.

  • 11-02-2007 04:56 PM In reply to

    Re: Providing Copy & Paste functionality - Can it be done?

    Glad to help!

  • 11-22-2007 08:15 AM In reply to

    Re: Providing Copy & Paste functionality - Can it be done?

    After being moved to a different project, i'm back to this again!

    I now have it working, as below:

    public void CTRL5_5_OnClick(DocActionEvent e)

    {

    IXMLDOMNodeList nodes = thisXDocument.DOM.selectNodes("//*"); // Note: this XPath only accounts for elements, and not attributes.

    foreach (IXMLDOMNode node in nodes)

    {

    strOutput += "=" + node.nodeName + ":" + node.text;

     

    }

    IXMLDOMNode myEl = (IXMLDOMNode)thisXDocument.DOM.selectSingleNode("/my:myFields/my:field4");

    myEl.text = strOutput;

     

    }

     However, my output is first, the text from all nodes in myFields, and then, the text from each field in myFields - basically meaning I get the data twice.

    Do you know of a way to only retrieve data from elements, rather than from groups?

  • 12-04-2007 01:39 PM In reply to

    Re: Providing Copy & Paste functionality - Can it be done?

    My guess of what's going on is that you already have a value in: my:field4. So before you do anything else (before you get all the nodes), you need to clear the value of this field...

    thisXDocument.DOM.selectSingleNode("/my:myFields/my:field4").text = "";

Page 1 of 1 (10 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.