Toying Around with Search and Document Libraries

September 4th, 2007 by mosslover

Right now I have been playing around with search in document libraries and dabbling a bit with custom forms.  Well first off in custom forms I am having trouble with this web service and I had a little trouble with the sql database.  My colleague had to create a new custom form and then create a data connection, because out of 4 forms I could not get it to work.  We still had to hide the old edit form view in the application.  If you look back into my edit form problems you will notice that it would default back to the main Sharepoint Site if you do not keep that main form in there.  Right now my other problems stem from how they want the search to look.  I created that advance search webpart with some custom properties and edited the metadata properties.  It turns out that may not be exactly what they want and my deadline is now bumped to September 26th from sometime in October.  I am going to find out more criteria tomorrow, but I promise I will post more information by the end of the week on what I am going to do.  It may be something far more interesting than using the custom metadata properties and may help me in the long run to learn something new.  I hope that everyone had a good holiday and I will catch you all later. 

Windows Powershell

August 29th, 2007 by mosslover

I was at the KC .Net User Group last night and the topic was all about Automated Testing.  When I first read the topic header on my gmail account I thought this was going to be something I could care less about, because I rarely write code outside of Sharepoint.  The presenter, Dr. James McCaffrey, was very engaging.  He seemed very much like the guy whose class you couldn't wait for an entire week to attend.  This makes sense, because he was a math professor many moons ago.  He threw up a couple math problems for 5th graders as teasers for the audience.  When he started talking about the product he showed us a few examples without boring us to death and sticking to his power point presentation.  I never really knew much about automated testing until now.  When he showed up Powershell I thought that it was so cool how you could simulate button clicks and user inputted data without hard coding it into your application.  I had no idea this product was free either at http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx.  It doesn't integrate well with Sharepoint yet, but if you are building other .Net Applications this could definitely come in handy.  He promised that the next version of Sharepoint will have it's own version of Powershell alongside the installation files.  I look forward to playing with it in the future.

What You Need to Know Before Dealing with Managed Properties

August 23rd, 2007 by mosslover

I spent 2-3 trying to figure out why my managed properties would only index all or some of the files within a document library.  In the property you need to call two instances for each column one that is the exact name of the column and another that starts with "OWS".  If you create your managed properties calling the columns in this manner, then you will not run into the issues that I have.
Also, I found a bug in my client's version of MOSS that does not index anything in the "Last Modified By" and "Created By" managed property instances.  If I find a solution, then I will make a post in a couple of days.
 

Document Library Custom Form Bugs

August 22nd, 2007 by mosslover

I am trying to build a custom edit form in Sharepoint Designer for a document library.  What you are supposed to do to accomplish such a task is copy the current "EditForm.aspx" Page and past it into the directory with a different name.  If you go into this form and convert it to a custom form before you reference it in the document library folder properties, then designer will tell you that the Edit Form can not be changed since the list is not referenced.  After playing around with the form for a bit I realized that this was the work around to at least reference your custom form.  I ran into another far worse problem after I fixed the first bug.  The document library will redirect the user to the main Sharepoint Site after the custom form works for a few minutes.  This particular bug occurs right after you change the form from a normal form to a custom form.  I honestly have no idea how to fix this issue and I can not create a data source field outside of the BDC without using Sharepoint Designer.  Right now I am scouring google for any type of answer.

Status Update and Warning

August 21st, 2007 by mosslover

We scrapped the idea to add user dynamically or even mess with the layout pages based on database access.  I spent good long hours on this issue and no matter what solution we found there was always some degree of unnecessary pain involved.  We are just going to track people based on alerts and the Site Administration Recycle Bin.  I love that option, because if a user attempts to delete an item, then you will still see it in that recycle bin.
The new issue that I am working on deals with Searching a document library for various document types and categories.  I believe that this can be done with the out of he box search capabilities of Sharepoint if I just do a bit of training.  I ran into an interesting issue today while checking the error logs I could not get into the remote server.  My colleague was able to log in, however I could not because the two person limit was exceeded.  I did some checking around and it turned out someone was changing the database directory and turned off all the IIS Websites.  He had some type of snag on the Timer Job Service for WSS.  I can only assume that somehow turning off IIS and not turning off the other Sharepoint Services locked the Timer Job Service.  This is a warning for everyone.  If you are playing with the databases on Sharepoint you may want to try and turn off all the Sharepoint Services and IIS Websites, so that nothing is completely locked in a process.  I remember the old version of Sharepoint had you starting and stopping all kinds of services and IIS entries.  We ended up restarting the entire server and somehow all these e-mails from workflows and task entries were all of a sudden pushed into our inboxes.  Sometime last week another administrator updated the Outlook components for SMTP, which leads me to believe that he may not have restarted the Sharepoint Box to get the server to accept the changes.  I am just glad that overall Sharepoint is working, but I will be monitoring it closely the next few days.

 

Attempting to Add Users Dynamically

August 7th, 2007 by mosslover

Here is the problem: I want to add users to a site when they get an access denied message and I want it to redirect the person.  I have been using this site as my guide: http://blogs.msdn.com/jannemattila/archive/2007/06/25/adding-users-to-sharepoint-dynamically-at-first-request-after-authentication.aspx.  I pasted the code in to test it, however it is not working in the manner that I expect it to work.  I am not even sure if it is working at all.  You see my user is already in the initial AD group for Sharepoint, but I want to add them to a specific site.  I am wondering if anyone has a better suggestion on how to implement this code or another solution.  I have tried modifying the code at least a dozen times without any luck. 

Back From Vacation

August 3rd, 2007 by mosslover

I'm not sure if too many people read this blog, however I figured I would update you guys on my status.  I gave up on creating a Test and Development Environment for now.  There are way too many bugs in the Content Deployment Area of Sharepoint.  I would get inexplicable webpart view changes and could not find hot fixes.  More than often a random error that made no sense would occur one time, then I would run the job again and it would not work.  I have noticed that a fair amount of people are having similar issues without any sort of fixes.  I feel that this part of Sharepoint is a great addition, however I wish they had put more effort into testing it before deploying a solution.  I hope that the first service pack for Sharepoint will fix any bugs in Content Deployment.  The triumph at least out of all these problems is that I was able to deploy publishing on all the team sites by turning on a feature and migrating all the default.aspx files to the pages folder.  The only site that my colleague and I had problems with was a workspace site that kept shooting off a ton of weird errors.  I will warn you guys to stay away from the publishing features on a site if you are using a workspace template.  You may end up with a random "unexpected error occurred" and your site may need to be re-published by the last person who edited the site.  Normally the draft is not available to everyone and the old version still works.

Ok, enough business…Los Angeles was awesome.  Not exactly a place that I would love to live, but very pretty and not as humid as Kansas City.  Disneyland was really great.  I loved going on the Pirates of the Carribean and It's a Small World Rides.  Towards the end of our trip we ended up at the Finding Nemo ride, which was really neat due to the fact that you are in a submarine type area.  We also saw this incredible light show with just about every Disney Character you could imagine.  I would love to visit California again, but next on the agenda is a trip to Miami to see my grandmother and maybe another one to New York to visit some World of Warcraft buddies.  I have a goal to visit more places in the upcoming months, because I feel that I have spent too much time sitting around in the Midwest lately.

Frustrated with Content Deployment Job Import(Revised)

July 18th, 2007 by mosslover

For the past week I have attempted to create a staging server for my client's Sharepoint Site.  The problem is that it will import 9100-9700 objects and then it will fail and issue me these errors:

Content deployment job 'Remote import job for job with sourceID =
378a003b-941d-46dc-979b-e7e276e60c77' failed.The exception thrown was
'System.UnauthorizedAccessException' : 'Access denied.'

 and

Access denied. at
Microsoft.SharePoint.SPGlobal.HandleUnauthorizedAccessException(UnauthorizedAccessException
ex) at Microsoft.SharePoint.Library.SPRequest.PatchUrl(String bstrUrl, String
bstrWebRelFileUrl, String bstrWebRelOldUrl, String bstrWebRelNewUrl, Int32 grf)
at Microsoft.SharePoint.Deployment.ImportObjectManager.FixLinkInFile(String
fileUrl, Guid webId, String oldTargetUrl, String newTargetUrl) at
Microsoft.SharePoint.Deployment.LinkSerializer.SetObjectData(Object obj,
SerializationInfo info, StreamingContext context, ISurrogateSelector selector)
at Microsoft.SharePoint.Deployment.FileSerializer.UpdateLinks(SPFile file,
String linksXml, StreamingContext context, ISurrogateSelector selector) at
Microsoft.SharePoint.Deployment.FileSerializer.UpdateFileAssocData(SPFile file,
SPWeb web, Guid id, String fileUrl, SerializationInfoHelper infoHelper,
SerializationInfoHelper infoHelperListitem, StreamingContext context,
ISurrogateSelector selector, ImportObjectManager objectManager) at
Microsoft.SharePoint.Deployment.FileSerializer.CreateOrUpdateFileAndAssocData(Object
fileOrListItem, SPWeb web, Guid id, String& fileUrl, Boolean fileExistsInDb,
SerializationInfoHelper infoHelper, SerializationInfoHelper infoHelperListitem,
StreamingContext context, ISurrogateSelector selector) at
Microsoft.SharePoint.Deployment.FileSerializer.SetObjectData(Object obj,
SerializationInfo info, StreamingContext context, ISurrogateSelector selector)
at Microsoft.SharePoint.Deployment.XmlFormatter.ParseObject(Type objectType,
Boolean isChildObject) at
Microsoft.SharePoint.Deployment.XmlFormatter.DeserializeObject(Type objectType,
Boolean isChildObject, DeploymentObject envelope) at
Microsoft.SharePoint.Deployment.XmlFormatter.Deserialize(Stream
serializationStream) at
Microsoft.SharePoint.Deployment.ObjectSerializer.Deserialize(Stream
serializationStream) at
Microsoft.SharePoint.Deployment.ImportObjectManager.ProcessObject(XmlReader
xmlReader) at Microsoft.SharePoint.Deployment.SPImport.DeserializeObjects() at
Microsoft.SharePoint.Deployment.SPImport.Run()

 

I have been all over the web and found nothing for this specific issue.  I have tried playing with the features and turning off publishing at the Main Sharepoint Site.  I have tried granting access to the Wamrag and the host file folder for that server.  I have tried so many different things that I don't even remember.  My head is spinning.  I got so frustrated that I tried sending Andrew Connell a message to see if he could shed some light on the issue.  I'm not even sure I will get a response, but he seems to know a lot about content management.  I think I'm at the point where I need to walk away from the problem for a while.  This should be a time when I am starting to wind down and kick back.  I am on vacation next week in Los Angeles and the last Harry Potter book comes out of this weekend.  I even got to level 66 in World of Warcraft and I can now visit the instance I've wanted to see since Burning Crusade came out.  In short life is good why stress out about a little Sharepoint issue.  The answer will come.

 

*UPDATE*

I got it to work by excluding this testing like that has every single template Sharepoint can offer including the Fantastic 40.  I am assuming there is something in there that angered the import job.  I didn't need to copy that directory, so it is not a big deal.  I am hoping that this helps someone else who is receiving the same error.  Just remember it could be an object in a site that deals with the Fantastic 40.  You may need to upload some type of feature or list.

Anyway all is pretty much well aside from this publishing problem.  If I try and activate publishing on existing sites for quick deploy to work it doesn't do anything, even with the feature turned on in both the site collection and site.  I am not sure why it will not work on the team sites or the workspace sites.  I assumed that you activate the feature on the sites and publishing was activated.  I am going to look into changing the default.masters in those sites.  If anyone else has a better idea I am all ears. 
 

Pulling Data From SQL Server for Use in Sharepoint 2007

July 16th, 2007 by mosslover

Here is the much anticipated code sample:

Dim Site As New SPSite("{Enter Your Sharepoint Site}")

            Dim Web As SPWeb = Site.OpenWeb

            'Sql Connection Information
            Dim ClientTable As New DataTable 'Datatable

            'Sql Connection Information
            Dim Connect As New SqlConnection("Initial Catalog ={Enter a Database};Data Source={Enter a Server};User ID={Enter a User ID};password={Enter a Password}")
            Dim GetStoredProcedureData As New SqlCommand 'Gets Stored Procedure
            Dim ClientsDataset As New DataSet 'Dataset Variable
            Dim StoredProcedureAdapter 'Data Adapter for Stored Procedure

            Connect.Open()

            'saves data to dataset then appends to invoice files
            GetStoredProcedureData.Connection = Connect
            GetStoredProcedureData.CommandType = CommandType.Text
            GetStoredProcedureData.CommandText = "{A Select Statement Needs to be Inserted Here}"
            StoredProcedureAdapter = New SqlDataAdapter(GetStoredProcedureData)
            StoredProcedureAdapter.Fill(ClientsDataset)

            Dim i As Integer 'row increment
            Dim RowCount As Integer 'row length
            Dim DocumentLibraryName As String
            Dim NameDescription As String

'gets Sharepoint Site Information, this example only has one table, it starts at 0 for the first tables and goes on
            ClientTable = ClientsDataset.Tables(0)
            RowCount = txtCount.Text
            i = txti.Text
            While i < RowCount
                'My example has two items coming from the database, whereas yours may have more items
                'The
                DocumentLibraryName = ClientTable.Rows(i).Item(0).ToString()
                NameDescription = ClientTable.Rows(i).Item(1).ToString()

                'Create a Document library with a Microsoft Office Word
                'document(template)
                Dim newListGuid As Guid = Web.Lists.Add(NameDescription, NameDescription, Web.ListTemplates("Document Library"), Web.DocTemplates(1))

                'Get the new list using the returned GUID
                Dim list As SPList = Web.Lists(newListGuid)

                'Makes the Quick Launch visible in the Document Library
                list.OnQuickLaunch = True

                'Allows you to use versioning if you want
                list.EnableVersioning = True

                'You Need this statement to commit updates int he document library, otherwise none of the settings will take into effect
                'If you are creating a regular list you will still need this statement
                list.Update()
                i = i + 1
            End While

There may be other ways to pull this data.  Also, you can probably push it into a datagrid, rather than create the document library.  It's really not that hard.  I am sure someone has a code sample for creating a datagrid in VB .Net or use it to create sites.  You can deploy this in a webpart.  You would just put the code into a class library.  It is really simple to translate into C#.  You can pretty much do anything in Sharepoint that you can do in .Net.  The new webpart I am working on rips off a 3 digit code at the end of a url and finds a specific name in the database, then creates a list entry based on the user and what site they visited.  I am really loving playing with the object model.  I would encourage you guys to experiment and let me know some of the ideas you find.

Working with SPList and a List of Links

July 12th, 2007 by mosslover

I am working on this Top 3 Sites Webpart that saves to a list of links.  I never knew that there was a variable called SPFieldURLValue that stores the description and url for the variable in a list.  Here is an example of how it would be used in SPList:

Dim URLVariable as new SPFieldUrlValue

 UrlVariable.Url = "http://yoururl"

UrlVariable.Description = "description for url"

ListItem = List.Items.Add

ListItem("URLField") = UrlVariable

ListItem.Update() 

It's incredibly easy once you know what you are looking for.  I hope this helps one of you guys working with a list of links.  I know it did for me.