Validating Field against web service - InfoPath Dev
in

InfoPath Dev

Validating Field against web service

Last post 11-16-2006 09:15 AM by Greg Collins. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 11-15-2006 03:03 AM

    Validating Field against web service

    Hi,

    I'm developing a form using Infopath 2007 (Beta) to be used in Sharepoint 2007 and have a query regarding validating a field against a web service data source. I should also point out I'm new to developing in Infopath so I may have missed something obvious.

    The scenario is this:

    I have a form with three controls (it actually has a lot more but three is enough to demonstrate the issue).

    The controls are:

    i) Textbox for customer ID
    ii) Read Only Textbox showing the customer name.
    iii) Button to lookup customers

    The form needs to provide a lookup via a web service to return the customer name for a given id. It needs to provide two ways of achieving this.

    The first uses the button to change to a different view where the user can enter either an ID or a partial name and get a selection of matching customers to choose from. This works fine, I've set up a secondary data source to the web service and the form creates a repeated set of matching results for the user to choose from.

    The second approach is to allow the user to enter the customer ID directly into the textbox. In order to do this I need the textbox to be validated by calling the web service and the customer name updated or an error raised. I couldn't see how to perform this using validation rules so I've chosen to perform it in code. I thought my validation code would be quite simple: move the value of the customer ID to the field in the secondary data source, execute the web service and move results back to the main data source. Unfortunately I've found I cannot write the customer ID to the secondary data source as the data source cannot be editted at this point.

    Has anyone else used Infopath in this way and am I doing something wrong? Any help would be appreciated.

    Thanks
    Chris
  • 11-15-2006 09:29 AM In reply to

    Re: Validating Field against web service

    What event handler are you using in your code? Some event handlers are run while the DOM is in readonly mode.
  • 11-15-2006 09:58 AM In reply to

    Re: Validating Field against web service

    Hi Greg,

    Thanks for answering.

    I'm using the validating event on the customer ID textbox.

    I wanted to use that so I can call the ReportError method should the lookup fail.

  • 11-15-2006 04:34 PM In reply to

    Re: Validating Field against web service

    Yes, the DOM is readonly during that event. To modify the DOM, you must use the change event.
  • 11-16-2006 01:42 AM In reply to

    Re: Validating Field against web service

    Hi Greg,

    Many thanks for this. I've now moved the code to the change event and it works fine.

    Thanks for your help.
  • 11-16-2006 09:15 AM In reply to

    Re: Validating Field against web service

    Glad to have helped!
Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.