Friday, December 29, 2006

Try the 2007 Microsoft Office Systems for 60 days

You can download a trial of the 2007 Microsoft Office Systems on htpp://www.trymicrosoftoffice.com

Microsoft Office InfoPath 2007 is not included in any trial package. :-/

For the Office 2007 in dutch, you can go to http://benelux.trymicrosoftoffice.com

Sunday, December 03, 2006

Restricting the number of File Attachments

It's quite simple to restrict the number of attachment in a specific InfoPath Form.With some knowledge of XPath expressions you can easily extend the InfoPath default behaviour.

Following these steps:
1. Create a new InfoPath form
2. Add a repeating section on your form (Design Task Pane > Controls) -> name: group1

3. Add an 'File Attachment' control in your repeating section -> name: field1
4. Double click on the 'repeating section' label to open its properties
5. Go to the Display tab and click on 'Conditional Formatting'
6. Click on the 'Add' button
7. Select 'The Expression' and enter following expression: 'count(my:field1) >= 10'
8. Apply following formatting: 'Don't allow users to insert or delete this control'
9. Click on OK (3 times)





10. Re-open the properties of the repeating section to open the conditional formatting again.
Have a look at the formatting you just have added ...
Your expression will be converted into another expression:
'Number of occurences of field1' is 'Greater than or equals to' 10




11. Test your form now and try to add 11 items ...

Monday, November 20, 2006

Enabling PDF search on WSS v3 (beta)

Lots of troubles to enable the search functionality in WSS v3.
I found a fantastic article on Stan Spotts' blog about enabling PDF search on WSS 3.0 beta.

You must still use the Adobe iFilter for PDF's like you did in Sharepoint 2003, but you need to check some registry settings to make sure that WSS indexes your PDF documents correctly.

Click here to visit Stan Spotts' article.

Limitations
a It only indexes PDF documents after you have configurated this functionality.
a You can only search for full words

Search doesn't work ?!
I had a lot of troubles to configure the search functionality (without the PDF search).
Keep in mind to configure your Search Server first and then create your Content Database !
It seems that the order is very important in the beta version.

Wednesday, November 15, 2006

Enabling InfoPath Forms Services 2007

It is quite simple to enable InfoPath Forms Services 2007 on your Microsoft Office SharePoint Portal 2007. Follow the steps below to use browser-enabled forms:

I. Central administration

1. Go to the Central Administration

2. Click on Application Management
3. Click on Configure InfoPath Form Services under the InfoPath Forms Services section.
(http://yourserver/_admin/ipfsConfig.aspx)



4. Make sure that browser-enabled form templates are allowed
(Check all checkboxes in User Browser-Enabled Form Templates)



5. You can specify other options if necessary. Click on OK to apply the changes.
6. You can close the Central Administration Website.



II. List Configuration
I created a new Document Library on my site called 'InfoPath Forms'. This document does not open InfoPath forms in your browser directly. You must configure this list in this way:

1. Open the List which contains browser-enabled InfoPath Forms
2. Click on Settings and select Document Library Settings


3. Select Advanced Settings Under 'General Settings'
4. Configure the Browser-enabled Documents section and select 'Display as a Web page'



5. Click on OK to confirm the changes



III. Publishing InfoPath Templates
Use the Publish Wizard to deploy the form on your Sharepoint Portal Server.
Define the location, promote the fields and publish!
(In this example you must update an existing Document Library)

Use following URL structure to deploy
http://yourserver/SiteDirectory/YourSite/YourList/Forms/AllItems.aspx



IV. Testing the deployed form
Create a new document in your 'InfoPath Forms' list. The form will be automatically open in your browser.




V. Tips
aYou can manage the toolbars at the top/bottom in InfoPath 2007.
(menu Tools > Form Options > Browser > 'Show toolbar at top/bottom of form')

VI. Download this example
download the example here

Tuesday, November 14, 2006

FormErrorCollection - Errors Property


Custom validation with managed code will be improved in InfoPath 2007. Several new classes provides the possibility to generate data validation errors in code.

In InfoPath 2003 it was possible to generate errormessages (in JScript or through the .NET framework), but it wasn't possible to draw a border around the field which indicates the error.

InfoPath 2007 provides a FormErrorCollection containing FormError objects in the XmlForm as the 'Errors' property.

Methods
1. Errors.Add(XPathNavigator context, string name, string message);
It act like a Key/Value (name/message) collection and each error points to the node to which the error is associated (context).

2.
Errors.Delete(string name);
You can remove the FormError by using the Key in the Errors.Delete method.


Example

public void InternalStartup()
{
// ...
EventManager.XmlEvents["/my:myFields/my:SampleField"].Validating +=
new XmlValidatingEventHandler(SampleField_Validating);
// ...
}

//Right-click on the control > Programming > Validating Event ...
public void SampleField_Validating(object sender, XmlValidatingEventArgs e)
{
// check if the new value isn't empty
if (!String.IsNullOrEmpty(e.NewValue))
{
//current fieldvalue cannot be 'example'
if (e.NewValue.ToLower().Equals("example"))
{
//e.Site points to the node that is being changed, e.Site is always the reference to the field which you are validating at that moment
Errors.Add(e.Site, "Error_SampleField", "Invalid fieldvalue");
}
else // all other values are allowed
{
Errors.Delete("Error_SampleField");
}
}
}



Conclusion
a The FormErrorCollection is also accessible in Form Services 2007 !
a It acts like the 'real' Data Validation (at design time)
a You cannot submit the form without resolving the errors !
Microsoft InfoPath 2007 Object Model
2007 Office System: Developer Posters

Thursday, September 14, 2006

Free licence keys for Windows Vista RC 1

You can obtain free serial numbers to try Windows Vista Release Candidate 1.
First you have to log in with your Microsoft Passport on the german live.com website.
After completing some questions, a licence key will be generated.

Download links:

This Windows download is not the 'Enterprise' edition. Without this free key, you can use Windows Vista RC 1 just for 14 days. After the trial period you can insert a licence code (only for the 'Ultimate' edition)

Saturday, September 02, 2006

Free e-books about Office 2007, Windows Sharepoint Services 3.0 & Sharepoint 2007

This week I found free e-books on Scattered Notes.
A big thanks to the
.NET aficionado who sent me the link.


You can directly download the free e-books in this post:

Homepage: Microsoft Office Systems 2007

Sunday, August 20, 2006

Picture Buttons in InfoPath 2007

In InfoPath 2007 it is impossible to create buttons with images as background. But, you can adapt some InfoPath files by yourself to create those picture buttons. Follow my instructions:

1. Create a new InfoPath form template

2. Add a new button. (
The button has ‘button’ as standard label.The border is black and the background is gray.)

Remar
k
In InfoPath 2003 it was still possible to replace the label value with a space character to have a button without text. In InfoPath 2007 it is impossible to add a space character as label value. We replace the standard value with ‘myvalue’.


3. Go to Tools > Resource Files and Add an .gif file as a Resource file. Rename the file to ‘picture.gif’.

4. Save your form template to ‘test.xsn

5. Now, go to the location where you stored the form template and rename ‘test.xsn’ to ‘test.cab’.

6. Extract all files and open View1.xsl with notepad. This stylesheet file renders the xml data. The content is written in HTML en CSS. The XSL has the same relation like HTML & CSS has. HTML files contain content and CSS files contain style definition which can be applied to the content files (HTML files).

7. Navigate to the Style endtag.

8. Add a new CSS definition for the picture button

.imageButton
{
BACKGROUND-IMAGE: url(picture.gif);
BACKGROUND-REPEAT: no-repeat;
}


9. Navigate to the input tag in the body which defines our button and add the newly created CSS definition the class attribute.

... class="imageButton langFont" ...



10. InfoPath 2007 does not support an empty buttonlabel. But you can change the label manually in this file. So replace the ‘myValue’ in the value attribute with empty quotes.
... class="imageButton langFont" value="" ...



11. Save and close View1.xsl.

12. You can now reopen your form by right-clicking on manifest.xsf and select ‘Design’ in the menu.

13. The picture will be integrated in your view right now.

Greg Collins also wrote an article about Picture Buttons for InfoPath 2003.
My article is a supplement on his article.

Sunday, August 13, 2006

Switch view when drop down list has changed


It’s impossible to use the ViewInfos.SwitchView(string) method while the changed event is running. You can only switch a view by using the button clickhandler. This post will create a workaround to change view without clicking on buttons.

1. Using ViewInfos.SwitchView() method in the Changed event

While firing events it is impossible to switch to another view. Only the Click event on the button will permit a ‘SwitchView’ action. In all other cases you will receive a COMException at runtime.


public void InternalStartup()
{
EventManager.XmlEvents["/my:myFields/my:list"].Changed +=
new XmlChangedEventHandler(list_Changed);
}

public void field1_Changed(object sender, XmlEventArgs e)
{
ViewInfos.SwitchView("view2");
// The code is successfully compiled, but will not run !
// It results in a run-time error (COMException)
}

Redirecting to another view is not quite simple. We have to use other tricks


2. OnContextChange event is asynchronous

The OnContextChange event is fired when the form or elements on the forms has been changed. There is just a little problem the event is asynchronous. So, it does not fire on every change in the context node.

Instead, it fires the event when all other events has been terminated.We will use the OnContextChange event (which is only enabled if you created a form without browser-compatible features) to redirect to another view.Test the Asynchronous OnContextChange event:



public void InternalStartup()
{
EventManager.FormEvents.ContextChanged +=
new ContextChangedEventHandler(FormEvents_ContextChanged);
}

public void FormEvents_ContextChanged(object sender, ContextChangedEventArgs e)
{
System.Windows.Forms.MessageBox.Show("context changed");
}


While selecting several values in the drop down list, you will see that the OnContextChange event will not fire on every change in the context node.


More information:
Microsoft - OnContextChange event



3. Change the focus to force the OnContextChange event

We cannot trust on the OnContextChange event because it’s asynchronous. So we have to force the OnContextChange event by changing the focus from the drop down list to another field through code.

To change the focus we will use a textbox which must be visible and not read-only. You cannot set the focus to every control. More information :
http://blogs.msdn.com/infopath/archive/2004/04/07/109189.aspx

Following code will be executed while the ‘changed event’ of the drop down list has been fired.



public void list_Changed(object sender, XmlEventArgs e)
{
SetFocus("/my:myFields/my:unusedfield");
}

private void SetFocus(string xpath)
{
XPathNavigator fieldToFocus = MainDataSource.CreateNavigator().
SelectSingleNode(xpath,NamespaceManager);
this.CurrentView.SelectText(fieldToFocus);
}


Download the new InfoPath 2007 Object Model by this link:
http://download.microsoft.com/download/0/9/c/09cda3f2-6d3d-4082-aec5-9a62b7679ecf/Office2007InfoPathOMPoster.exe




4. Switch to another view

Now we can implement the OnContextChange method which allows to use the SwitchView() method.


public void FormEvents_ContextChanged(object sender, ContextChangedEventArgs e)
{
ViewInfos.SwitchView("view2");
}


The code is insufficient. The OnContextChange event will fire many times while filling in a form. It is not every time allowed to change the view. We need an extra variable which indicates if the SwitchView() method me be called.


private bool canRedirect = false;
public void FormEvents_ContextChanged(object sender, ContextChangedEventArgs e)
{
if (canRedirect)
{
canRedirect = false;
ViewInfos.SwitchView("view2");
}
}



5. Complete code


public partial class FormCode
{
public void InternalStartup()
{
EventManager.XmlEvents["/my:myFields/my:list"].Changed +=
new XmlChangedEventHandler(list_Changed);
EventManager.FormEvents.ContextChanged +=
new ContextChangedEventHandler(FormEvents_ContextChanged);
}


private bool canRedirect = false;
public void list_Changed(object sender, XmlEventArgs e)
{
canRedirect = true;
SetFocus("/my:myFields/my:unusedfield");
}

private void SetFocus(string xpath)
{
try
{
XPathNavigator fieldToFocus = MainDataSource.CreateNavigator().
SelectSingleNode(xpath,NamespaceManager);
this.CurrentView.SelectText(fieldToFocus);
}
catch (ArgumentException ex)
{
MessageBox.Show("The focus cannot be set to " + xpath);
}
}

public void FormEvents_ContextChanged(object sender, ContextChangedEventArgs e)
{
if (canRedirect)
{
canRedirect = false;
ViewInfos.SwitchView("view2");
}
}
}




6. Tips
You can hide the ‘canRedirect’ member by writing a wrapper class around this member


Tuesday, August 08, 2006

Hiding check boxes and DateTime controls

InfoPath still does not allowing hided checkboxes and DateTime controls.
In certain situations it’s recommended to hide those controls for the users.
The conditional formatting options are restricted and we can only disable them.

Use following trick to hide controls:

1. Create an empty group (for example: CheckTest) in the main datasource.
This group will act like a wrapper section for the Checkbox (which can not be invisible)


my:myFields
-> CheckTest





2. Add a Boolean field into 'CheckTest'
If you don't want to hide FieldA, you can add this field directly below my:myFields.


my:myFields
-> CheckTest
-> FieldA


3. Use ‘CheckTest’ as Section on the screen.

4. Use conditional formatting to hide this section when the user may not see the check boxes.
Perhaps you need another field to base your conditional formatting on.
For example: if FieldB is empty then 'Hide'.


Tip: You can base your conditional rule on another field which is calculated by customized code or directly based on existing fields or expressions in your form.

For a detailed example please read Greg Collins' article on InfoPathdev.com

Monday, July 03, 2006

InfoPath 2007: Form Template Parts

In InfoPath 2007 it will be possible to reuse forms by creating Form Template Parts.
You can compare those Form Template Parts with regular forms, which you can reuse into other forms.


Form Templates Parts Step by Step

For example: You have several forms which contains customerdata. It would be a lot of work to copy & paste all fields, conditional formatting and rules. If you have 10 customer datafields (name, address, postal code, ...) which will be reused on 5 forms, you have to manually adapt your main data source in each form in InfoPath 2003.

Now, in InfoPath 2007 we can create a separate form which contains our customer datafields and we save the template as an .XTP file.


1. How to create a Form Template Part ?

Open Office InfoPath 2007. Open the File menu and select 'Design a form'.
Select 'Design a new Template Part'. (we will base our example on a 'blank' form template)

Now, It seems that InfoPath has created an empty form for you, but it isn't.
This will be our Form template Part, which will be reused on other forms.

2. Managing data structure of a Form Template Part

You can add new datafields to your template by drag & drop some controls on your form.
You can also manually insert, update or remove datafields when you select 'Data Source'
in the Design Tasks taskpane. The root of you template will also be named 'myFields'.

I suggest you change the myFields root element into a more specific name like 'customer'.
The form which will reuse this template will copy this root element and his child elements into its form.
So it is usefull to change the root element in a understandable name for reuse.

3. Designing your template

You can design your form in the same way you design a regular form in InfoPath 2007.
You can add conditional formatting to manage the color or the visibility (hide/show/disabled) of your components.
You can also add some rules or data validation handlers to process your data.

4. Save your template

The template you have made, will be saved as an XTP file on your harddisk.
You can save your template in the same way you did by forms.

5. Reuse the template

Now you have to create a new form which will be based on our template.
Open the File menu and select 'Desig a form...'.
This time you will 'Design a new Form Template' based on a 'blank' form.

Before you can use your template, we have to import the Form Template Part as a custom control.
Open the 'Controls' panel in 'Design Tasks'. In InfoPath 2007 you will find a new item in this controls list which is called 'Custom'. You can import your template by clicking on 'Add or Remove Custom Controls...'
Point to the right template location on your harddisk and add the template as a custom control.

Drag & drop your created custom control on the screen.
The root and its child elements will be copied from the template into the main datasource of your form.
It is also possible to drag and drop more than one occurence of your template in the form.
InfoPath will automatically add '_x' to the imported datastructure to identify every field as a unique item.
(replace the x by a number starting from 1, 2, 3, ...)

Save and publish your form. The Form Template has been successfully integrated in your form.

6. Download the Customer example

You can download an example including an .xsn form which is based on a .xtp template.
The Word 2007 document will show you some screenshots.
(Data logic will not be added to the form, because it isn't relevant in this exercise)

Form
Invoice form

Template
Customer Template

Screenshots (Word 2007)
screenshots

Example Invoice (without data logic)
invoice example



Saturday, May 27, 2006

InfoPath 2003: Tips

1. Create a “please wait” and a “start up” screen when you receive or submit data to a data source.
(Use a combination of the OnContextChange and OnSwitchView InfoPath methods to create such please wait views.)

2. Use the Wingdings font to show images on buttons

3. Provide a static class in JavaScript or C# which contains methods to obtain data fields of your form. It will save you a lot of code to get and set data in your form!

Example:
my:myFields
---- my:Customer
--------- my:CustomerName
---- my:Product
--------- my:ProductName

> Use: Path.GetInstance(thisXDocument).GetCustomerItem(“my:CustomerName”)
> Class: Path
> Static Method: GetInstance(XDocument thisXDocument) [singleton pattern]
> Methods GetCustomerItem() (to retrieve object(s) of IXMLDOMNode = return type)

4. Avoid cycles, think about the need of rules,

Please think about ...

  • how many rules I will need,
  • which fields must have rules.
  • ...

    (Without this analysis, you will create cycles in complex forms)
    (Too much rules are not maintainable)

5. Let's hope that InfoPath 2007 will provide more functionality:

  • Clickable images
  • Support for repeating sections within other repeating sections (no recursion)
  • a list with all rules and conditional formatting per control and field

InfoPath 2003: do's and don'ts

I am currently a Office - InfoPath 2003 consultant. I really learn a lot about InfoPath and its boundaries. In my opinion it's interesting to summarize some practical do's and the don't for InfoPath 2003 before you promote InfoPath as Office's wonder. Those do's and don't can be a start for a new post. ;-)

Here they are:

Don’ts

- Do not make applications in InfoPath 2003 with logging, historical data
- InfoPath 2003 does not support workflows
- Do not create a form with one or more views for several roles when each role or view has its
own rules. Rules are bound to data fields. So, if you use a rule on view 1, the rule will also be executed in other views. On the other hand conditional display formatting will be executed per control which represents a field on one view. So, a conditional formatting on view 1 will not influence other views.

- Do not use InfoPath as GUI + business + database
- InfoPath does not support multi – languages (if the company forbid to use several views per language)


Do’s

- Create forms in InfoPath 2003 without workflows. Do not call your form an application !!!

Examples:
a form to request your holiday, a form which represents a bill and calculate totals


- InfoPath is perfect to replace the GUI part of your application, but it’s very difficult to replace all layers in your application.

Use InfoPath to show and format data from databases, web services, SharePoint, …
InfoPath can be a perfect smart client which can show, send, format, calculate data … but nothing more …

- If you use different rules on the same fields for different form users (roles). I suggest to divide the form in more than one form which will separate the rules for all different users. So, there will be no rule-conflicts.

- I prefer Visual C# to write custom code. You can use the IntelliSense of Visual Studio which can reduce frustrating moments in JavaScript.

Sunday, January 08, 2006

How to enable SSL for IIS

Enabling SSL in 4 steps


1. First of all you have to install the IIS Resource Kit

Download location:
http://www.microsoft.com/downloads/details.aspx?familyid=56FC92EE-A71A-4C73-B628-ADE629C89499&displaylang=en


2. After the installation you must retrieve your virtual server ID. (if you want to specify virtual server which different from ‘Default Web Site’ which has ID = 1)
(virtual server example > c:\inetpub\spsroot)

You will use MetaBase explorer to retrieve the ID. You can find this program under the newly created directory 'ISS resources' in your start menu.

In MetaBase explorer, you will open the server > LM > W3SVC node
Under W3SVC you can find several ID's with their corresponding data.
In this case: ID = 407700768 (c:\inetpub\spsroot)



3. Now we will enable SSL with SelfSSL (another program in the IIS Resource Kit)


This program uses several parameters to configure SSL on your virtual server.
Type the following command:
selfssl.exe /N:CN= /K:1024 /V:7 /S:487700768 /P:443
(you can find the meaning of the parameters in the documentation)

4. Surf to the secured website: https://servername

Attention please: do not use the port of your virtual server to access the secured portal.
for example: http://servername:101 becomes https://servername.
SSL uses port 443 as default.

How to delete your WSS sites completely ?



It seems to be easy, but to delete WSS sites you have to do 3 things:

1. Remove the physical path
Go to your WSS site > Site Settings > Go To Site Administration > Management and Statistics > Delete Site



2. Remove the link to the WSS site
Go to SiteDirectory (http://server/SiteDirectory/Lists/Sites/Summary.aspx) > Manage Sites



3. Exclude the site of the search results
Portal > Site Settings > Configure search and indexing > View sites pending approval for indexing



Your WSS site has been deleted successfully!