Build a Simple Language Translator using InfoPath and No Code – Part 2 of 2

7. After you have finished your data connection you will have two data references in your InfoPath project – Main and the Translate service you just created will be labelled a secondary connection…

You will see from the view above that the data connection is in two parts “query fields” and “data fields”. Put simply, the query fields enable you to pass information through the data connection and the data fields represent what you get back!

8. Enter text labels in the left hand column of the table you created in step 1 and drag the text field and the TranslateResult fields from the fields pane on the right into the form layout 

9. Now switch to the Main Data view in the fields pane and add two dropdown list controls and label LanguageFrom and LanguageTo… This will create two extra field references in the Myfields folder of the Main view of the Fields pane as in the screenshot below. These two fields will be used to provide data to the “From” and “To” query fields of the Translate data connection

10. Enter the values as in the screenshot below to the Drop Down List Box properties for the LanguageFrom field

11. And enter the values as in the screenshot below to set up the LanguageTo Dropdown List Box properties: Yes, pretty much identical to the LanguageFrom field!

For this example I have only added five languages and their associated codes , but you can add additional languages to these controls if they are supported by the Microsoft Translate API.

12. Now finally we just need to add a button to our form and attach some logic to the button so that when pressed the following will happen:

  • Populate the “From” query field of the Translate data connection with the value selected in the LanguageFrom Dropdown List
  • Populate the “To” query field of the Translate data connection with the value selected in the LanguageTo Dropdown List
  • Run the web service to see the translate result

This is achieved simply by adding a button from the Controls section of the Home ribbon and adding a Rule with three actions as below:

The three actions are

  1. Set a fields value (select the “from” field from the Translate data connection and make equal to the LanguageFrom field from the Main data connection)
  2. Set a fields value (select the “to” field from the Translate data connection and make equal to the LanguageTo field from the Main data connection)
  3. Query using a data connection (select the Translate data connection)

Conclusion

Well, that’s all there is to it! Test the form in preview mode and add some simple sentences and combinations of From and To languages. If you have been successful, you will appreciate how InfoPath can be used to address some fairly complex Business scenarios in a straightforward manner with NO CODE REQUIRED!
J

Do you have any similar examples of code free web service based InfoPath development – we’d love to hear from you!

2 Responses to “Build a Simple Language Translator using InfoPath and No Code – Part 2 of 2”


  1. 1 Anurag April 9, 2012 at 9:29 am

    Awesome !! Worked like a charm !!

    I have a question though.. This AppID that I have created, does it have any dependencies as such and does it have an expiry date?


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s





Follow

Get every new post delivered to your Inbox.

Join 279 other followers