Contact Selector Control - cannot e-mail to selected contact. - InfoPath Dev
in

InfoPath Dev

Contact Selector Control - cannot e-mail to selected contact.

Last post 12-20-2008 12:23 PM by Alec Pojidaev. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 08-13-2008 08:03 AM

    Contact Selector Control - cannot e-mail to selected contact.

    Hi,  I have created a form with several contact selectors.  I can search for the contact fine.  But I don't seem to be able to use the results of the query.

    My structure is....

    group1
      Person
         DisplayName
         AccountId
         AccountType
         AD
    AccountVal

    On submit I want to email the selected contact.  In the submit data connection I choose group1 as the To field.  On submit I get an error The following addresses did not resolve in the To line: Ormerod, Catharine  DTIN\OrmerC User  I presume I am using the wrong field - but none of the other fields holds the email address which should be in the form ([email protected]).  What am I doing wrong ?

    I do have a webservice which will get the correct e-mail address if it is given the username BUT for that to work I have to separate the domain from the username in AccoundId.  I have not been able to do that either.....

    I tried a couple of things...

    1. Adding a field (AD) to the Person Repeating group. (The Contact Selector still worked with the additional field).  I put a default value of sub substring-after(AccountId, "DTIN\") - but this did not return any value at all - I also added a rule to AccountId to set the value of AD - again nothing happened

    2. Adding a field (AccountVal) outside the Person repeating group. + a rule on AccountId which  sets the value of AccountVal

    I have finally been able to separate off the username by putting a rule on group1 which sets the value of AccountVal.  I am worried that this will crash if the user selects more than one contact. - Is this the only way to do it ?  Why did my other attempts not work.

    Thank you for reading

    Catharine

  • 11-14-2008 11:08 PM In reply to

    • ravig
    • Top 500 Contributor
    • Joined on 06-21-2008
    • Posts 27

    Re: Contact Selector Control - cannot e-mail to selected contact.

    Hi,

    Take a string and append all the contact selector field values to the string.

    ex: name = name + GetNodeValue("field xPath")

    and give this string in the "To" of email option

    Ravi G
  • 11-15-2008 01:18 AM In reply to

    Re: Contact Selector Control - cannot e-mail to selected contact.

    Hi,

    Add a field (named as "EmailAddresses") in the main schema .In the submit data connection choose "EmailAddresses" as the To field. Now in the "group1" OnAfterChange event. Please write the below lines of code.

    Note: The below code is in C#.net .

    [InfoPathEventHandler(MatchPath = "/my:myfields/my:group1", EventType = InfoPathEventType.OnAfterChange)]
    public void group1_OnAfterChange(DataDOMEvent e)
    {

     if (e.IsUndoRedo || e.Operation != "Insert" || e.Site.baseName != "group1")
                {
                    return;
                }


                IXMLDOMNodeList personNodeList = GetNodes("/my:GMO/my:group1/my:Person");
                string userNameFromAccountID = string.Empty;
                string userNameEmailAddress = string.Empty;


                foreach (IXMLDOMNode personNode in personNodeList)
                {
                    if (GetNodeValue(personNode, "my:AccountId") != string.Empty)
                    {
                        string accountID = GetNodeValue(personNode, "my:AccountId");
                        int position = accountID.LastIndexOf("\\");
                        position = position + 1;
      userNameFromAccountID = accountID.Substring(position, (accountID.Length - position));
          string domainName = accountID.Substring(0, position);     
      userNameEmailAddress = userNameEmailAddress + userNameFromAccountID + "@" + domainName + ".com" + ";" ;
             }              
                }


     thisXDocument.DOM.selectSingleNode("/my:myfields/my:EmailAddresses").text = userNameEmailAddress;
    }

    Please let me know if you want any help in understanding the above code.

    Chandrakanth/GGKTech
  • 11-20-2008 06:12 AM In reply to

    • cathy
    • Top 500 Contributor
    • Joined on 08-19-2007
    • Posts 38

    Re: Contact Selector Control - cannot e-mail to selected contact.

    <p>

    Hi,

    I got a similar requirement! and was trying this code. 

    it looks like this code was written in C++. what is the equivalent code for C#?  IXMLDOMNode is not present in C# or am I missing any namespace?

     

    </p>

    Filed under: ,
  • 11-20-2008 06:21 AM In reply to

    Re: Contact Selector Control - cannot e-mail to selected contact.

    Hi,

    The code that i have mentioned is completly C#. Please check the below namaspace.

    using Microsoft.Office.Interop.InfoPath.SemiTrust;

    Chandrakanth/GGKTech
  • 11-20-2008 07:19 AM In reply to

    Re: Contact Selector Control - cannot e-mail to selected contact.

    The code sample is using the IP 2003 object model. If you are using IP 2007, you can either set your form to use C# 2003 compatible for the programming language or modify the code to use the 2007 OM. This MSDN article has some information on the differences.

    Hilary Stoupa

  • 11-21-2008 08:35 AM In reply to

    • cathy
    • Top 500 Contributor
    • Joined on 08-19-2007
    • Posts 38

    Re: Contact Selector Control - cannot e-mail to selected contact.

    Could you please tell me how can I loop through the group with XPathNavigator to achieve the above? I mean foreach().

    Any example would be greately appreciable.

    TIA

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