Archive for the 'Infopath' Category

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

One of the most useful features of InfoPath, is the ability to easily set up and use data connections from so many sources. Using data connections to web services, InfoPath can be used to create a form that passes data onto a third party website where the data is acted upon in some way and a response passed back to the end user.

A simple, yet practical example of this is this simple text translator. This was built on the back of a customer request to have forms available in multiple languages. No code is used in this development, but we do make use of the “Rules” functionality by which Business Logic and in-form workflow can be built.

While the result of some InfoPath experimentation presented here will not be putting any multi-lingual technical translating staff out of business I’m sure you can think of other applications which could benefit from a Web Service interface such as this.

Ok – so how do you go about creating a translation form? It’s as simple as baking a loaf of bread, so let’s start by looking at the ingredients we will need!

Recipe for InfoPath Translator – Serves 5 ( English, German, Spanish, French and Italian!)

Ingredients:

Instructions

  1. In InfoPath 2010 Designer create a new Blank Form and create a table with six rows and two columns
  2. Create a Data Connection – Not built one of these before? – Don’t worry a wizard makes this really simple!
    1. From the ribbon select Data / From Web Service /From SOAP Web Service and enter in the web service URL as below:

3.Now from the list of Services select Translate

4. On the next screen you will see a list of Parameters that are used by the web service – Enter your Bing Application ID here by using the Set Value button (You do have an app id don’t you? If not, sign up at http://www.bing.com/toolbox/bingdeveloper/) In the content type and category parameters set the values to ‘text/plain’ and ‘general’ respectively

5. The next screen should be skipped – hit the Next button

6. Now we are on the final screen for our data connection set up. Deselect the “Automatically retrieve data when form is opened” check box – Best practice for forms is to only use data connections when needed, and we will only be calling this service when a button is clicked

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!

ISC London: Quickly Delivering Business Applications on SharePoint 2010 Session

I’m looking forward to talking about quickly delivering business applications on SharePoint 2010 at The International SharePoint Conference London 2012 in April. I’ll be co presenting with one of our customers.

When the tools available in SharePoint 2010 are used appropriately, it can be phenomenally productive. In my session, we take a look at how it was possible to build a fully featured business application, with forms, workflow and reporting in a matter of days – and without writing any code. Using Purchase Order management as an example, I’ll review the business requirements and explain why SharePoint was chosen for the application, before getting hands on with some demos and looking at how SharePoint capabilities were leveraged to quickly deliver the application at an engineering company.

Full agenda of speakers can be found here. It’s shaping up to be another excellent event!

Register ICSLondon

Click here to regsiter: http://www.internationalsharepointconference.com/Pages/Register.aspx

Cascading Dropdowns in InfoPath 2010

This is a robust way to implement cascading (sometimes called nested) dropdowns in InfoPath 2010, that also works with InfoPath Forms Services in SharePoint 2010. The approach in this article expands upon the demo that I gave at SharePoint Saturday UK on 12 November 2011.

There are numerous other blog articles out there explaining how to achieve cascading dropdowns in InfoPath, and I have had varying degrees of success with them. Some work okay but are complex, others seem to be a bit buggy. So the approach I take here will (hopefully!) provide a good solution – but comments welcome as always!

Objective: On an InfoPath form I wish to have an arbitrary number of dropdowns. Selecting an item in the first dropdown determines the items available in the second, selecting an item in the second dropdown determines the items in the third, and so on. A user should be able to go back to a previous dropdown and make a change. Users should be forced to select in order, so that until an item in the first dropdown is chosen, the second dropdown is disabled, and so forth.

Preparing the Data Source

For the example below our data source for the dropdown items is SharePoint lists. However the method could be modified to use other data sources such as a database or a web service. In the dropdowns users will select a region, then an office, then a team.

I have created three lists for the example and will create three dropdowns.

The “Regions” list is a custom list with no extra columns added. It is populated as follows:

The “Offices” list is a custom list with one extra column added, which is a lookup to “Regions”. It is populated as follows:

The “Teams” list is a custom list with one extra column added, which is a lookup to “Offices”. It is populated as follows:

Designing the InfoPath 2010 Form

Launch InfoPath 2010 and create a new blank form (or open the form to which you wish to add your dropdowns).

Add three text fields as follows:

Repeat for “Office” and “Team”.

Now drag-and-drop each field onto the form.

Without any formatting your form will look like this:

Right-click each textbox and choose “Change Control > Drop-Down List Box”.

The form will now look like this:

Now we need to create three data sources, one for each dropdown.

Click on the “Data” menu at the top of the window, and then “From SharePoint List”.

We’ll do “Region” first.

Enter the location of the SharePoint site. Note that the lists can be on a different site to the site that our form is going to end up in.

Click “Next”. Select the “Regions” list.

Click “Next”. Select “Title” and change the sort order to “Title”.

Click “Next”. Click “Next” again on the offline option page.

Accept the options on the final page.

Click “Finish”.

Now repeat this process for Offices and Teams, but with the following two changes:

First, include the related column in the fields to select from. So for Offices the wizard will look as follows:

Teams will look similar, but with the “Office” column selected.

Second, uncheck the “Automatically retrieve data when the form is opened” option. For all but the first dropdown, we won’t be getting the data until the previous dropdown is changed.

Ok now we need to hook up our dropdowns to our data sources. Right click the “Region” dropdown and choose “Drop-Down List Box Properties”. In the “List box choices” section choose “Get choices from an external data source”. Make sure the data source is “Regions” and amend the “Display name” field to Title (using the button on to its right) so that the form looks as follows:

Click “OK” and repeat for the “Office” and “Team” dropdowns, choosing the appropriate data source in each case. Make sure the “Value” and “Display name” fields are always correct. So for “Office” the form looks as follows:

If you preview your form at this point then the “Region” dropdown should be populated but the other two should not.

Finally we need some rules to make it all work.

Select the “Region” dropdown, then on the “Home” tab at the top, choose “Manage Rules”.

On the “Region” dropdown we will add a single rule. Choose “New, Action”.

Change the “Details for” to read “Populate Offices”.

Now choose “Add, Set a field’s value”.

The field we will set is the “Region” field on the “Offices” data connection. This will act as a filter on the list of offices, only displaying those that have the correct region.

Click the button to the right of “Field”. Change the dropdown at the top to “Offices (Secondary)” and expand “queryFields” to select “Region”.

Click “OK”. Now click the “fx” button to the right of the “Value” field. Click “Insert Field or Group…”

Choose “Region”.

Click “OK”. The formula shows as follows:

Click “OK”.

Now add another action to the rule, again to “Set a field’s value”. This rule will simply set the “Office” field to blank, to clear out any old values.

Now add an action to “Query for data”.

Set the data connection to “Offices”. Click “OK”.

If you preview your form now you should be able to select a region and see the correct list of offices populated.

Now we set up the rules on the Offices dropdown. Select the dropdown and click on “Manage Rules”.

Add a new formatting rule:

Change the details to “Disable if Region Blank”. Click on “None” under “Condition. Set the condition as follows:

Select “Disable this control”.

Next add a new action rule.

Call this rule “Populate Teams”.

Add an action to set a field’s value.

Pick the Teams/Office query field.

Set the value equal to “Office”.

Add another action to set “Team” to blank.

Add a final action to query the teams data connection.

Finally add a formatting rule to the “Teams” dropdown. This rule will disable the control if “Office” is blank.

Now preview your form and check everything works!

Provided all is okay you can publish your form. If you want to use InfoPath Forms Services within SharePoint 2010, it should work fine.

Back to PointBeyond web site.

When Collaboration Becomes a Commodity, How Do You Choose a Platform that Adds Value?

When SharePoint was first released, the idea of a web site where users could upload documents, and manage their own lists, calendars, etc was quite novel to many people. It was, as we all know, a runaway success and SharePoint has been widely adopted across many organisations. Many other software vendors, as well as Microsoft, also provide collaboration platforms.

Now more and more collaboration platforms are becoming available, with cloud offerings such as Box.net, Huddle, Google Docs and many others being added to the mix.

One of the differentiators of SharePoint 2010 is that you can use it as a platform for the delivery of business applications, as well as for straightforward collaboration. Even the entry level SharePoint 2010 Foundation gives you:

  • Out of the box and custom lists and views. These lists can be linked to deliver simple data driven applications
  • Built in security model. You can set permissions to control who can see and do what
  • Ability to build workflows using SharePoint Designer
  • Forms that use the InfoPath client (part of some editions of Microsoft Office)
  • Core Business Connectivity Services functionality, for interacting with data in other systems
  • An open platform for enhancement through custom development and integration with other systems
  • Possibility to use SQL Server Reporting Services in SharePoint integrated mode to build reports and dashboards

Once you move up the licencing scale to SharePoint Server 2010 Enterprise, you get the “Composites” functionality that adds significantly to the toolset available for building applications. This includes

  • Excel Services, for interacting with and publishing parts of Excel spreadsheets through the browser
  • InfoPath Forms Services, that takes InfoPath forms and renders them in the browser
  • Visio Services, for publishing data driven diagrams
  • Access Services, for converting Access Databases to SharePoint lists and forms, and allowing browser based interaction
  • Enhanced Business Connectivity Services
  • Various web parts and out-of-the-box workflows

This rich toolset for quickly delivering business applications sets SharePoint apart from many collaboration platforms, and it should be a major consideration for many organisations when choosing a collaboration platform.

Our technology neutral white paper, “The Business Applications Deficit” looks at the drivers behind the need for business applications, and the challenges faced by organisations in implementing applications. To receive your complimentary copy please click here.

Delivering Business Applications with SharePoint Composites: Don’t get Stuck!

Suppose that you are in New York and you want to come to my house. You could look at a map of the world that has New York and my house marked on it. Looking at the map you can see that London Heathrow airport is pretty close to my house. So you think, hey that’s cool I’ll fly over. You pay for your flight, tell me what time you are arriving, and tell your wife/husband/partner how much it costs. Sorted. Easy.

So you jump on the plane and all goes well for a few hours. You arrive at Heathrow and walk out of the airport. Now, Ian’s house is somewhere nearby isn’t it? Actually you’ve got still got 94 miles to go and although you have completed 97% of your journey you aren’t at my house. You’ve no UK currency and your mobile phone is flat (and you can’t plug your charger in because of our rather cool power socket design J). So you are stuck.

Let’s compare this to the case of building a SharePoint business application using tools such as InfoPath, SharePoint Designer, Excel Services and Access Services. It’s all too easy to get started with these tools without an absolutely clear idea of how your end solution will work. The tools allow you to do a lot very quickly. So you pull your application together and it almost meets your requirements. But then you hit a problem: the last little bit requires something that the tools don’t let you do. You are faced with having to resort to another tool, possibly some custom code, or even having to rework what you have already done. Also chances are you need to go back to the business and tell them that you need more time and/or money.

The conclusions to this are really as follows:

  • Before you embark on delivering a business application using SharePoint composites, be absolutely clear about what the end solution will be (where are you going)
  • Be clear about how the tools available will deliver all of the required functionality (what is the means of transport for each stage of the journey). If you do a proof of concept then make sure you tackle the difficult bits of functionality up front. Don’t just do the easy bits so that you can show the business users something nice! It may make them happy in the short term but they won’t like it when you have to go back telling them you need more time and money.

Enjoy your journey!

Back to the PointBeyond web site

Index of SharePoint 2010 Issues and Resolutions

Thought I would consolidate the posts I have made over the last few months into a single index. The topics are quite varied as they comprise issues I have encountered while working on real world projects.

InfoPath web form not loading in SharePoint 2010

Error viewing reports in Access Services

Unable to open the file for an unknown reason in Excel Services

Document IDs and the managed metadata service

Unable to find the content type publishing link in site administration, or to use managed metadata columns

No content types have been subscribed error message

 

 

Back to PointBeyond web site

InfoPath Form not Loading in SharePoint 2010

Something weird going on here…

I’ve a URL to an InfoPath form which renders in the browser. Here is the URL

http://sp2010/_layouts/FormServer.aspx?XsnLocation=http://sp2010/TestForm/forms/template.xsn&OpenIn=browser&SaveLocation=http://sp2010/TestForm&Source=http://sp2010/TestForm

If I start IE and paste in this URL, it works fine.

If I create a desktop icon and click on it, it works fine.

But, if I paste the URL into Word 2010 or Excel 2010 and then click on it, I get the following:

The form never loads. The Javascript error is

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; InfoPath.3; .NET4.0C; .NET4.0E)

Timestamp: Fri, 31 Dec 2010 17:08:08 UTC

Message: Syntax error

Line: 380

Char: 90

Code: 0

URI: http://sp2010/_layouts/FormServer.aspx?XsnLocation=http://sp2010/TestForm/forms/template.xsn&OpenIn=browser&SaveLocation=http://sp2010/TestForm&Source=http://sp2010/TestForm

Message: ‘g_objCurrentFormData_Error’ is undefined

Line: 549

Char: 3

Code: 0

URI: http://sp2010/_layouts/FormServer.aspx?XsnLocation=http://sp2010/TestForm/forms/template.xsn&OpenIn=browser&SaveLocation=http://sp2010/TestForm&Source=http://sp2010/TestForm

Here is line 380

var g_objHasFormPostedBack_FormControl=false;var g_objCurrentFormData_FormControl = [[],[1,[[[2,[0,["","","",-1],[[3,["",["","","",-1],[],false,false,false],-1,false,false,3]],false],-1,false,false,3]],false,[0,0],[1],false],-1,false,false,3],0,”25f04190a0d34663b6ddd45e1bf7966e_ba7c22eb533544e8b20b16a243729ec2″,”AHYXKHSEFSKL2R5RS2PME3RRTJ2RYL2UIVJVIRSPKJGS6RSPKJGVGL2UIVGVATCBKRCS4WCTJYVWE5TIPFDGC4KJOBYVU4DZNNBG2NKCKJWFQSSUIFSTMTTFIZLDEUKMGZLVQ5DQOMZE2S3TA”,1033,”2010-12-31T17:05:57″,”2010-12-31″,["0","","http:\u002f\u002fsp2010\u002fTestForm\u002fforms\u002ftemplate.xsn","http:\u002f\u002fsp2010\u002fTestForm\u002f","http:\u002f\u002fsp2010\u002fTestForm\u002fforms\u002ftemplate.xsn","http:\u002f\u002fsp2010\u002fTestForm",1,0,"FormControl",0,false],”View 1″,0,false,”TestForm – New Form”,1,”",”http:\u002f\u002fsp2010″,”ltr”,”http:\u002f\u002fsp2010″,6.34294119577127E+17,”0″,”",false,1033,”http:\u002f\u002fsp2010″,[],false,true,”",”",”0″,false,”",true,2,”",”",”",”puN2wNKuBBJ\u002fcJfi\u002fht858J7Kvg5lmIm3Ab\u002foyQb9bCuc13KdA2g5VC5SATX4mcEeMyOPR8V5fq6oC0bSAFFAQ==|634294119576971096″];

Some pretty weird looking characters after the second equals sign. If I refresh the page (F5) it works.

Line 380 now a more healthy looking

var g_objHasFormPostedBack_FormControl=false;var g_objCurrentFormData_FormControl = [[],[1,[[[2,[0,["","","",-1],[[3,["",["","","",-1],[],false,false,false],-1,false,false,3]],false],-1,false,false,3]],false,[0,0],[1],false],-1,false,false,3],0,”25f04190a0d34663b6ddd45e1bf7966e_dab1b19fd5bd43229c497a0710468307″,”AHYXKHSEFSKL2R5RS2PME3RRTJ2RYL2UIVJVIRSPKJGS6RSPKJGVGL2UIVGVATCBKRCS4WCTJYVWE5TIPFDGC4KJOBYVU4DZNNBG2NKCKJWFQSSUIFSTMTTFIZLDEUKMGZLVQ5DQOMZE2S3TA”,1033,”2010-12-31T17:17:07″,”2010-12-31″,["0","","http:\u002f\u002fsp2010\u002fTestForm\u002fforms\u002ftemplate.xsn","http:\u002f\u002fsp2010\u002fTestForm\u002f","http:\u002f\u002fsp2010\u002fTestForm\u002fforms\u002ftemplate.xsn","http:\u002f\u002fsp2010\u002fTestForm",1,0,"FormControl",0,false],”View 1″,0,false,”TestForm – New Form”,1,”",”http:\u002f\u002fsp2010″,”ltr”,”http:\u002f\u002fsp2010″,6.34294126273283E+17,”0″,”",false,1033,”http:\u002f\u002fsp2010″,[],false,true,”",”",”0″,false,”",true,2,”",”",”",”ye\u002fl3NLOSE8tEEvuHJw\u002bV8BbPew9HmxiavUkjgd\u002b\u002bkYa\u002f1J82qWX\u002bpwjlvGijygad0J6I7Vkp3onbQv56VLbwA==|634294126273282857″];

So why should clicking a link in Word 2010 or Excel 2010 be any different to following any other hyperlink? Over to Microsoft on this one I think! Anyone any ideas?

UPDATE: It seems a bit intermittent. Also setting the regional settings of the SharePoint site to “English (UK)”, the same as my client computer, seems to fix the problem.

 

Back to PointBeyond web site



Follow

Get every new post delivered to your Inbox.