Outlook Search in Repeating Section - InfoPath Dev
in

InfoPath Dev

Outlook Search in Repeating Section

Last post 12-06-2007 02:51 AM by nukkumatti. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 12-05-2007 02:45 AM

    Outlook Search in Repeating Section

    Hi,

    I have a repeating section in an InfoPath 2003 form with three text box controls, DisplayName, Account and Email address.
    In this section I have a search button for contacts in Outlook address book.
    When I click on it the address book opens and I can select a contact and populate the fields in the first section.
    But when I do the same in the second section the values are concatenated with those in the first section and the second one remains empty.
    Can anyone please help me since this is urgent. I have done the coding in jscript.

    Regards,
    Hans

  • 12-05-2007 04:38 AM In reply to

    Re: Outlook Search in Repeating Section

    Hi, so I guess that than in the OnClick event of your button you have in each row you also use code to actually write the values into your controls. when you have this button in your repeating section you can actually use the parameter of your button event to always refer to the row you are at the moment. this would mean change your code from XDocument.DOM.selectSingleNode(my:myFields/my:Email").text = myValue to eventObj.Site.selectSingleNode(my:myFields/my:Email").text = myValue. if this doesn't work try eventObj.Source.selectSingleNode not to sure now. does this help ?
    Listen to Motörhead cos they play Rock'n Roll :)
  • 12-05-2007 08:14 AM In reply to

    Re: Outlook Search in Repeating Section

    Hi,

    Cannot get it to work with eventObj.........
    This is my code, maybee you can make some sence out of it.

    function GetName::OnClick(eventObj)
    {
     try
     {
      var cdoAddrEntry; // AddressEntry
      var strData; // string

      // JavaScript does not recognize constants!
      // Define them explicitly or use their value.
      var CdoPR_ACCOUNT = 0x3A00001F;
      var CdoPR_DISPLAY_NAME = 0x3001001E;
      var CdoPR_EMAIL = 0x39FE001E;
      var CdoPR_DEPARTMENT_NAME = 0x3A18001F;
      var CdoPR_OFFICE_LOCATION = 0x3A19001F;
      var CdoPR_BUSINESS_TELEPHONE_NUMBER = 0x3A08001F;
      //Start the CDO code to find a match.
      cdoSession = new ActiveXObject("Mapi.session")
      cdoSession.Logon(null,null,false,false,0);   //Use the existing Outlook session.

      // Get the AddressEntry of the recipient/current user.
      cdoAddrEntry = cdoSession.CurrentUser;
      AddPerson("//my:field1", "//my:field2", "//my:field3", false);
     }
     catch(e)
     {
      if (e.description.lastIndexOf('MAPI_E_LOGON_FAILED(80040111)') != -1)
       XDocument.UI.Alert("You need to have Outlook started " +e.description);
      else
       XDocument.UI.Alert(e.description);
     }
    }

    function AddPerson(nameFieldPath, mailFieldPath, accountFieldPath, allowManySelection)
    {
     try {
      var oRecipients = null;
      var oTestMessage=cdoSession.Outbox.Messages.Add();
      oRecipients=cdoSession.AddressBook(oTestMessage.Recipients, "Select User", !allowManySelection, true, 1, "Add");
      oRecipients.Resolve();
      
      if(allowManySelection)
      {
       for(i=1;i<=oRecipients.Count;i++)
       {
        fillTextBox(nameFieldPath, oRecipients.item(i).AddressEntry.Fields(0x3001001E)+";");
        fillTextBox(mailFieldPath, oRecipients.item(i).AddressEntry.Fields(0x39FE001E)+";");
        fillTextBox(accountFieldPath, oRecipients.item(i).AddressEntry.Fields(0x3A00001F)+";");
       }
      }
      else
      {
       fillTextBox(nameFieldPath, oRecipients.item(1).AddressEntry.Fields(0x3001001E));
       fillTextBox(mailFieldPath, oRecipients.item(1).AddressEntry.Fields(0x39FE001E));
       fillTextBox(accountFieldPath, oRecipients.item(1).AddressEntry.Fields(0x3A00001F));
      }
     }
     catch(ex)
     {
      if(ex.description.lastIndexOf('MAPI_E_USER_CANCEL(80040113)') == -1)
      {
       if(ex.description.lastIndexOf('MAPI_E_NOT_INITIALIZED(80040605)') != -1)
        XDocument.UI.Alert("No Address book connection, please close and reopen the form and select a valid Outlook profile");
       else
        XDocument.UI.Alert("Error retrieving user mail. Make sure Outlook is online: "+ex.description);
      }
     }
    }

    function fillTextBox(textBoxPath, value)
    {
     if(textBoxPath != "")
     {
      var textBox = XDocument.DOM.selectSingleNode(textBoxPath);
      textBox.text += value;
      XDocument.UI.Alert(value);
     }
    }

     

    Many thanks in advance,
    Hans

  • 12-06-2007 12:29 AM In reply to

    Re: Outlook Search in Repeating Section

    Hi, always a bit hard to debug code just like this but my guess would be that in the OnClick event where you pass the parameters (xPath to your form controls) to the AddPerson method try to use eventObj.Source.selectSingleNode("my:field1")
    Listen to Motörhead cos they play Rock'n Roll :)
  • 12-06-2007 02:51 AM In reply to

    Re: Outlook Search in Repeating Section

    i tried to rund your code but receive an Access Denied error for the Collaboration Data Object so i actually cannot test my proposal. if you know how to fix my error it's may be easier to debug. SOLVED ! stupid me just didn't work in preview mode.
    Listen to Motörhead cos they play Rock'n Roll :)
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.