June 2007 - Posts
I was preparing hands-on-lab to equip some of the developers with the skillsets to deliver a project. When trying to create a CustomAction, the SDK said that ContentTypeId is used to specify the ID of a content type to associate with the custom action. However, that doesn't work.
Instead, use RegistrationId to specify the ID of the content type you would like to associate, and assign "ContentType" to RegistrationType does what I need easily...
Now, any tips for a newbie running a hands-on-lab?
When defining a field in your feature, sometimes you want to do condition rendering, depending on what values are captured in certain fields. To retrieve them, you can use <Field Name="..."/> or <Column Name=".."/>
Field element returns formatted value, while Column element returns raw information. So for a field of type boolean, a Field element will return "Yes" / "No" while a Column element will return 1 / 0
I was working on a POC for a client that wanted to implement SOA for his company. Microsoft sold them a story of using BizTalk for the Enterprise Service Bus, and SharePoint (or OBA) for the frontend, portal, workflow, integrating with SAP, and other databases... It's a two weeks project, and we asked for competent people for the job, since time is little, and each team member has to be skilled (or at least know how to find solutions to solve the problems themselves). Was working with an empty shell, which made everyone (including the customer and Microsoft) panicked. WOW, you can be amazed the gap between the level of competency they declared and what they actually have... (So much so I decided to do part of his job to make sure I can get my part working... BizTalk orchestration have to be working for me to test out my InfoPath forms)
In come this hero, and after a week, with two nights of hardwork, we managed to complete the whole POC (which would otherwise failed terrible) around, gaining much confidence from client. At the end of the presentation, two thumbs up was given, and praises was flying around...
And this hero is now blogging here...
In this blog post, Scott Heim talked about adding a Contact Selector Control into your infopath form. Contact Selector Control requires a fix data structure for it to work. My first thought was, this would limit the usage, since you can't have the same field name in a InfoPath form. But wait... I remember OOTB workflow initating forms which is powered by InfoPath Forms Services (at least I was told) does have multiple Contact Selector Controls. Google doesn't help, trying various ways doesn't help... until I clicked on Add Reference, which recreates the entire structure in another section of the form.
Checked Microsoft's documentation. It says
[Quote Url=http://office.microsoft.com/en-us/infopath/HP010967521033.aspx]
The fields and groups that you add to the data source define the type and structure of the data that users can enter into your form. If you want to match the properties of an existing field or group to a new field or group, you can also add a reference field or reference group to your form
......
When you reference an existing field, Microsoft Office InfoPath 2003 creates a new field whose properties are linked and matched to the properties of the original field, including the name and data type. Both fields become reference fields, and any changes you make to one field updates the other field automatically
[/Quote]
I don't understand what they are saying. What worried me was the last statement "changes you make to one field updates the other field automatically". Nevertheless, I still gave the reference field a try, crossing my fingers that I store different information in the two fields. After some testing, I realise what the statement meant. It updates the definition, not the value of the fields, hence you can have different values... 
So how do you add multiple contact selectors?
Using a email form, first of all, follow the instructions in the blog entry to create the structure requried by Contact Selector Control. For myself, I created it under the group named "To"
Then, create a group named "CC"
Right click on the group named Person, and select "Reference"

Select CC, or other target group you want the structure to be in

And your data source should look like this.

Drag and drop the two groups onto the form, and select Contact Selector, and now you have two contact selectors which can have different values!

P.S. Screenshots are done using SnagIt. Saved me lots of time. :)
I have been facing this error everytime I start an InfoPath project, and I keep forgetting the reason why. I mean I got the answer for this during Beta 2 timeframe, and it still doesn't get into my head...
InfoPath Team blog has posted the reason why here. It is because a nillable attribute is typically present when the following data types are null:
- Whole Number (integer)
- Decimal (double)
- Date (date)
- Time (time)
- Date and Time (dateTime)
Setting the above types with certain values without removing the attribute will cause schema validation error. The team blog has provided a generic function to remove the nillable attribute, but do you know that you have to put the attribute back when you want to set that same element back to null? So I'm going to provide you the generic function to insert back the nillable attribute. And for completeness sake, I'm going to copy the generic delete function here as well.
public void DeleteNil(XPathNavigator node)
{
if (node.MoveToAttribute("nil", "http://www.w3.org/2001/XMLSchema-instance"))
{
node.DeleteSelf();
}
}
public void InsertNil(XPathNavigator node)
{
if (!node.MoveToAttribute("nil", "http://www.w3.org/2001/XMLSchema-instance"))
{
node.CreateAttribute("xsi", "nil", "http://www.w3.org/2001/XMLSchema-instance", "true");
}
}
When you want to set the node with certain value,
DeleteNil(xpathMyNode);
xpathMyNode.SetValue(DateTime.Today.ToString());
When you want to set the node to empty,
xpathMyNode.SetValue(string.Empty);
InsertNil(xpathMyNode);