Callback from HtmlTaskPane to Form - InfoPath Dev
in

InfoPath Dev

Callback from HtmlTaskPane to Form

Last post 11-17-2005 06:52 AM by franck. 14 replies.
Page 1 of 1 (15 items)
Sort Posts: Previous Next
  • 11-14-2005 03:56 PM

    Callback from HtmlTaskPane to Form

    Hello Members,

    i'm new here and currently working on an InfoPath Project. (Really ;-) I'm 29 years old programmer normally responsible for ado.net & sql server programming in our team. Currently i have to find an answer about this InfoPath Question.

    I'm using VS 2003 + InfoPath Toolkit to create my forms and publish them to a SharePoint server. At the moment I'm testing around with the HtmlTaskPane and checked the sample provided by MS. My question is if it is possible to access the current InfoPath formular and change field values which I selected from a drop down list in the HtmlTaskPane?

    If you need additional information about

    Regards

    Tony
  • 11-14-2005 05:39 PM In reply to

    Re: Callback from HtmlTaskPane to Form

    I will give an official welcome for Patrick (site guru).

    On my last InfoPath project I highly utilized the custom task pane to do many things. For instance, I embedded search functionality into the taskpane to call a webservice. You can pass data easily between the task pane and the InfoPath form.

    Excuse the VBScript example but it will get the point across. It was what the client wanted.

    This code is in the HTML page:

    '===========================
    ' Adds items to the list box.
    '===========================
    Sub AddPartItem(displayText, valueText)
    Dim oOption
    Set oOption = document.createElement("OPTION")
    oOption.text = displayText
    oOption.value = valueText
    document.GetElementById("lstParts").add(oOption)
    End Sub

    This code is in InfoPath:

    Sub SendTaskPaneResultsPartsByNo()
    Dim i
    For i = 0 To XDocument.DataObjects(...).DOM.selectNodes(...).length - 1
    call XDocument.View.Window.TaskPanes.Item(0).HTMLDocument.parentWindow.AddPartItem( _
    XDocument.DataObjects(...).DOM.selectNodes(...)(i).text, _
    XDocument.DataObjects(...).DOM.selectNodes(...)(i).text)
    Next
    End Sub

    OR can go vice versa

    In the HTML page I can go:

    Call window.external.Window.XDocument.Extension.SearchForPartNumber(Parts.txtPartSearch.value, Parts.rdoPartNumber.checked)

    And the create a method SearchForPartNumber in InfoPath.

    If it sounds like you are going to use manage code, review this article. -http://blogs.msdn.com/infopath/archive/2004/09/27/234911.aspx

    The one issue I found with using .NET managed code and the custom task pane is that you will need to have full trust. Someone please correct me if I am wrong.
    Jason
    http://www.k2distillery.com/
  • 11-15-2005 08:53 AM In reply to

    Re: Callback from HtmlTaskPane to Form

    Hi vt_asparagus,

    and thanks for the nice welcome. :-)
    quote:
    Originally posted by vt_asparagus

    I will give an official welcome for Patrick (site guru).
    On my last InfoPath project I highly utilized the custom task pane to do many things. For instance, I embedded search functionality into the taskpane to call a webservice. You can pass data easily between the task pane and the InfoPath form.



    That's 100% what I want to do ;-) I've tried to build a c# / js sample in analogie to your post.
    Calling JS from InfoPath seems to be no problem. Also changes in the DOM through JS will be aviable in InfoPath.
    What I can not get to work is this call.

    window.external.Window.XDocument.Extension.SearchForPartNumber(Parts.txtPartSearch.value, Parts.rdoPartNumber.checked)

    I wrote an c# method called ChangeValue(String val) only for testing.
    Excuse the VBScript example but it will get the point across. It was what the client wanted.

    public string ChangeValue( String val)
    {
    Microsoft.Office.Interop.InfoPath.SemiTrust.IXMLDOMDocument dom = thisXDocument.DOM;
    dom.selectSingleNode("my:meineFelder/my:Personenkennziffer").text = val;
    return val + "_SET";
    }

    This code is in the HTML page:

    function check(){
    try
    {
    var s = window.external.Window.XDocument.Extension.ChangeValue("1545874");
    alert(s);
    }
    catch(e)
    {
    alert(e.message);
    }
    }

    Actually I will see an the "catch" alert box saying "Permission denied". I've add the calling Site to the trusted IE zone but it changed nothing. Perhaps I should mentioned that the Site I display in the TaskPane is an aspx site.

    Kindly Regards

    Tony
  • 11-15-2005 09:02 AM In reply to

    Re: Callback from HtmlTaskPane to Form

    Hi Tony,

    For TaskPane manipulation through Managed Code, your template needs to be full trust.

    Regards,

    Franck Dauché
  • 11-15-2005 09:46 AM In reply to

    Re: Callback from HtmlTaskPane to Form

    Hello franck,

    thanks for your fast response. I've signed my project digitally and it seems to be full trusted. I've an embedded html ressource file, which makes this call without any problems. When I use an external aspx file it wont work. :-( Any Idea?

    var xDocument = window.external.Window.XDocument.DOM;
    xDocument.getElementsByTagName("my:Name")[0].text = "Meyer, Josef";

    Regards Tony

    EDIT
    I just stepped into the Script Debugger and can see the XDocument ?!?!

    quote:
    Originally posted by franck

    Hi Tony,

    For TaskPane manipulation through Managed Code, your template needs to be full trust.

    Regards,
    Franck Dauché

  • 11-15-2005 02:20 PM In reply to

    Re: Callback from HtmlTaskPane to Form

    Hi and welcome aboard :-)

    it would probably be a security issue. AFAIR window.External.Window.XDocument is security level 2, and that means no cross-domain trust.

    To prove this, try with an ASPX page on same server as your trusted form.

    hth
    //AndersR
  • 11-15-2005 08:01 PM In reply to

    Re: Callback from HtmlTaskPane to Form

    Check this out, it may have some answers, they are talking about passing values with an aspx embedded in the custom taskpane -http://groups.google.com/group/microsoft.public.infopath/browse_thread/thread/133021719e343bd/063df81a61fd7652

    Glad to help. As I mentioned, and Franck too, is that you will need full trust. For the project I was doing I was going to use managed code, but the client did not want to deal with certificate (go figure that one out) and I was forced back into use script. I did not continue past that but from what everyone said is once you have it at full trust you should be good to go.
    Jason
    http://www.k2distillery.com/
  • 11-15-2005 10:59 PM In reply to

    Re: Callback from HtmlTaskPane to Form

    Hi Tony and welcome to our forum!
    Looks like you are in the very able hands of Jason, Franck, and Anders...

    Patrick Halstead [InfoPath MVP]
    InfoPathDev
    Patrick Halstead
    Project Manager at Qdabra
  • 11-16-2005 05:42 AM In reply to

    Re: Callback from HtmlTaskPane to Form

    quote:
    Originally posted by vt_asparagus
    Glad to help. As I mentioned, and Franck too, is that you will need full trust. For the project I was doing I was going to use managed code, but the client did not want to deal with certificate (go figure that one out) and I was forced back into use script. I did not continue past that but from what everyone said is once you have it at full trust you should be good to go.




    You can publish forms with managed code without code signing signatures. All you need is to set the URN in your manifest.xsf and then use regform.exe in the Tools folder of your SDK with the urn as parameter:

    regform.exe /U urn:YourCompany:InfoPath:YourForm /T Yes /MSI yourForm.xsn

    The /T option specifies the form is fully trusted
    /MSI means output is a MS Installer package.

    The package can be installed with all the usual parameters for scilent installation etc to be rolled out via AD or boot scripts.

    One thing you *wont* have (out of the box anyway) is the publishing feature to a SharePoint library (has to do with using URI instead of a URL in manifest) but theres a workaround of this as well by replacing the template of the library, but im already wandering way of topic ;-)

    //AndersR


  • 11-16-2005 12:31 PM In reply to

    Re: Callback from HtmlTaskPane to Form

    Hi,

    and wow, what a great feedback. Thanks a lot. Ok it seems that i'm beginning to understand some more about the facts that are important to my situation.
    I'll will start with AndersR who think's he's walking out of topic. NO :-) That's 100% my situation. I found out (Thnaks to Patrick's book I bought today) how the security stuff work togehter and how they interact. But what I can't clearly figure out (even with the book) is how to publish fully thusted forms to sharepoint. The problems happen when I open the form SharePoint. (location:http://sharepoint/)
    What I'm currently doing is the following workflow.

    1) Open IP from VS and Check the "Sign" checkbox (I added this cert manually to the os, as trusted)
    2) Publish form to SharePoint (new or owerride seems to make no difference for me)
    3) Open the form from InfoPath, accept the Users Cert as trusted and click ok ---> bang ---> Security Exception from JavaScript accessing external.Window etc.

    Seems to be an cross domain problem, but both components are residing an the same machine. The only difference is, that sharepoint is accessed viahttp://sharepoint and the "normal" websites viahttp://winserver

    Did someone have an idea and can tell me if my steps for publishing a fully trusted form are correct?

    Can someone give me a link or tell me some more about the Sharepoint workaround?

    Kindly regards

    Tony

    Installation (Development maschine | virtual mashine):

    WinServer 2003 (no domain)
    SharePoint Portal Server 2003
    VS2003
    VS 2003 Office / InfoPath Toolkit
    SAP .NET Connector 2.0
    MS Office 2003


  • 11-16-2005 02:31 PM In reply to

    Re: Callback from HtmlTaskPane to Form

    Hi Tony

    you dont mention anything about the form being fully trusted. Did you check the "full trust" checkbox?
    Also remember to check the "accept.. blabla" (sorry its two lines of text and i dont have IP on this box :-)

    In general i would recommend reading the articles on MSDN regarding common developer tasks. Especially this one:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ipsdk/html/ipsdkSignedFormTemplate_HV01120501.asp

    wich describes how to publish fully trusted forms without certificates

    Regarding the "sharepoint workaround" as you mention, it is only applicable on fully trusted forms without certificates so i dont think it will help on your specific problem:

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ipsdk/html/ipsdkSignedFormTemplate_HV01120501.asp

    About the aspx page in HTMLtaskpane: try putting it in the _layout vdir in sharepoint just to test if there is a difference so that we can exclude cross-domain from the equation!

    hth
    //AndersR

    ps. just a silly question now that you mention your setup: you *do* have SP1 > on that Office right?


  • 11-16-2005 04:38 PM In reply to

    Re: Callback from HtmlTaskPane to Form

    Tony...I do not mean to hop on your thread here but AndersR has struck a cord with me.

    AndersR...This was an issue I ran into. I wanted to .NET Managed code but I need to used an "integrated" taskpane, I could not use certificates and I had to use sharepoint for deployment (I could not do a msi to install as you described earlier.). I had some posts on this forum about this. So you are saying all I needed to do was sign the template (not requiring a certificate) and then deploy on SharePoint?
    Jason
    http://www.k2distillery.com/
  • 11-17-2005 01:00 AM In reply to

    Re: Callback from HtmlTaskPane to Form

    hi Very Tender ;-)

    My last (and first btw ;-) InfoPath project, has more than 1000 lines of code in it, with both taskpane and modal boxes and the customer didnt want to spend $200 on a code signing certificate.

    All i did to get it to work was to set Full Trust, change URL to URI in manifest and create an installer with regform.exe

    Ofcourse since you are using a taskpane, you also need to register microsoft.mshtml.dll in the GAC on every machine running the form (create a script running gacutil via AD or bootscripts) or you will get an exception.

    hope this clears it up
    //AndersR


  • 11-17-2005 06:09 AM In reply to

    Re: Callback from HtmlTaskPane to Form

    Oh no. Patrick look what you have done to me! I told my wife you guys had developed a new nickname for me and she laughed uncontrollably for 10 minutes (my real last name is easy to make fun, would you believe the hotel front desk where I have been living out of for the past 4 months all call me Mr. Asparagus!!!)

    Again Tony...sorry about your thread. We live to serve if you have more questions...
    Jason
    http://www.k2distillery.com/
  • 11-17-2005 06:52 AM In reply to

    Re: Callback from HtmlTaskPane to Form

    oops....Jason, I have to take the blame for this...sorry, I meant vt.

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