Wednesday, March 5, 2008

SharePoint Workflows Config alternative using InfoPath Forms



I recently wrote a workflow that will use the SharePoint Object Model to manipulate sites or just about anything you want. I seperated the functionality of the workflow from the actual sites manipulation into two assemblies. One for the SharePoint Sequential Workflow and one for the SharePoint sites manipulation. Iwanted my manipulatingassembly to incorporate a Config file. Where would I place the config file? the following is an alternative, that was useful in what I wanted to do with my config file.

   If you have ever developed workflows, you know that the assemblies are placed in the GAC. Well, the config files would have to be stored in the GAC as well. My workflow doesn't access the web.config for the site, and alternatives to map a config to a location on the local machine wasn't quite working either. I think it had issues with security. What I decided to do is store a 'Config' file in SharePoint.

   The biggest draw for doing this was to have an accessible file where specific users could actually edit the config file. What better place than a SharePoint Site. I also used InfoPath forms to create a more ascetically pleasing config file that non-technical users can edit.

   Step 1: create an info path form: this is a sample of the field that 
I stored as "Approvers"






this means that the key value pair looks like this:   key: Approvers   and value: "Approvers". (The Text field is actually called 'Approvers')

Not the best example because they are the same in this case but an authorized end user could change the group name of approvers to be the site 'Members' or any other created group name. When the workflow runs it will look at the value entered in this field to get the name of the Approvers group.

Step 2:  using XSD.exe you can create a class to serialize your infopath form. First, in InfoPath under file>>save as source. This will create a file called myschema.xsd.  Then using XSD.exe use the command:    xsd myschema.xsd /c

this will produce a class you simply rename, it looks like the following:( I renamed it 'workflowConfig')

You see that it has a property exposed to you. If you have multiple properties, more will be created for you. I used reflection to then be able to access the properties like you would a config file. 

this method is added to the class that was created for you by the XSD.exe. 

Step 3:  Access the Config file stored in SharePoint.

   this step requires you to access the root site and the Form Library that stores the config file and then deserialize  the form with your generated class.

As you can see, you have to send a rootURL of the site, and access the document Library called, "Configurations" and since there is only one entry in that Forms Library, you can just use the first entry in the library to access our config file.

Step 4: Use the Config File.

This static method was placed in the Manipulating DLL as you can see the Class is called "Create", but it access the local static method called "getConfig" which was posted earlier. Reflection gave us the ability to access the config file like a key value pair. this Method will give you the email of the first user in the "Approvers" group in SharePoint.  If you were to change the approver group, an end user can change the config file or InfoPath form in SharePoint and the code would read a new Group and therefore a different UserEmail. Also if the a different user is added to the group, the new user's email will be read by your code. 


Hopefully this helps, as you consider some alternatives to doing something similar. I know that there are details missing in this post but I will update this post when I have time and go through some of the detail that I missed. Any questions, let me know. 

 Good luck

Juan

Thursday, January 3, 2008

Workflow InfoPath forms stuck on "Installing" issue fix

I receantly worked through a workflow that implented InfoPath forms. InfoPath forms are really handy because of the designer capabilites. You can drag and drop controls and no code is really required. The hosting SharePoint aspx page runs all the code and so you don't have to have the InforPath form doing any of the required code.
I was done with my workflow and I deployed my solution to the target site collection. When I tried to bind the workflow to a document library I would get an error. The error was saying that the infoPath form was not workflow enabled. I also changed my web.config file to spit out a stack trace and this is what I got.

Value cannot be null.
Parameter name: g at System.Guid..ctor(String g)
at Microsoft.Office.Workflow.WrkAssocPage.AssociationOnLoad(EventArgs ea)
at Microsoft.Office.Workflow.CstWrkflIPPage.OnLoad(EventArgs ea)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,Boolean

includeStagesAfterAsyncPoint)


I soon figured out that either something was wrong with my WrkAssocPage.aspx or the hosting aspx pages or there was really no info path form sent to those hosting pages.

So, I checked SharePoing Central Admin to see the status of my InfoPath templates. Go to "SharePoint Central Admin >>Application Management>>" at the bottom of the page you will see Info path form Templates link. Check the status of your IP templates. Mine were stuck on status, "Installing" and they were marked as "NOT" workflow enabled.

If this is happening to you. This is what fixed it for me. Recall the steps you took to save the IP template.
1) you should have set the security setting to "domain".
2) you should have changed the controls ot only be web enabled. (controls that are not web enabled, ie. rich texbox field, will cause this problem)

3) and the MOST IMPORTANT, when you publish your IP you should save it to your Visual Studio project folder of your workflow. After you choose the location the publish wizard will ask you to enter an "access path". DO NOT FILL IT OUT! leave it blank, it will then give you a half error, just click 'OK', and finish with the wizard.

if you fill out an 'access path', well, the IP form will remain in that 'installing' state, and it will not be usable.

IF you have already deployed your solution and you are experiencing this problem there are a couple of things you have to do first.

1) deactivate the feature from the site collection
a) go to your site
b) go to 'Site Actions'
c) go to the 'Administration section' under 'Site Collection Features
d) find the feature(ie, your workflow feature) and deactivate it.
2) unistall the feature using stsadm.exe
a) stsadm.exe -o unistallfeature -filename


3)Delete the IP templates you published to the project folder
I just tired to republish the templates and it would not allow me to. Because it did not
ovewrite the old ones.
4) Publish the templates again to the project folder.


hope this saves you a lot of grief. The one thing I can suggest is to change the web config file of your site collection to spit out the stacktrace for better error reporting. I found a how to here:

http://www.sharepointblogs.com/michael/archive/2007/06/28/sharepoint-under-the-hood-see-real-error-description-and-callstack-stack-trace.aspx



Good luck

Juan

Thursday, December 6, 2007

MOSS Publishing Infrastructure feature causing Link Issues

It turns out that MOSS publishing Infrastructure feature can cause link issues. Innitially I deactivated it to add sub sites and have them show up as tabs to the main site. It turns out that deactivating it and activating again can cause major issues with the Quick Launch navigation links of SharePoint sites. 

  Most headers in the Quick Lauch had a repeating parameter. It was the right parameter but it was just repeating over and over. When I tried to change it manually by going though "Site Actions>>Site Settings>>Navigation" I had a SharePoint Error and my changes in the Navigation did not persist. I was unable to change the Navigation, I had broken links everywhere.

  I could not find a solution for this, I basically had to start from scratch again. 

this is what I ended up doing:

        My Solution:
   
1) Deactivate the MOSS Publishing Infrastructure Feature - notice how the subsites of subsites will appear as tabs for the main site.

2) Erase all the troublesome Links from the Quick Launch navigation section (Site Actions>>Site Settings>>Quick Launch)

3) Activate the Publishing Infrastructure Feature - sites and sub sites will revert back to the desired navigation.

4) add the links and the headings manually (Site Actions>>Site Settings>>Navigation)



Not fun!

Juan

Monday, November 5, 2007

Leopard Problems, Leopard makes Vista look great!

ok, I recently bought a Macbook '15 Pro. I should really have 4Gigs of Ram for virtualization but only have 2Gigs right now. It would cost me an arm and a leg to get it through the mac store. Plus spending $3500 for a machine, well...it hurt. I recently upgraded the OSX, from Tiger to the new Leopard.
  Firstly let me say that I really didn't notice that much of a difference in the new features. The only ones that are really handy right now are the Quick Preview, Cover flow and Spaces. The reason they are really handy is because I can preview a document, and most of the time they are Windows Documents, like word or excel files and it's nice to peak at the contents without really open the application. It's great! sometimes that's all I need, preview the document. Spaces is great in that I can have a Parallel Machine running on another space and I can switch back and forth as I need to. Coherence View in parallel doesn't really interest me as much as there are little bugs here and there that are annoying but not serious. 
 
  After all the hype let me tell you, I am extremely disappointed! Let's talk about the 200 or so features. I haven't even noticed these so called features. They don't seem to add to my experience, I haven't really noticed them. Let me tell you what I have noticed, IChat is supposed to be this great new feature. It's supposed to have great video chat capabilities. Well, I still haven't gotten it to work with another mac. It always tells me that there is a communication error from the other computer. The problem is that both ends of the conversation tell you that it's the others fault! I checked for firewalls and nothing seems to be an issue, just that IChat does not connect. Talking with other mac users, they say the same thing, it's hit and miss with IChat. I though this was a home grow application I could bank on. 

  Adium which is way better than MSN messenger is freezing up on me, at random times. I wrote a blog post about the issue.

   this is funny. Half way through writing this post right now, my Safari browser crashed and had to relaunch. No word of a lie! Thank goodness this blog site auto saves drafts. 

So there is a temporary fix for Adium and I am willing to understand that this is not Apple's fault or Leopard's fault and it's more Adium. But I did expect more.
   Earlier today a bunch of my applications were not running, I got error: 10810 which, after some googling, I found out it has something to do with too many applications running at once. I had 2 applications running, which means, at some point none of the processes underneath were terminated properly. What the HELL!! this is the great new Leopard OSX???
 
  The newest issue and it's why I was prompted to write this blog was my problem with Parallels. Parallel's for those of you who don't know runs windows operating systems virtually. It is Mac's version of Virtual PC's. It used to run great with minimal hiccups, but now it wont run. I get an error that says, that there is not enough memory for my Parallel to run. I thought it was odd. I had been using Parallels all day, for work. So I lowered the memory settings on the parallel machine and I got the equivalent of Vista's "BLUE SCREEN OF DEATH" which is called "GREY SCREEN OF DEATH". I'll give mac credit, it did look pretty cool, like my computer was dying! 
      This Operating system upgrade is making Vista look Great! I really feel like throwing my Mac against the wall! I really do. Maybe my next blog entry will be through  my piece of crap windows machine. Will someone create a superior product please! I though I had already bought it, I guess I was wrong.

 I guess now I'm just venting.

   any thoughts??

  Juan 

   

Sunday, November 4, 2007

Use Quicksilver to access Hidden files (Adium temporary fix)

I recently upgraded from Mac OSX Tiger to Leopard. I was having trouble with Adium not being able to sign into MSN accounts. It turns out that Adium has a bug and can not resolve the hotmail DNS very well, it's a hit and miss.
After checking out some blogs the quick-fix was to add the IP and hotmail domain name to the Host file. I had made modifications to the host file on Tiger with NetInfo Manager but Leopard did away with NetInfo Manager and there does not appear to be an application that easily modifies the host file. For those of you that have tried to access hidden files through Finder know that it is not a simple task to access hidden files. 

USING FINDER:

To access hidden files with Finder: (you have to set a AppleShowAllFiles switch to True)

 1) open a Terminal Window. Located in Applications/Utilities/Terminal

 2) Type , 'defaults write com.apple.finder AppleShowAllFiles -bool true' without the quotes.

 3) Hit enter and in order to see the changes take effect, log out or restart your computer and relaunch Finder. 

       Now you can access the host file by the path , Macintosh HD/Private/etc/hosts.  Make sure that you have access to write to it (right click on the file and select Get Info to adjust access)

  You might be asking, why don't you just use command prompt or Terminal to change the host file?  You can do that too, but I wanted to add and remove to the Host file manually.

USING TERMINAL:

    To use the terminal to change host file do:

 1) access the Terminal (Applications/Utilities/Terminal)

 2) Type: sudo su

 3) Hit Enter,  then enter your password

 4) then type: 
      cp /etc/hosts /etc/hosts.bak
      echo 65.54.239.20 messenger.hotmail.com >> /etc/hosts
      echo 6554.179.216 nexus.passport.com >> /etc/hosts
      echo 65.54.183.203 login.live.com >> /etc/hosts
      exit



This is the TEMPORARY Adium fix. You can actually enter those IP's and DNS to fix the login issues with hotmail accounts. 

   To revert back after Adium fixes the the issue. Use the Terminal command prompt to change things back again.

   1) Access the Terminal.

   2) type: sudo su

   3) hit Enter, and enter your password

  4) cp /etc/hosts.bak /etc/hosts
  
  5) exit

  This will change back your settings.

The Reason I didn't want to use the Terminal to add and delete to Host file was that I wasn't sure what was going to be deleted I reverted back, or changed the host file to it's original state.

 This long drawn out Blog entry is to show that you can access hidden files with QuickSilver, this is how.

USING QUICKSILVER:

   1) Access QuickSilver. Start entering Mac and one of the top options is Macintosh HD

   2) Select Macintosh HD but before opening it up with the action 'Open', enter "Alt - /" . This will give you access to all the hidden files in that Folder. 

    3) now you can use QuickSilver to access the host file, Macintosh HD/Private/etc/hosts

   By entering "?" you can move up a level if you get to the hosts file but want to access 'etc' folder to change the 'read/write' security settings of the host file.

These are different ways to do the same, I suggest using QuickSilver to access the hidden file, 'private/etc/hosts' to access the host file and making the modifications you need manually.


Best Regards,

  Juan