Hi Richard, That is the default string value for lookups. I hit a similar issue with People and Name fields.
I can't see where you're getting the value for finalFolder and checking if it already exists. Perhaps you should be getting and checking this first as a separate process before performing your file submission? On 5 March 2013 14:46, Richard Angus <[email protected]> wrote: > Content Organizer Question**** > > ==========================**** > > I have an interesting scenario that I am unable to find an answer to > (either due to my requirements being unrealistic for SharePoint, or my > Google Fu is bad).**** > > ** ** > > The Scenario**** > > ==============**** > > I have a number of lists (e.g. Functions, Departments, Areas, DocTypes), > that I want to be able to cascade using SPServices. This part is easy. I > have this now.**** > > ** ** > > These lists are referenced by a number of corresponding Site Columns.**** > > These Site Columns are contained as required fields in a Site Content Type > which has a Document Content Type as its parent**** > > I have added the Content Organizer to the site, added the content type to > both the Drop Of Library and the final destination library**** > > I have created a Content Organizer Rule that will route documents of the > content type to the target document library, an create a folder if one does > not exist based on the value of one of the **** > > site columns that get their data from a lookup field.**** > > ** ** > > The problem I seem to be having with this, is that it create a folder like > the following in the target document library:**** > > 3; Department Name 1**** > > ** ** > > What I was expecting/hoping it would do is create a folder like this:**** > > Department Name 1**** > > ** ** > > Things I have already tried**** > > ============================**** > > **· ** I have followed a path of creating a Custom Document > Router and registering this (Code below signature). However, there are > issues with this, particularly when you attempt to upload an updated > document (I am using the finalFolder.MoveTo to rename the folder to remove > the “3;”. However, if there is already a file with that name in the target > folder, the MoveTo errors.**** > > **· **Tried to use Managed Metadata fields. However, this removes > the ability to have cascading drop downs in entry fields.**** > > ** ** > > My Questions**** > > ================**** > > **· **Has anyone else come across this situation?**** > > **· **Am I on the right track with the custom document router? To > me it seems as if the custom document router is called *after* the target > has already been set (and even appears to be created by the time the Custom > Router is called)**** > > **· **Am I missing something here? I am unable to find any *real* > examples of how to use this in the way I am trying to.**** > > ** ** > > Any help/insights are much appreciated.**** > > ** ** > > Regards**** > > ** ** > > ** ** > > *Richard Angus – Software Engineer* > > *Dev IQ Pty Ltd* **** > > *Email*: [email protected] **** > > *Mob*: +61 412 660 774 **** > > *Fax*: +61 7 3103 4510**** > > *Twitter*: @RichardAngus **** > > *Web*: www.deviq.com.au **** > > *Blog*: blog.richardangus.com**** > > [image: Description: Description: MCTS(rgb)_1390]**** > > ** ** > > ** ** > > ** ** > > using System;**** > > using System.Collections;**** > > using System.IO;**** > > using Microsoft.SharePoint;**** > > using EcmDocumentRoutingWeb = > Microsoft.Office.RecordsManagement.RecordsRepository.EcmDocumentRoutingWeb; > **** > > using EcmDocumentRouter = > Microsoft.Office.RecordsManagement.RecordsRepository.EcmDocumentRouter;*** > * > > using ICustomRouter = > Microsoft.Office.RecordsManagement.RecordsRepository.ICustomRouter;**** > > using CustomRouterResult = > Microsoft.Office.RecordsManagement.RecordsRepository.CustomRouterResult;** > ** > > using System.Linq;**** > > ** ** > > ** ** > > namespace Deviq.SharePoint.Ecm**** > > {**** > > public class DeviqDocRouter: ICustomRouter**** > > {**** > > CustomRouterResult > ICustomRouter.OnSubmitFile(EcmDocumentRoutingWeb contentOrganizerWeb, > string recordSeries, string userName, Stream fileContent, > RecordsRepositoryProperty[] properties, SPFolder finalFolder, ref string > resultDetails)**** > > {**** > > if (contentOrganizerWeb == null)**** > > throw new > ArgumentNullException("contentOrganizerWeb");**** > > **** > > // We should have a Content Organizer enabled web **** > > if (!contentOrganizerWeb.IsRoutingEnabled)**** > > throw new ArgumentException("Invalid content > organizer.");**** > > ** ** > > string fileName = (from prp in properties where > prp.DisplayName == "Name" select prp.Value).FirstOrDefault();**** > > ** ** > > **** > > using (SPSite site = new > SPSite(contentOrganizerWeb.DropOffZoneUrl))**** > > {**** > > SPWeb web = site.OpenWeb();**** > > try**** > > {**** > > // User creating the file**** > > SPUser submittingUser = > web.SiteUsers[userName];**** > > // Create a Hashtable of properties which > forms the metadata for the file**** > > Hashtable fileProperties = > EcmDocumentRouter.GetHashtableForRecordsRepositoryProperties(properties, > recordSeries);**** > > // Save the file here since we need to > modify the file.**** > > if (finalFolder.Name.Contains(";"))**** > > {**** > > //Work out the new URL**** > > string newUrl = string.Empty;**** > > ** ** > > int found = > finalFolder.ServerRelativeUrl.IndexOf(';');**** > > string left = > finalFolder.ServerRelativeUrl.Substring(0, found - 1);**** > > string right = > finalFolder.ServerRelativeUrl.Substring(found + 1);**** > > ** ** > > found = left.LastIndexOf('/');**** > > newUrl = left.Substring(0, found + 1) > + right.Trim();**** > > finalFolder.MoveTo(newUrl);**** > > }**** > > SPFile result = > EcmDocumentRouter.SaveFileToFinalLocation(contentOrganizerWeb,**** > > finalFolder,**** > > fileContent,**** > > fileName,**** > > "",**** > > fileProperties,**** > > submittingUser,**** > > true /*override versioning settings on > the content organizer and create a new file*/, "");**** > > resultDetails = "File has been routed to the > following URL : " + result.ServerRelativeUrl;**** > > return > CustomRouterResult.SuccessContinueProcessing;**** > > }**** > > finally**** > > {**** > > web.Dispose();**** > > }**** > > }**** > > }**** > > ** ** > > }**** > > }**** > > ** ** > > _______________________________________________ > ozmoss mailing list > [email protected] > http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss > > -- Regards, Paul Noone SharePoint Farm Admin/Developer Infrastructure Team CEO Sydney p: (02) 9568 8461 f: (02) 9568 8483 e: [email protected] w: http://www.ceosyd.catholic.edu.au/
<<image001.jpg>>
_______________________________________________ ozmoss mailing list [email protected] http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss
