June: SharePoint ipsum

Simplex Explanation: “Praedae pretium non est in parte.”

UPDATE: An anonymous poster left a great comment about internal names. Be sure to read it.

Cum operantes cum eventus receptatores et Codicis references SharePoint album items per obiectum exemplar, Saepe erroribus quod generare hoc error ad runtime:

Error oneratisque et currit eventus susceptor Conchango.xyzzyEventReceiver in xyzzy, Version = 1.0.0.0, Culturae = neutra, PublicKeyToken = 0dc50a750396c3ac. Additional information is below. : Value does not fall within the expected range.

I think this is a fairly generic error that is potentially caused many different ways. Autem, one simple explanation is that I’m referencing a field incorrectly. If the name of the field is "Due Date", Ego oportet respicere quasi hoc in eventus accipientis:

properties.ListItem["Due Date"]

Cum misspell vel uti iniuriam causa cum indiciunt agro, SharePoint generates the above mentioned runtime error. Verbigratia, hoc est iniuriam:

properties.ListItem["Debitum Date"]

</finem>

Scribet ad mea blog.

Technorati Tags:

Velox & Facile: Partum a folder assignare adipiscing elit (Aut, Et Manduca habeant Your KPIs eos nimis)

In order to work around a KPI problem I wrote about here, I did some testing and discovered that KPI’s work against folders with meta data in the same way that they work against documents or list items. I proved it out by creating a new content type based on the folder content type and then added a few fields. I created some indicators and proved to myself that KPIs work as expected. This was welcome news. It’s not perfect, because the drill-down you get from the KPI against the folders is not exactly what you want. This isn’t too much a drawback in my case because 1) the end users don’t know any better and 2) the drill-down goes to a folder. They click the folder name and they are at the item. It’s two clicks instead of one, which isn’t the end of the world.

This flowed nicely with the work I was doing. I am creating a folder for every document that gets uploaded. This is done via an event receiver. Ut ex, it’s a piece of cake to keep the parent folder’s meta data in sync with the KPI-driven meta data from the file itself since the plumbing is already in place. Hoc mihi concedit KPI meum in ea, et comedent et 🙂

I modified the event receiver to add the folder and then set this new folder’s content type to my custom KPI-friendly content type. This bit of code did the trick:

 SPFolderCollection srcFolders = targetWeb.GetFolder("Documents").SubFolders;
  SPFolder addedFolder = srcFolders.Add(properties.ListItem.ID.ToString());
  SPContentTypeId kpiCT = novum SPContentTypeId("0x0120002A666CAA9176DC4AA8CBAA9DC6B4039F");
  addedFolder.Item["Content Type ID"] = kpiCT;
  addedFolder.Item.Update();

To locate the actual Content Type ID, I accessed that content type via site settings and copy/pasted it from the URL as shown:

imaginem

</finem>

Scribet ad mea blog!

Technorati Tags: ,

Vivos et Securus: Adepto de SPFolder SPListItem in eventum Receptor

Odi illud admittere,, but I struggled with this one all day. My event receiver needs to update a field of its parent folder. This little bit shows how to do it:

privatis Irrita UpdateParentFolder(SPItemEventProperties Proprietates)
{

SPFolder thisItemFolder = properties.ListItem.File.ParentFolder;
thisItemFolder.Item["ZZ Approval Status"] = "Good news, omnes!";
thisItemFolder.Item.Update();


} // UpdateParentFolder

In hoc, Ego sum operantes cum a tabellae bibliothecam proprietates veniunt ab eventu ItemAdded.

Dolum est, ut non directe item Lorem ipsum SPFolder (i.e. properties.ListItem.Folder nulla sit). Pro, item in album scriptor ire et adepto coniuncta File lima folder est scriptor.

</finem>

Scribet ad mea blog!

Technorati Tags:

Aliud Vicis Receptor debug Dolum

I’m sure I’m not the first person to come up with this. Autem, I haven’t noticed anyone publish a trick like this since I started paying close attention to the community last July. Ita, Ego stipes hoc mallem de facili debug apicem.

I’m working on an event receiver that started to generate this error in the 12 alveare:

Error oneratisque et currit eventus susceptor Conchango.xyzzyEventReceiver in xyzzy, Version = 1.0.0.0, Culturae = neutra, PublicKeyToken=blahbalhbalh. Additional information is below. : Non objectum secundum posuit ad instantiam objectum.

I didn’t know where I had introduced this bug because I had done too many things in one of my code/deploy/test cycles.

I tried this solution to get my pdb in there with hopes that SharePoint’s 12 hive would show the stack trace, sed non fortuna. I don’t know if it’s possible and if someone does, placet me cognoscere 🙂

I know it’s possible to write your own log messages to the 12 alveare. Frankly, I wanted something a little less scary and quicker to implement.

It occurred to me that I could at least get some basic trace information by catching and re-throwing generic exceptions like this:

  experiri {
    UpdateEditionDate(Proprietates);
  }
  capiendos (Exceptio e)
  {
    mittent novum Exceptio("Dispatcher, UpdateEditionDate(): Exceptio: [" + e.ToString() + "].");
  }

This showed up in the 12 hive thusly:

Error oneratisque et currit eventus susceptor Conchango.xyzzyEventReceiver in xyzzy, Version = 1.0.0.0, Culturae = neutra, PublicKeyToken=blahblahblah. Additional information is below. : Dispatcher, UpdateEditionDate(): Exceptio: [System.NullReferenceException: Non objectum secundum posuit ad instantiam objectum. at Conchango.xyzzyManagementEventReceiver.UpdateEditionDate(SPItemEventProperties proprietatum) at Conchango.xyzzyManagementEventReceiver.Dispatcher(SPItemEventProperties proprietatum, String eventDescription)].

That gave me all the detail I needed to track down that particular problem and I expect to use it a lot going forward.

</finem>

Scribet ad mea blog!

Solutio: Non SPQuery Scrutamini folders

This past week I was implementing an "evolving" solution for a client that uses BDC and SPQuery and ran into some difficulty using SPQuery against a document library containing folders. Imo linea: assign "recursive" Ad secundum proprium quaestionis.

Missionem meam:

  • Die Lune, Ego upload a tabellae et conpleamus aliqua notitia meta.
  • Sequenti septimana, I upload a new document. Much of this new document’s meta data is based on the document I uploaded on Monday (which we call the "master document").
  • Diximus creavit textus muneris ut suggero a latitudo autem ante faciem BDC-familiaris interface ut album ut users ut facile locus Lune per tabellae quaestionis titulus.
  • A BDC data column provides a friendly user interface. (Hæc est pars agminis conatu ad usura BDC pro amiciores Lookup).

Latitudo autem ante faciem ultima BDC cultum adhibet query hoc facere lookup:

 // U2U tool usus ad assistunt in generatione hac quaestione CAML.
      oQuery.Query =
        "<Ubi>";

      si (titleFilter.Length > 0)
        oQuery.Query   =
          "  <Et>";

      oQuery.Query   =
        "    <Et>" +
        "      <Geq>" +
        "        <FieldRef Name=\"DocumentId\" />" +
        "        <Value Type=\"Text\">" + MinID + "</Valor>" +
        "      </Geq>" +
        "      <Leq>" +
        "        <FieldRef Name=\"DocumentId\" />" +
        "        <Value Type=\"Text\">" + maxId + "</Valor>" +
        "      </Leq>" +
        "    </Et>";

      si (titleFilter.Length > 0)
        oQuery.Query   =
          "    <Continet>" +
          "      <FieldRef Name=\"Title\" />" +
          "      <Value Type=\"Text\">" + titleFilter + "</Valor>" +
          "    </Continet>" +
          "  </Et>";
      oQuery.Query   =
        "</Ubi>";

In initialis stadio progressionem, this worked great. Autem, nos in introductus folders album solvere quaestiones et subito quidam, my BDC picker wouldn’t return any results. I tracked this down to the fact that the SPQuery would never return any results. We used folders primarily to allow multiple files with the same name to be uploaded but with different meta data. When the file is uploaded, partum a folder item ex album, et tunc permoveo lima ibi ID scriptor (Ego scripsit quod hic; weve 'had mixta results sed cum omnis aditus, illud bene operetur). The user don’t care about folders and in fact, don’t really understand that there are any folders. We have configured all the views on the library to show items without regard to folders.

I hit this problem twice as the technical implementation evolved and solved it differently each time. The first time, I wasn’t using the CONTAINS operator in the query. Without a CONTAINS operator, I was able to solve the problem by specifying the view on the SPQuery’s contructor. Instead of using the default constructor:

SPList oList = web.Lists["Documents"];

SPQuery oQuery = novum SPQuery();

Ego potius uteretur sententia machinator quod specificatur:

SPList oList = web.Lists["Documents"];

SPQuery oQuery = novum SPQuery(oList.Views["All Documents"]);

Ut problema solvendum et coepi praecessi adepto meus.

I then added the CONTAINS operator into the mix and it broke again. It turns out that the CONTAINS operator, ut mihi indicet, Sic uti non sit simplicior quam GEQ / LEQ operators. I did some searching and learned that the query’s ViewAttributes should be set to "Recursive", ut in:

oQuery.ViewAttributes = "Scope=\"Recursive\"";

That solved the problem for CONTAINS. In facto, hoc problema solvitur etiam pristinae quaerere et si fecissem peregit recursive primum attributum,, Nec vero causae occurrunt.

Quod visus operetur in aliqua dicentur SPQuery operators (GEQ/LEQ) et non alios, (Continet), copulata hoc, quod non videtur ad operari cum KPIs folder-document continens bibliothecis ducit me ad credendum quod aliqua SPQuery orthogonality exitibus.

Praecipua gratias,:

  • At bonum folks U2U et machinatio eorum query.
  • Magna est scriptor Michael Hoffer "discendi facere," blog nuntius, comments et responsa.

</finem>

Scribet ad mea blog!

MUSCUS KPI bug? Indicis album Ligatum ad Document Bibliotheca Cum folders

UPDATE 02/29/08: I solved this problem by creating a folder and then assigning a content type to the folder which has the meta data I need for the KPIs. I described that in a little more detail here.

We have implemented a technical solution where users upload documents to a document library. An event receiver creates a directory and moves the file to that directory (using a technique similar to what I wrote about hic). We’ve successfully navigated around the potential issues caused by event receivers that rename uploaded files (mainly because users never start their document by clicking on "New" but instead create the docs locally and then upload them).

The meta data for these documents includes a Yes/No site column called "Urgent" and another site column called "Status". We need to meet a business requirement that shows the percentage of "Urgent" documents whose status is "Pending".

This is usually simple to do and I described something very much like this at the SharePoint Beagle with lots of screen shots if you’re interested.

In a nutshell, Fecit sequenti:

  • Create a view on the doc library called "Pending".
  • Configure the view to ignore folder structure.
  • Create a KPI List.
  • Create an indicator in the list that points to the doc lib and that "Pending" considerabit.

This simply does not work. The KPI shows my target (e.g. five urgent documents) but always shows the actual number of urgent documents as zero. Paradoxically, if you drill down to the details, it shows the five urgent documents in the list. I created a very simple scenario with two documents, one in a folder and one not. Here is the screen shot:

imaginem

The above screen shot clearly shows there are two documents in the view but the "value" is one. The "CamlSchema" with blank document Id is in the root folder and the other is in a folder named "84".

It appears to me that even though you specify a view, the KPI doesn’t honor the "show all items without folders" setting and instead, confines itself to the root folder.

If I’m wrong, please drop me a line or leave a comment.

</finem>

Scribet ad mea blog!

Technorati Tags:

Forsit quod Solutio: “FileNotFoundException” Cum Feature Receptor.

I was working on a feature last week that would add some event receivers to a specific list instance. (Blogged sum a frenum album, ut hic Receptorem).

Usura order versus, Possem install pluma cum nihil erroris (Pellentesque sed qui absconditus est errare). When I tried to deploy the feature on the site, MOSS complained of a "FileNotFoundException" error. This blog entry describes how I solved it.

Quod est error ostendit mihi in textus pasco quod MUSCUS:

Feature ‘b2cb42e3-4f0a-4380-aaba-1ef9cd526f20’ could not be installed because the loading of event receiver assembly "xyzzyFeatureReceiver_0" defecit: System.IO.FileNotFoundException: Could not load file or assembly ‘xyzzyFeatureReceiver_0’ aut unum viculis. Ratio non reperio lima nuncupati.
File name: ‘xyzzyFeatureReceiver_0’
at System.Reflection.Assembly.nLoad(AssemblyName filename, String codeBase, Testimonium assemblySecurity, Coetus locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Testimonium assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(String assemblyString, Testimonium assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)
at Microsoft.SharePoint.Administration.SPFeatureDefinition.get_ReceiverObject()
WRN: Vincientes logging est verto off contione.
Ut ligemus cœtus defectum logging, statuet pretium registry [HKLM Software Microsoft Fusion!EnableLog] (DWORD) ad 1.
Note: Aliqua poena est effectus coniungitur cum contione ligáveris defectum logging.
Convertere off pluma, tollere valorem registry [HKLM Software Microsoft Fusion!EnableLog].

Troubleshoot proventus SharePoint Fenestra Muneris.

Scio quia de industria causam erroris: don’t install the assembly in the GAC. Sed, it was in the GAC. I normally install assemblies into the GAC by dragging them into the c:\windows\assembly folder using windows explorer. I’ve never felt 100% faciens quod consolatoria quia ego semper existimavi fuisse ex causa quia gacutil … so I tried that. It made no difference.

Rimarer Internets invenit locum istum: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2243677&SiteID=1

Poster contigit eadem usus radicis frenum of code (a intus ex WSS libro hoc album) so that was a hopeful sign. Autem, suggerentibus tegerent cum contione [conventu: ] directive didn’t make sense to me. I tried it anyway and I was right. It made no difference.

Then I noticed that my class definition was not public. I made it public and that made no difference.

Postero, I went to the trouble of enabling the "assembly bind failure log" (iuuabit sequi et mandata accurate provisis) and this is where things started to get interesting. That log shows me that the runtime is searching everywhere on that server for my assembly. It even appears to be searching for it in my medicine cabinet. Sed … non inveniri in GAC.

I put on my winter jacket and go searching the Internets again and find that someone has had this problem too. The lengthy discussion in that posting peters off into nothing and I can’t find a solution.

I move my assembly into one of the places the log claims it’s searching and I make a little more progress. I’m rewarded with a new error in the browser when I try to activate the feature:

Failed to create feature receiver object from assembly "xyzzyFeatureReceiver_0", type "Conchango.xyzzyFeatureReceiver" quia pluma-b2cb42e3 4f0a-(IV)CCCLXXX-aaba-1ef9cd526f20: System.ArgumentNullException: Valorem non potest esse nulla.
Nomen modularis: typus
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at Microsoft.SharePoint.Administration.SPFeatureDefinition.get_ReceiverObject()

Troubleshoot proventus SharePoint Fenestra Muneris.

Uno tempore enim ultimi itineris usque ad Internets!

Hoc tempore invéniam, Satis praevisam, that MOSS issues this error because the assembly is not in GAC.

Lorem ipsum dolor sit conantur positionem et ex hoc quod ego creavi superbos Fugacissimo MSIL cœtus, but it’s not working. I’m just plain annoyed. I find myself muttering "chicken or the egg" sub lingua mea.

I finally decide to punt. I create an entirely new project and copy/paste the code from the incredible-cloaked-from-the-GAC-assembly non-working project over to this new project. (I look for a build flag called something like "hide from assembly binding if installed in the GAC" sed non potest invenire).

Ego install ipsum et eu eam et … Operatur! Ita, post omnes,, I had to basically ‘reboot’ my project. Hae altera causa est cur oderim computers.

I did learn something useful from this. I had been installing features using the stsadm command line all day long and been using the "-force" option out of habit. Propter aliquam causam,, I did not use the -force option when I installed the new project. Hoc tempore, Ego actu, truly forget to copy this new project’s assembly into the GAC. Ut ex, I received that "FielNotFoundException" error. Hoc tempore, Possedi a stsadm, not when I tried to activate the feature via the web browser. Ita, -force actually plays two roles. It allows you to re-install an existing feature. It also allows you to install a buggy feature that cannot work at runtime by suppressing the error. It probably says as much in the help somewhere but I never noticed it.

</finem>

Technorati Tags: ,

Velox & Facile: TRANSNOMINO Uploaded File Usura SharePoint Objectiva Pe Via res Receptor

UPDATE: This works but there are significant limitations which are described in the comments. This may still be useful in some cirumstances.

UPDATE 2: In current project, users always upload documents. Ut ex, I don’t run into a problem where MS Word is running and thinks that the file was renamed on it. I did run into a problem, "the file was modified by someone else" and solved this via a simple semaphore type flag. Users need to change a meta data field from its default value to something else. The itemupdated() accipientem spectat ad validam valorem ante TRANSNOMINO in actu perfecto, et tunc cum, I have not had any problems. Your mileage may vary.

I have a client requirement to change the name of files uploaded to a specific document library to conform with a particular naming convention. The API does not provide a "rename()" methodo. Pro, Utimur "MoveTo(…)". Here is a minimal bit of code to accomplish this:

 publica dominari Irrita ItemAdded(SPItemEventProperties Proprietates)
        {
            SPFile F = properties.ListItem.File;

            f.MoveTo(properties.ListItem.ParentList.RootFolder.Url + "/xyzzy.doc");
            f.Update();

        }

The only tricky bit is the "properties.ListItem.ParentList.RootFolder.Url". The MoveTo() method requires a URL. That mashed up string points me to the root folder of my current document library. This allows me to avoid any hard coding in my event receiver.

Latin utilior est idem facit, but assigns the name of the file to "Title":

 publica dominari Irrita ItemAdded(SPItemEventProperties Proprietates)
        {
            DisableEventFiring();

            // Titulus autem huius assignant item nomen file ipsum.
 // MONUMENTUM: Hac assignatione fieri oportet ante se temperare file.
 // Vocans update() in SPFile videtur infirmatione proprietatum
 // quaedam.  Updates to "Title" donec deficerent mutabilibus (et update() voca)
 // Nomen fasciculi ad commutationem pro motis.
            properties.ListItem["Title"] = Properties.ListItem.File.Name;

            properties.ListItem.Update();

            SPFile F = properties.ListItem.File;

            // Impetro file extensionem.  Nos postulo ut postea.
 filum spfileExt = novum File Info(f.Name).Extensio;

            // TRANSNOMINO lima ut album Item ID scriptor utor lima tractus custodire
 // intactam illam partem.
            f.MoveTo(properties.ListItem.ParentList.RootFolder.Url +
                "/" + properties.ListItem["ID"] + spfileExt);

            // Committere movéntur.
            f.Update();

            EnableEventFiring();
        }

Vivos Tip: Quaero Web content Parte, Column p valorem et Lookup

I have a column name in a content type named "Real Estate Location".

That column is of type "lookup".

Ego mutatio: <CommonViewFields> et ostenderent agmen ItemStyle.xsl.

Simplex <p:value-lego a =…> retro redit, ut valor includit intrinsecam Ordinale data positione, quales:

1;#Miami

Ut humana valorem-amica, uti post-p substring, ut ostensum:

<p:value-of select="substring-after(@Real_x005F_x0020_Estate_x005F_x0020_Location,’#’)"></p:valor ex->

Uti hoc ars, quotiens operamur cum lookup valores in p commutat atque opus ad adepto valorem in humana-amica.

<Finis />

Technorati Tags: , ,

Vivos et Securus: Determine Internal Column Name of a Site Column

UPDATE: Jeremy Thake has blogged about this and put up some code for a console application that shows internal names.

I was trying to get a content query web part to display a due date from a task and because the screen label is "Due Date", I assumed that the column name to use in <CommonViewFields> is "Due_x0020_Date".

Iniuriam!

The real column name in this case was "DueDate".

How did I find it? I re-read Heather Solomon’s blog entry on modifying CQWP to show additional columns of data. She describes this process at step #13. Trust it. It’s correct. At least, it was correct for me. I did not trust it at first for another column with a much longer name.

I say "Trust it" because I did not trust it and probably wasted near two hours butting my head up against a wall. After I resolved the "DueDate" nomen, I wanted to add another field to <CommonViewFields>. Using the Solomon technique, I was getting a column name like "XYZ_x0020_Project_x0020_Due_x00".

I thought to myself, that’s clearly a truncated name. I went ahead and un-truncated it with no success. I finally used the seemingly truncated name and it worked.

Bonus tip: When I was working with the CQWP, if I added a bad internal name to <CommonViewFields>, the CQWP would tell me that the query had returned no results. Sed, if I added a data type to the field name, it would return a result. Adding the data type actually masked a problem since I was referencing a non-existent field. I could add it, but when I tried to display its value, I would always get a blank.

This did not mask the error:

<CommonViewFields>Due_x0020_Date;</CommonViewfields>

This did mask the error:

<CommonViewFields>Due_x0020_Date,DateTime;</CommonViewfields>

</finem>