Adding fields in the introduction section of email data connection - InfoPath Dev
in

InfoPath Dev

Adding fields in the introduction section of email data connection

Last post 11-19-2007 03:39 AM by Sam . 16 replies.
Page 1 of 2 (17 items) 1 2 Next >
Sort Posts: Previous Next
  • 11-12-2007 02:21 AM

    • Sam
    • Top 500 Contributor
    • Joined on 11-27-2006
    • California
    • Posts 44

    Adding fields in the introduction section of email data connection

    Hi,

    I have a data connection where an email is sent to a user with the press of a button.

    I would like to add a field from the form in the introduction area of the email message.

    Any help would be appreciated..

    Hetal 

  • 11-12-2007 07:39 AM In reply to

    Re: Adding fields in the introduction section of email data connection

    Obviously putting form field data is easier in the subject line than in the Introduction since the UI has the button for it. You can concatenate it into other text or fields.

    For the Introduction text you would need to use code and concatenate your field with text and then save it into the Introfield directly.  I think this would be the only way to do it.

  • 11-12-2007 09:19 PM In reply to

    • Sam
    • Top 500 Contributor
    • Joined on 11-27-2006
    • California
    • Posts 44

    Re: Adding fields in the introduction section of email data connection

    Hi,

    Thanks for your reply.

    I have added fields in the subject line using concatenation. I need to add 2 more fields which has to be mentioned with the introduction text.

    Can you please tell me where i can find a code for the introduction section and how do i go about it.

    Hetal

  • 11-13-2007 04:46 AM In reply to

    Re: Adding fields in the introduction section of email data connection

    Here is what you need: Add a new Data Connection to your template (or use the one you have set up already). In the OnClick event of you button with which you want to send the mail you can use the below snippet: var mail = XDocument.DataAdapters("Name Of Your DataConnection"); mail.To = [email protected]; mail.Intro = "This is my body text"; mail.Subject = "bla bla bla" mail.Submit(); Hope this helps. code is in jscript, managed code looks similar but is still different just do a search on the forum.
    Listen to Motörhead cos they play Rock'n Roll :)
  • 11-13-2007 08:04 AM In reply to

    Re: Adding fields in the introduction section of email data connection

    Just to add you can concatenate some text and some fields into the mail.intro to get what you are looking for.

  • 11-15-2007 03:23 AM In reply to

    • Sam
    • Top 500 Contributor
    • Joined on 11-27-2006
    • California
    • Posts 44

    Re: Adding fields in the introduction section of email data connection

    Hi, Thanks alot .. that code works... hurray!!

    But i couldnt concatenate fields in mail.intro.. I dont think i am using the right command. 

    I have a field called "comments"  and everytime a user presses the decline button - the text in the "comments" field should be mentioned in the introduction area of the mail.

    hetal

     

  • 11-15-2007 03:47 AM In reply to

    • Sam
    • Top 500 Contributor
    • Joined on 11-27-2006
    • California
    • Posts 44

    Re: Adding fields in the introduction section of email data connection

    I know the below code is wrong... can you please tell me where is the problem 

    mail.Intro = concat("This is my body text", comments);

  • 11-15-2007 04:18 AM In reply to

    Re: Adding fields in the introduction section of email data connection

    When writing code you should always have the API open because there you can find everything you need (In Script Editor press F1 to open the Help). Please search there for concat to see how to use it correclt. In managed code I would use a StringBuilder object to build my text which i want to add to the intro but for you something like var comments = XDocument.DOM.selectSingleNode(XPath to your control(something like "my:myFields/my:commets")).text; mail.Intro = ("This is my body text", comments) should work.
    Listen to Motörhead cos they play Rock'n Roll :)
  • 11-15-2007 05:09 AM In reply to

    • Sam
    • Top 500 Contributor
    • Joined on 11-27-2006
    • California
    • Posts 44

    Re: Adding fields in the introduction section of email data connection

    Thanks alot.... It works perfect...

  • 11-15-2007 05:30 AM In reply to

    • Sam
    • Top 500 Contributor
    • Joined on 11-27-2006
    • California
    • Posts 44

    Re: Adding fields in the introduction section of email data connection

     Hi.. Just one more thing...

    On one button i have got 6-7 rules.. Since you asked me to use my email data connection - every time now when i press a button i have to send 2 emails.. one from the data connection and 2nd from the code..

    I want the email to go to the user only after it is submitted in the doc library and gone through couple of rules. How will i be able to number the code as which rule??

  • 11-15-2007 05:41 AM In reply to

    • Sam
    • Top 500 Contributor
    • Joined on 11-27-2006
    • California
    • Posts 44

    Re: Adding fields in the introduction section of email data connection

    Now i can see either the field from the form or text not both -

    mail.Intro = ("This is my body text", comments);

    Its either This is my body text    OR   comments

  • 11-15-2007 05:57 AM In reply to

    Re: Adding fields in the introduction section of email data connection

    To your second questions it must of course be mail.Intro = "This is my body text" + comments; Sorry for that. Coming to you first question I guess why you are sending two eMails is because you forgot to delete one Action on your rules which says Submit Dataconnection which is actually your Mail Submit. Delete this Action/Rule from your button (not the Dataconnection itself) and you should send only one mail now. I also think that Rules are fired before your code in the OnClick event of your button (e.g. you fileupload to SharePoint or what ever). If not then just call everything from code as you upload is nothing else but another DataConnection just use the same functionality than for the mail event. Hope this helps.
    Listen to Motörhead cos they play Rock'n Roll :)
  • 11-18-2007 01:42 AM In reply to

    • Sam
    • Top 500 Contributor
    • Joined on 11-27-2006
    • California
    • Posts 44

    Re: Adding fields in the introduction section of email data connection

    Thanks alot for your help...

    All the below works exactly the way i wanted. My Infopath forms are live and published on Sharepoint. When I try to change the code from VBscript to JScript - it doesnt allow me to do so... The field is greyed out.  

    Where can i get the same code in vb script..??

  • 11-18-2007 03:27 AM In reply to

    • Sam
    • Top 500 Contributor
    • Joined on 11-27-2006
    • California
    • Posts 44

    Re: Adding fields in the introduction section of email data connection

    Hi, This is what i would like to do but in 2003.

    http://office.microsoft.com/en-us/infopath/HA102034701033.aspx  

    I dont have options for the buttons in 2003.

     

  • 11-18-2007 01:55 PM In reply to

    Re: Adding fields in the introduction section of email data connection

    If you navigate to Tools->Form Options->Advanced, you will see a section for Programming Language which states: "The programming language can only be set when no code exists in the form." To remove the code, you will have to extract the form files from the XSN (File->Extract Form Files). Close the Designer. Now, open the manifest.xsf in notepad.

    If you previously had your programming language set as jscript, you'll need to remove the following 3 blocks:

        <xsf:file name="script.js">
        <xsf:fileProperties>
         <xsf:property name="scriptType" type="string" value="userEvents"></xsf:property>
        </xsf:fileProperties>
       </xsf:file>

     <xsf:applicationParameters application="InfoPath Design Mode">
      <xsf:solutionProperties scriptLanguage="jscript" fullyEditableNamespace="http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-11-18T21:45:53" lastOpenView="view1.xsl"></xsf:solutionProperties>
     </xsf:applicationParameters>


     <xsf:scripts language="jscript">
      <xsf:script src="script.js"></xsf:script>
     </xsf:scripts>

    Save the manifest.xsf with the sections removed. Now open it up again in the Designer and the language dropdown under Tools->Form Options->Advanced will be enabled.

    Hope this helps,

     

    Patrick Halstead
    Project Manager at Qdabra
Page 1 of 2 (17 items) 1 2 Next >
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.