Category Archives: SharePoint garapena

Simple azalpena: “Balioa ez da espero tartean erori.”

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

Noiz gertaera hargailuak eta beste kode batekin lan erreferentziak SharePoint zerrenda bidez objektu ereduaren elementuak, Egin ohi dut akatsak sortzen duten exekuzio at error honetan:

Errorea kargatu eta exekutatzen gertaera hartzailea xyzzy en Conchango.xyzzyEventReceiver, 1.0.0.0 bertsioa =, Kultura = neutrala, 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. Hala eta guztiz ere, one simple explanation is that I’m referencing a field incorrectly. If the name of the field is "Due Date", Bertan azaldu behar dut hau bezalako gertaera hargailu batean:

properties.ListItem["Due Date"]

Noiz edo misspell dut oker gertatzen eremuan erreferentzia, SharePoint generates the above mentioned runtime error. Adibidez, hau ez da zuzena:

properties.ListItem["due Date"]

</amaiera>

Nire blog Harpidetu.

Technorati Tags:

Quick & Erraza: Sortu karpeta bat eta Eduki mota bat esleitu (Edo, Zure KPIs eta beraiekin jan ere)

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) erabiltzaileek ez dakite edozein hobeto eta 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, eta hori ez da munduaren amaiera.

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. Baten ondorioz, bat tarta zati mantentzen da karpeta gurasoa en meta data in sync with the KPI-driven meta data from the file itself since the plumbing is already in place. This allows me to have my KPI’s and eat them too 🙂

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").Azpikarpetak;
  SPFolder addedFolder = srcFolders.Add(properties.ListItem.ID.ToString());
  SPContentTypeId kpiCT = berria SPContentTypeId("0x0120002A666CAA9176DC4AA8CBAA9DC6B4039F");
  addedFolder.Item["Content Type ID"] = KpiCT;
  addedFolder.Item.Update();

Benetako Eduki mota ID lokalizatu, Eduki gune ezarpenak eta kopia bidez mota / itsatsi ezazu URL from orokorrak gisa sar dut:

image

</amaiera>

Nire blog Harpidetu!

Technorati Tags: ,

Azkarra eta erraza: Talde SPListItem baten SPFolder gertaera hargailuen batean

Aitortzen gorroto dut, 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:

pribatua gal UpdateParentFolder(SPItemEventProperties propietate)
{

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


} // UpdateParentFolder

Kasu honetan, Dokumentu liburutegi batekin ari naiz lanean, eta propietate dira ItemAdded gertaera datozen.

Tranpa da, ezin dela lortu Elementu SPFolder zuzenean elementua bera (I.E. properties.ListItem.Folder null). Horren ordez, du zerrendako elementu horrek lotutako File joan eta fitxategi horrek karpeta lortu.

</amaiera>

Nire blog Harpidetu!

Technorati Tags:

Yet Another Gertaera hargailuen Araztu Trick

I’m sure I’m not the first person to come up with this. Hala eta guztiz ere, I haven’t noticed anyone publish a trick like this since I started paying close attention to the community last July. Beraz,, Hau da, azkarra eta erraza arazketa punta bidaltzeko nuela pentsatu nuen.

Gertaera baten hartzailea duten hasi akats hau sortzeko nabil 12 hive:

Errorea kargatu eta exekutatzen gertaera hartzailea xyzzy en Conchango.xyzzyEventReceiver, 1.0.0.0 bertsioa =, Kultura = neutrala, PublicKeyToken = blahbalhbalh. Additional information is below. : Objektu erreferentzia ez objektu baten instantzia bat ezarri.

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.

Saiatu dut irtenbide hau nire pdb lortzeko hor itxaropen dituzten SharePoint-en 12 hive automatikoa erakutsiko luke, but no luck. I don’t know if it’s possible and if someone does, please let me know 🙂

Posible al da, ezagutzen dut idatzi, zure log mezuak 12 hive. Frankly, Zerbait apur bat gutxiago scary eta azkarrago ezartzea nahi dut.

Gertatu zait ezin dudala gutxienez lortu zenbait aztarna oinarrizko informazioa eta harrapatzeko berriro bota hau bezalako salbuespenak by generic:

  saiatu {
    UpdateEditionDate(propietate);
  }
  harrapatzeko (Salbuespen eta)
  {
    bota berria Salbuespen("Dispatcher, UpdateEditionDate(): Salbuespen: [" + e.ToString() + "].");
  }

Honek erakutsi du parte 12 hive thusly:

Errorea kargatu eta exekutatzen gertaera hartzailea xyzzy en Conchango.xyzzyEventReceiver, 1.0.0.0 bertsioa =, Kultura = neutrala, PublicKeyToken = blahblahblah. Additional information is below. : Aztergailu, UpdateEditionDate(): Salbuespen: [System.NullReferenceException: Objektu erreferentzia ez objektu baten instantzia bat ezarri. at Conchango.xyzzyManagementEventReceiver.UpdateEditionDate(SPItemEventProperties propietate) at Conchango.xyzzyManagementEventReceiver.Dispatcher(SPItemEventProperties propietate, Katea eventDescription)].

Eman zidan xehetasun behera jarraitzeko bereziki arazo hori behar nuen guztia, eta erabili asko aurrera joatea espero dut.

</amaiera>

Nire blog Harpidetu!

Irtenbidea: SPQuery ez da bilaketa-karpetak

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. Behean line: assign "recursive" bilaketara atributua ikuspegian.

Nire agertokia:

  • Astelehenean, Dokumentu bat igo dut, eta meta-datu batzuk hornitzeko.
  • Ondorengo astean, 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").
  • Sortu dugu, web-zerbitzu fatxada duten BDC errespetatzen interfaze bat eskaintzen du zerrenda hori, beraz, erabiltzaileek erraz kokatzeko Astelehena dokumentua izenburua bilaketa baten bitartez.
  • A BDC data column provides a friendly user interface. (Hau nire saiakera parte da BDC erabiliz Lookup gehiago errespetatzen zutabean at).

Amaierako BDC fatxada kontsulta zerbitzu bat erabiltzen du horrelako bilaketak egiteko:

 // Erabiltzen U2U tresna CAML kontsulta hau sortzen lagundu.
      oQuery.Query =
        "<Non>";

      bada (titleFilter.Length > 0)
        oQuery.Query   =
          "  <Eta>";

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

      bada (titleFilter.Length > 0)
        oQuery.Query   =
          "    <Dauka>" +
          "      <FieldRef Name=\"Title\" />" +
          "      <Value Type=\"Text\">" + titleFilter + "</Balio>" +
          "    </Dauka>" +
          "  </Eta>";
      oQuery.Query   =
        "</Non>";

Garapenaren hasierako fasean, this worked great. Hala eta guztiz ere, karpetak sartu dugu direktorioa arazo batzuk konpontzeko, eta bat-batean, 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, zerrenda-elementua ID oinarritutako karpeta bat sortuko dugu, eta ondoren fitxategia eraman (Idatzi dut hemen; izan dugu mistoak emaitzak Planteamendu honekin, baina, oro har,, ondo ari da lanean). 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 = berria SPQuery();

Ordez erabiltzen dut eraikitzaile bat zehaztu ikuspegi bat:

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

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

Hori arazoa konpondu eta nire emaitzak lortzeko hasi nintzen.

I then added the CONTAINS operator into the mix and it broke again. It turns out that the CONTAINS operator, orain arte bezala dizut, ez du ikuspegian lan egiteko modu berean bat GEQ errazagoa gisa / LEQ operators. I did some searching and learned that the query’s ViewAttributes should be set to "Recursive", bezala:

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

That solved the problem for CONTAINS. Izan ere,, hori ere konpondu nire jatorrizko bilaketa, arazo eta nuen zehazten recursive atributua lehenengo aldiz, Dut, ez luke alean sartu exekutatu berriro.

Izan ere, ikuspegi oinarritutako SPQuery bat operadore batzuen lanak (GEQ/LEQ) eta ez beste batzuk (CONTIENE), Izan ere, gero KPIs hori ez dirudi lan guztiak karpeta duten dokumentu liburutegi batekin eramaten uste SPQuery duela orthogonality gai batzuk ninduen.

Berezia esker:

  • Ona Folks at U2U eta beren kontsulta-tresna.
  • Michael Hoffer handia "egiten ikasteko" blog post, iruzkinak eta erantzunak.

</amaiera>

Nire blog Harpidetu!

MOSS KPI bug? Zerrenda adierazle Dokumentu liburutegia lotuta karpeta

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. Duten deskribatzen dut Xehetasun gehiagorekin hemen.

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 (teknika bat zer idatzi nuen antzekoak erabiliz hemen). 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" baina horren ordez sortu docs lokalean eta gero igo).

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".

Normalean erraz egin eta zerbait deskribatu dut oso atsegin dute hau SharePoint Beagle hartan pantaila plano asko galtzen interesa duten bazara.

Hitz batean, Honako hau egin nuen:

  • Create a view on the doc library called "Pending".
  • Konfiguratu ikuspegia karpeta-egitura ez ikusi egin.
  • Sortu KPI zerrenda bat.
  • Create an indicator in the list that points to the doc lib and that "Pending" ikusteko.

This simply does not work. The KPI shows my target (e.g. bost premiazko dokumentuak) but always shows the actual number of urgent documents as zero. Paradoxically, zulatzeko edukiz xehetasunak, 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:

image

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".

Agertzen zait, nahiz eta duten ikuspegi bat zehaztu behar duzu, the KPI doesn’t honor the "show all items without folders" eta ezarpen ordez, mugarik berez erro karpeta.

Dut oker bada, mesedez, jaregin me lerro bat edo iruzkina utzi.

</amaiera>

Nire blog Harpidetu!

Technorati Tags:

Arazoaren konponbidea: “FileNotFoundException” Nire Film hargailu batekin.

I was working on a feature last week that would add some event receivers to a specific list instance. (Pixka bat Blogetakoak I hartzailea zerrenda hori hemen).

Komando-lerroa erabiliz, Ezaugarri instalatu izan dut error gabe (baina ikusi beherago ezkutuko akats). When I tried to deploy the feature on the site, MOSS complained of a "FileNotFoundException" error. This blog entry describes how I solved it.

Hau errorea MOSS erakutsi zidan web nabigatzailea da:

Feature ‘b2cb42e3-4f0a-4380-aaba-1ef9cd526f20’ could not be installed because the loading of event receiver assembly "xyzzyFeatureReceiver_0" huts egin du: System.IO.FileNotFoundException: Could not load file or assembly ‘xyzzyFeatureReceiver_0’ edo bere mendekotasunen bat. Sistema ezin du fitxategia aurkitu zehaztutako.
File name: ‘xyzzyFeatureReceiver_0’
at System.Reflection.Assembly.nLoad(AssemblyName fitxategi-izena, Katea iturburua, Evidence assemblySecurity, Batzar locationHint, StackCrawlMark& stackMark, Boolearrak throwOnFileNotFound, Boolearrak forIntrospection)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolearrak forIntrospection)
at System.Reflection.Assembly.InternalLoad(Katea assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolearrak forIntrospection)
at System.Reflection.Assembly.Load(Katea assemblyString)
at Microsoft.SharePoint.Administration.SPFeatureDefinition.get_ReceiverObject()
WRN: Batzar loteslea dena itzalita dago.
Muntaia bind porrota egunkarian gaitzeko, ezarri erregistro-balioa [HKLM Software Microsoft Fusión!EnableLog] (DWORD) to 1.
Kontuan izan: Badira muntaia bind porrota egunkarian lotutako errendimendu penalti batzuk.
Eginbide hori desaktibatzeko, kendu erregistroko balioa [HKLM Software Microsoft Fusión!EnableLog].

Konpondu Windows SharePoint Services gaiak.

Nola nahita eragin error jakin dut: don’t install the assembly in the GAC. Baina, 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% erosoa eta beti pentsatu izan dut delako gacutil duten arrazoi bat existitu egiten dela … so I tried that. It made no difference.

Internets bilatu nintzen eta post hau topatu: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2243677&SiteID=1

Egilearen gertatu daiteke erabili kodea erro bera bit (du zerrenda honetan Inside WSS-liburu) so that was a hopeful sign. Hala eta guztiz ere, Batzar apaintzen duen gomendioa batekin [muntaia: ] 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.

Hurrengoa, I went to the trouble of enabling the "assembly bind failure log" (betiere, lagungarria eta zehatza jarraibideak) 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. Baina … ezin izango da bilatzeko GAC en.

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" Ezaugarri for b2cb42e3-4f0a-4380-aaba-1ef9cd526f20: System.ArgumentNullException: Balioa ezin da hutsik egon.
Parametro izena: mota
at System.Activator.CreateInstance(Mota mota, Boolearrak nonPublic)
at System.Activator.CreateInstance(Mota mota)
at Microsoft.SharePoint.Administration.SPFeatureDefinition.get_ReceiverObject()

Konpondu Windows SharePoint Services gaiak.

Bata Internets azken bidaia egiteko denbora!

Denbora honetan jakin dut, aurrez nahikoa, that MOSS issues this error because the assembly is not in GAC.

Zerbait honen out positiboa lortzeko eta saiatu apur bat harro ditudan sortu sentitu nahi dut MSIL muntaietan Iheslarien, but it’s not working. I’m just plain annoyed. I find myself muttering "chicken or the egg" nire arnasa pean.

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" baina ezin da aurkitu).

Eginbidea instalatu eta gaitu eta … Funtzionamendua! Beraz,, hori guztia egin ondoren, I had to basically ‘reboot’ my project. Honetan beste arrazoi bat zergatik ordenagailuak gorroto dut.

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. For some reason, I did not use the -force option when I installed the new project. Oraingo honetan, Egia esan, ez nuen, truly forget to copy this new project’s assembly into the GAC. Baten ondorioz, I received that "FielNotFoundException" error. Oraingo honetan, Lortu dut stsadm tik, not when I tried to activate the feature via the web browser. Beraz,, -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.

</amaiera>

Quick & Erraza: Aldatu izena Kargatutako fitxategia SharePoint Object Model erabiliz Gertaera hargailuen bat Via

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

UPDATE 2: Nire proiektua uneko, users always upload documents. Baten ondorioz, 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() hartzailea da baliozko balioa bilatzen ez benetan rename egin aurretik, eta orduz geroztik, 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()" metodoa. Horren ordez, erabili behar dugun "MoveTo(…)". Here is a minimal bit of code to accomplish this:

 publikoak baliogabetzeko gal ItemAdded(SPItemEventProperties propietate)
        {
            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.

Hau gehiago erabilgarria bertsio gauza bera egiten da, but assigns the name of the file to "Title":

 publikoak baliogabetzeko gal ItemAdded(SPItemEventProperties propietate)
        {
            DisableEventFiring();

            // Esleitu Elementu honen izenburua, fitxategi beraren izena.
 // OHARRA: Esleipen hau egin behar dugu aldatzeko fitxategi beraren aurretik.
 // Eguneratzea deituz() SPFile buruzko badirudi propietate baliogabetu ahal izateko
 // Zentzu batzuk.  Updates to "Title" aldaketa huts egin arte (eta eguneratzea() deitu)
 // ziren aldaketaren aurrean mugitu fitxategi-izenaren.
            properties.ListItem["Title"] = Properties.ListItem.File.Name;

            properties.ListItem.Update();

            SPFile f = properties.ListItem.File;

            // Talde fitxategi luzapena.  Hori behar dugu, geroago.
 katea spfileExt = berria FileInfo(f.Name).Luzapena;

            // Aldatu fitxategiaren zerrenda-elementua ID-eta fitxategi-luzapena erabili eta mantentzeko
 // dela zati oso-osorik.
            f.MoveTo(properties.ListItem.ParentList.RootFolder.Url +
                "/" + properties.ListItem["ID"] + spfileExt);

            // Entregatu mugimendua.
            f.Update();

            EnableEventFiring();
        }

Quick Tip: Edukia Query Web zatia, Lookup Zutabe balioa eta XSL

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

That column is of type "lookup".

Aldatu dut <CommonViewFields> eta ItemStyle.xsl zutabe erakusteko.

Sinple bat <xsl:balio hautatu =…> itzultzen itzuli barneko balioa dituen ordinalak posizio datuak, esate baterako,:

1;#Miami

Giza-friendly balioa lortzeko, erabili xsl ezik-ondoren, ikus daitekeen bezala:

<xsl:value-of select="substring-after(@ Real_x005F_x0020_Estate_x005F_x0020_Location,'#')"></xsl:balio du>

Erabili teknika hau, betiere, XSL transformazio balio lookup ari zaren lan egin eta behar giza-friendly balioa lortzeko.

<amaieran />

Technorati Tags: , ,

Azkarra eta erraza: Zehazteko Barne Zutabe Web Zutabe baten izena

UPDATE: Jeremy Thake du honi buruz Blogetakoak eta jarri batzuk kontsola aplikazio baten kodea erakusten duen barne-izenak.

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", Zutabe-izen hori erabili bere gain hartu nuen <CommonViewFields> is "Due_x0020_Date".

Oker!

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

Nola aurkituko dut? I re-read Heather Solomon en CQWP aldatzea sarrera blog to show additional columns of data. She describes this process at step #13. Trust it. It’s correct. Gutxienez, 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" izena, Eremu beste gehitzeko nahi nuen <CommonViewFields>. Using the Solomon technique, I was getting a column name like "XYZ_x0020_Project_x0020_Due_x00".

, Pentsatu nuen, 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: Noiz CQWP batera nintzen lanean, gehitu dut txarra barne izena badago <CommonViewFields>, the CQWP would tell me that the query had returned no results. Baina, gehitu dut datu-mota bat bada, eremu-izena, 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, baina bere balioa erakutsi nahi izan dut,, I would always get a blank.

Honek ez zuen maskara errorea:

<CommonViewFields>Due_x0020_Date;</CommonViewfields>

Akats maskara zuen:

<CommonViewFields>Due_x0020_Date,DateTime;</CommonViewfields>

</amaiera>