SharePoint, InfoPath, .Net and more
One great feature of SharePoint and versioning is the ability to have versioned comments. This can allow a small discussion to occur on almost any item. It also allows someone to keep a running log of notes on certain items.
I had the wonderful task of figuring out how to get this to work the same in InfoPath. Below is a function that will append the notes into a repeating group. On submit of the form, I call this function and it works great, everytime!
public void AddAnalystNotes() { try { //this is the text box the user enters their notes into. if (GetNodeValue(GetRootNodeName() + "/my:DetailsSection/my:AddAnalystNotes/my:AddNotes") != "") { //this is the group in the datasource just above the repeating group XPathNavigator selReqs = MainDataSource.CreateNavigator().SelectSingleNode( GetRootNodeName() + "/my:DetailsSection/my:AnalystNotesGroup", NamespaceManager); string nsPrefix = selReqs.Prefix; string nsURI = selReqs.NamespaceURI; //this is the repeating group of notes XPathNodeIterator selAnalyst = MainDataSource.CreateNavigator().Select( GetRootNodeName() + "/my:DetailsSection/my:AnalystNotesGroup/my:AnalystNotes", NamespaceManager); XmlWriter writer; //if there are already items in the list, pop this new note at the top if(selAnalyst.Count > 0){ selReqs.MoveToChild("AnalystNotes",nsURI); writer = selReqs.InsertBefore(); }else{ writer = selReqs.AppendChild(); } //now write the values writer.WriteStartElement(nsPrefix, "AnalystNotes", nsURI); writer.WriteElementString(nsPrefix, "CreatedDate", nsURI, DateTime.Now.ToString()); writer.WriteElementString(nsPrefix, "CreatedBy", nsURI, SPContext.Current.Web.CurrentUser.Name); writer.WriteElementString(nsPrefix, "Notes", nsURI, ""); //have to create a blank entry then add the value later down the line writer.WriteEndElement(); writer.Close(); //gets the text box with the new notes in it XPathNavigator xnotes = MainDataSource.CreateNavigator().SelectSingleNode( GetRootNodeName() + "/my:DetailsSection/my:AddAnalystNotes/my:AddNotes",NamespaceManager); selAnalyst.MoveNext(); //grab the first element, the default is root //had to use InnerXml, the value to value loses HTML formatting selAnalyst.Current.SelectSingleNode("my:Notes",NamespaceManager).InnerXml = xnotes.InnerXml;
//clears the text box SetNodeValue(GetRootNodeName() + "/my:DetailsSection/my:AddAnalystNotes/my:AddNotes", ""); } } catch (Exception ex) { WriteErrorToLog("addRequestor_Click", "Adding analyst noteserrored", ex); } }
Then in the view, format the repeating group to be read-only and blamo, versioned comments.
0822e798-92e9-44b6-879d-fb4d43023674|0|.0
This appears to be a well known issue, but I just ran into it with a customer of mine. It appears that when you insert a custom list form in SharePoint Designer, it doesn't have the correct objects for attachments. Check out the following article for the fix.
http://support.microsoft.com/Default.aspx?id=953271
You will need to install a hot fix, make sure you installed SharePoint SP1 first, and then update the code on the pages.
A few of my own notes - Pay attention when you're pasting the code samples. I think SharePoint Designer converted the quotes in this article to the HTML version: from " to " so you'll have to go through and change them back. - To close the webpart in WSS since Edit Page is not available as it is in MOSS, change the value <IsIncluded>true</IsIncluded> to false. You will still see it in SPD, but it'll be grayed out.
HTH
825b9e8a-faf4-4f32-99f3-d3ca6455ae99|0|.0
It appears my customer and I are on the cutting edge of InfoPath development with Form Services. We are CONSTANTLY running into issues and bugs. I try my best to post what we find to help anyone else running through the same issues. This issue is a doosy.
Our scenario is this: We have 3 server farms setup, one for development, one for staging and testing and one for production. We are creating InfoPath forms in Visual Studio 2008 and each have loads of codebehind (handling loading, saving, webservices, etc). We publish the form, with several promoted fields, to Dev first and make sure it works, then publish it to Staging, then after rounds of testing it's released on the Production server. The promoted fields are almost assigned to existing site columns. This works great, in theory.
The issue is that once in a while, for no explained reason, whether publishing to any of the three servers, if I were to add a new field to a form, or modify the schema a little, that's when it hits the fan. The magic that is the InfoPath Publishing Wizard will decide to create a new site column for a promoted field that was already assigned to a site column! YES, it's true!
So for example we have a field in every InfoPath form called FX Form ID. Walking through the wizard, I make sure the FX Form ID field is bound to the correct site column. After the wizard is complete, I deactivate the current form, upload the form and the reactivate it. I take a look at Site Columns in Site Settings and I now see TWO FX Form ID FIELDS! Grrr...
I pulled up SharePoint Manager 2007 (awesome tool for analyzing exactly what is going on in SharePoint) on the server and took a look at the list of fields for the root web. Sure enough, there are two of the same field. They are exactly the same except for the Ids and Internal Names are different, each their own unique GUID.
Unfortunately, there is no easy way to remap the existing data and fields into a single column. I'd bet there is a way in the SQL tables to do it, but that'll void any support from Microsoft, and probably make matters worse. What you can do is moving forward, make sure it doesn't happen again.
The Work Around
Working closely with a Microsoft SharePoint Architect (as soon as he get's a blog I'll point you to it), we figured out a workaround. It works great, just very tedious. Here's what you do:
1. Close the mnifest.xsf design view and open it in XML editor (right click and select Open Wth)
2. Search for the field name, in this example Form ID. You should see something similiar to this towards the end of the file.
<xsf:field name="Form ID" columnName="{81BDA8CC-A286-405F-8A3B-E5ADB18D9FFB}" node="/my:myFields/fxformstate:FormState/fusionx:FormID" type="xsd:string"></xsf:field>
3. Now search for the columnName value, the GUID, in this same file. You should find something like this.
< xsf2:fieldExtension columnId="f765018d-6b66-4b03-8408-2d6a1f8f0060" readWrite="yes" columnName="{81BDA8CC-A286-405F-8A3B-E5ADB18D9FFB}"></xsf2:fieldExtension>
4. Note the columId value and open SharePoint Manager 2007 on the SharePoint server.
5. Expand the website then Fields (or if you want to see what existing forms are using, expand ContentTypes then the form name, then Fields).
6. Find the field and note the Id. Does it match the columnId value from the manifest file? If so, then you're fine, go get a coffee.
7. If they do not match, then InfoPath thought better of using the existing column and wanted to use another. Or if your columnId is blank, ="", then it wanted to create a new one. This here is the mystery, why did InfoPath decide the field you selected wasn't important enough, I don't know.
8. Copy the value from SPM and replace the value in the columnId in the manifest file.
9. Close the manifest file and open it normally in VS, allowing the design view to appear. You can now publish the form. When publishing, DO NOT modify the field in the Column list. This may overwrite the value you entered in. Continue through the publishing wizard and upload to MOSS.
If all goes well, the new content type or the upgrade should use the same column as selected. To verify, open SharePoint Manager on the server, expand the website then Content Types and find your form name and check the ID of the Field.
I hope this helps!
60090ff6-13e6-439f-85ca-64e4a0a1c149|0|.0
A customer's MOSS implementation stopped sending alerts after items were being updated. If someone was to sign up for an alert they would get the initial email but then after that no more alerts.
If you look in Central Administration and go to Operations then Timer Job Status, you should see a job Immediate Alerts for your website url. If you do not, the timer job was removed. Don't ask my how it was removed, good luck finding that out!
Anyway, run these two easy commands and you'll be back up and running, er, alerting.
stsadm.exe -o setproperty -url http://mysite.mydomain.com/ -pn alerts-enabled -pv true
stsadm.exe -o setproperty -url http: http://mysite.mydomain.com/ -pn job-immediate-alerts -pv "every 5 minutes"
Hope this helps!
8046e4ac-9d18-42c9-b267-2d8631a198cf|0|.0
This is an issue I'm seeing a little too often on SharePoint installs. Trying to access a site that is hosted on the same server will prompt for login credentials 3 times then display Page Cannot be Found.
From what I've gathered it's a loopback check issue. I've seen it come up as a result of installing WSS SP2 a few times as well. I've seen it "randomly" happen on customers' servers all over the place. I say randomly because I'm guessing that customers have installed Windows updates on these servers which may have installed an update which has caused it.
The fix is to disable the loopback check in the registry. I pulled the instructions on how to from MS KB 896861.
Method 2: Disable the loopback check
Follow these steps:
- Click Start, click Run, type regedit, and then click OK.
- In Registry Editor, locate and then click the following registry key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa
- Right-click Lsa, point to New, and then click DWORD Value.
- Type DisableLoopbackCheck, and then press ENTER.
- Right-click DisableLoopbackCheck, and then click Modify.
- In the Value data box, type 1, and then click OK.
- Quit Registry Editor, and then restart your computer.
I hope this helps!
4b7eabe9-5658-4f29-a6da-60bc59d94438|1|5.0
Now this might be common knowledge to some, but it came as a pain in the butt surprise to myself and my team. There are a few gotchas with using CAML in SharePoint, specifically with the SPQuery object. The results of using it incorrectly can cause missing data, which will cause a man to go crazy looking for a solution. I primarily use U2U CAML Query Builder Tool to create my CAML queries and then modify them as I need in the code. I recommend downloading this free tool and use it to generate your CAML queries fast and easily. Field_x0020_Names are different in CAML. If you're not using a CAML builder and are trying to simply type a CAML query by hand for the first time. Stop and download U2U CAML Query Builder. Certain fields are not named the same in CAML. For instance:In a calendar, the Start Time field is actually named EventDate. The End Time is EndDate. Names with spaces, like Assigned To is actually Assigned_x0020_To. Spaces are translated as _x0020_. Some names are completely different. If you take the Title column of a list and change the column name to be Company Name, for example, the CAML label is still Title. Any column name changes are not reflected in CAML. Long field names are trimmed at 32 characters. So column Inspected By Supervisor in CAML is Inspected_x0020_by_x0020_Supervi. Odd I know. If you happened to create two fields with the same first 32 characters, like Inspected By Supervisor Phone, the CAML label is Inspected_x0020_By_x0020_Supervi0. Why doesn't SharePoint just use the full name? I have no idea. Lack an <And> and you won't get it. Fair enough, if you don't put in enough <And> in a CAML query the filter isn't complete. <Where> <And> <Eq> <FieldRef Name='Title' /> <Value Type='Text'>value</Value> </Eq> <Eq> <FieldRef Name='Location' /> <Value Type='Text'>value</Value> </Eq> </And> <Eq> <FieldRef Name='fAllDayEvent' /> <Value Type='AllDayEvent'>1</Value> </Eq> </And> </Where> Above, I'm missing an <And> at the top. As a result, the last piece, AllDayEvent, will not be included in the filter. The frustrating part about this is that it doesn't error! It just simply ignores it and moves on. VERY frustrating when you're working with 8-9 <And> statements and you happen to miss one. Filter by Lookups and Users. Unfortunately, the current release of U2U doesn't handle lookups very well in CAML. There is a way around it however. Normally, U2U will filter a lookup similar to the following. <Eq> <FieldRef Name='Company' /> <Value Type='Lookup'>value</Value> </Eq> If you put the value as a name of the Company that should work. If you're use to relationships in SQL, you probably want to use the ID of the company record instead of the name. A better way to handle it is to use the LookupId option <Eq> <FieldRef Name='Company' LookupId='true' /> <Value Type='Integer'>1</Value> </Eq> When using the LookupId it is important to switch the type to integer. If you keep it on Lookup, it won't error and it won't get you the data you want. That's what I got for now. I hope this helps!
98b6b239-acf0-4fd6-90f4-ef35c611f704|0|.0
I wrote a web service that queries the users in certain groups and I bound a dropdown in my InfoPath form to it. The web service requires two values, the site name and the group name. In using the InfoPath Data Connection wizard I specified the values.
We now are looking to move this form to another server (from dev to staging to prod) and this form is going to become the base for about a dozen other forms, so changing this value manually every time will become a hassel at best.
I figured out how to update the webservice from the code behind, and send it the values I want to send it. Very effective and useful.
IMPORTANT First thing though, you need to stop the web service data connection from getting values on start up. That option is in the last screen of the data connection wizard.
Then, in the Form_Load use the similar code as below and blamo, you're off and running.
WebServiceConnection webservConn = (WebServiceConnection)DataConnections["ListGroupUsers"];
XmlDocument inputDoc = new XmlDocument();
inputDoc.LoadXml("<ListGroupUsers xmlns=\"http://site/\"><SiteURL>" + SPContext.Current.Web.Url + "</SiteURL><GroupName>Site Members</GroupName></ListGroupUsers>");
XPathNavigator inputNav = inputDoc.CreateNavigator();
XmlDocument outputDoc = new XmlDocument();
XPathNavigator outputNav = outputDoc.CreateNavigator();
XmlDocument errorDoc = new XmlDocument();
XPathNavigator errorNav = errorDoc.CreateNavigator();
//Need to specify the XPath to dump the results into, so grab the Web Service repsonse
XPathNavigator root = MainDataSource.CreateNavigator();
XPathNavigator node = root.SelectSingleNode("/dfs:myFields/dfs:dataFields/tns:ListGroupUsersResponse/tns:ListGroupUsersResult", NamespaceManager);
webservConn.Execute(inputNav,node,errorNav);
Hope this helps!
e1e8f6ca-fe13-40be-8ca2-d415d0afd121|0|.0
Microsoft announced March 30 that SharePoint Designer 2007 is now a free download!
http://office.microsoft.com/en-us/sharepointdesigner/HA103607611033.aspx
SharePoint Designer is a great tool for easy customizations of your existing SharePoint sites. You can make simple workflows, cross site data shares and customize the look and feel of the site.
934b34ff-fe22-4f61-8f94-dab70865b83a|0|.0
Every once in a while a WSS installation won't search. When searching in WSS we get the standard nothing was found. In the Application Event Viewer we see the following
Level: Warning Source: Windows SharePoint Services 3 Search Event ID: 2436 Task Category: Gatherer
Event Data: The start address <sts3://dhq/contentdbid={20ef7238-e02f-4938-94cb-791b0581042c}> cannot be crawled.
Context: Application 'Search index file on the search server', Catalog 'Search'
Details:
Access is denied. Check that the Default Content Access Account has access to this content, or add a crawl rule to crawl this content. (0x80041205)
So after a lot of searching and searching online, I came across article http://support.microsoft.com/kb/896861. I have found that the second method fixes it, the first doesn't do much for me.
Enjoy!
9797177e-2fa3-48bc-b52d-cdf51272181b|0|.0
When using the XML web part in SharePoint, I received the error:
The XSL specified by the XSL property or XSL Link property is not valid, or the XSL file cannot be accessed. Make sure you have specified a valid XSL style sheet for this Web Part, or if the XSL file is linked that it can be accessed by the server. For assistance, contact your site administrator. More about making XSL files accessible.
I received this error after using SharePoint Designer to update the default.aspx page by adding a dataview. The obvious is that there is invalid informtion in my XSL, but it was working fine before I made the updates to the page.
After further examination, it appears that the XSL editor has extra spaces at the top of the page. The <?xml version="1.0" encoding="utf-8"?> should be the very first item in the page, first line first column. It wasn't It was on line two and column 20 or so. So I deleted the extra line and spaces and it worked again.
For some reason SharePoint Designer thought it necessary to mess with my already existing and functioning code.
Hope this helps!
5b793cd3-8105-4784-9c5d-ea778b48e36d|0|.0
|
RSS
Login
|