jamii Archives: SharePoint Maendeleo

Maelezo rahisi: “Thamani si kuanguka ndani mbalimbali yanayotarajiwa.”

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

Wakati wa kufanya kazi na kupokea tukio na code nyingine kwamba marejeo SharePoint orodha ya vitu via mfano kitu, Mimi mara nyingi kufanya makosa ili kuzalisha hili kosa katika Runtime:

Hitilafu ya upakiaji na mbio tukio receiver Conchango.xyzzyEventReceiver katika xyzzy, Version = 1.0.0.0, Utamaduni = neutral, 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. Hata hivyo, one simple explanation is that I’m referencing a field incorrectly. If the name of the field is "Due Date", Mimi lazima akifanya marejeo ni kama hii katika receiver tukio:

properties.ListItem["Due Date"]

Wakati mimi misspell au kutumia vibaya wakati kesi referencing shamba, SharePoint generates the above mentioned runtime error. Kwa mfano, hii ni sahihi:

properties.ListItem["due Date"]

</mwisho>

Kujiunga na blog yangu.

Tags technorati:

Haraka & Rahisi: Kujenga Folder na Mpe Aina Content (Au, Kuwa KPIs yako na kula sana Them)

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. Kama matokeo, 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. Hii inaruhusu yangu kuwa wangu KPI na kula nao pia 🙂

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 = mpya 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:

picha

</mwisho>

Kujiunga na blog yangu!

Tags technorati: ,

Haraka na Easy: Kupata SPFolder ya SPListItem katika kupokea Tukio

I hate kukubali hilo, 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:

binafsi utupu UpdateParentFolder(SPItemEventProperties mali)
{

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


} // UpdateParentFolder

Katika kesi hiyo, Mimi nina kazi na maktaba hati na mali ni kuja kutoka tukio ItemAdded.

hila ni kwamba huwezi kupata SPFolder ya bidhaa moja kwa moja kutoka bidhaa yenyewe (i.e. properties.ListItem.Folder ni null). Badala yake, kwenda Picha bidhaa orodha ya kuhusishwa na kupata folder faili ya.

</mwisho>

Kujiunga na blog yangu!

Tags technorati:

Lakini nyingine kupokea Tukio Ondoa Hitialfu hila

I’m sure I’m not the first person to come up with this. Hata hivyo, I haven’t noticed anyone publish a trick like this since I started paying close attention to the community last July. Hivyo, Nilidhani ningependa baada ya kuwa hii haraka na rahisi Debug ncha.

Mimi nina kazi ya receiver tukio hilo kuwa ilianza kuzalisha kosa hili katika 12 mzinga:

Hitilafu ya upakiaji na mbio tukio receiver Conchango.xyzzyEventReceiver katika xyzzy, Version = 1.0.0.0, Utamaduni = neutral, PublicKeyToken = blahbalhbalh. Additional information is below. : Kitu kumbukumbu si kuweka mfano wa kitu.

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.

Nilijaribu ufumbuzi huu kupata PDB yangu katika huko pamoja na matumaini kwamba SharePoint ya 12 mzinga bila kuonyesha mpororo, but no luck. I don’t know if it’s possible and if someone does, tafadhali napenda kujua 🙂

Najua inawezekana kuandika ujumbe yako mwenyewe logi kwa 12 mzinga. Frankly, Nilitaka kitu kidogo kidogo inatisha na wepesi kutekeleza.

Ilitokea kwangu kwamba mimi naweza angalau kupata baadhi ya msingi kuwaeleza habari na kuambukizwa na re-kutupa isipokuwa generic kama hii:

  kujaribu {
    UpdateEditionDate(mali);
  }
  kukamata (Ubaguzi e)
  {
    kutupa mpya Ubaguzi("Dispatcher, UpdateEditionDate(): Ubaguzi: [" + e.ToString() + "].");
  }

Hii ilionyesha juu katika 12 mzinga thusly:

Hitilafu ya upakiaji na mbio tukio receiver Conchango.xyzzyEventReceiver katika xyzzy, Version = 1.0.0.0, Utamaduni = neutral, PublicKeyToken = blahblahblah. Additional information is below. : Dispatcher, UpdateEditionDate(): Ubaguzi: [System.NullReferenceException: Kitu kumbukumbu si kuweka mfano wa kitu. at Conchango.xyzzyManagementEventReceiver.UpdateEditionDate(SPItemEventProperties mali) at Conchango.xyzzyManagementEventReceiver.Dispatcher(SPItemEventProperties mali, Kamba eventDescription)].

Kwamba alinipa undani wote mimi zinahitajika kufuatilia kwamba tatizo fulani na mimi kutarajia matumizi yake mengi kwenda mbele.

</mwisho>

Kujiunga na blog yangu!

Ufumbuzi: SPQuery Je Si Tafuta 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. Bottom line: assign "recursive" kwa sifa mtazamo wa swala.

Yangu mazingira:

  • Jumatatu, Mimi upload hati na ugavi baadhi ya data meta.
  • Wiki iliyofuata, 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").
  • Tumeunda huduma ya mtandao façade ambayo hutoa interface BDC-kirafiki na orodha hivyo kwamba watumiaji urahisi Machapisho kwamba hati Jumatatu kupitia tafuta cheo.
  • A BDC data column provides a friendly user interface. (Hii ni sehemu ya jaribio yangu katika kutumia BDC kwa safu zaidi ya kirafiki Lookup).

mwisho BDC façade huduma anatumia swala kama hii kufanya lookup:

 // Kutumika U2U chombo ili kusaidia katika kuzalisha hii hoja CAML.
      oQuery.Query =
        "<Ambapo>";

      kama (titleFilter.Length > 0)
        oQuery.Query   =
          "  <Na>";

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

      kama (titleFilter.Length > 0)
        oQuery.Query   =
          "    <Ina>" +
          "      <FieldRef Name=\"Title\" />" +
          "      <Value Type=\"Text\">" + titleFilter + "</Thamani>" +
          "    </Ina>" +
          "  </Na>";
      oQuery.Query   =
        "</Ambapo>";

Wakati wa hatua ya awali ya maendeleo, this worked great. Hata hivyo, sisi ilianzisha folders katika saraka ya kutatua baadhi ya matatizo na ghafla, 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, sisi kujenga folder msingi ID bidhaa orodha na kisha kuondoka faili huko (Niliandika kuhusu kwamba hapa; tulikuwa na mchanganyiko matokeo na mfumo huu lakini kwa ujumla, ni kazi vizuri). 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 = mpya SPQuery();

Mimi badala kutumika kuujenga kwamba maalum mtazamo:

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

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

Kwamba kutatuliwa tatizo na mimi kuanza kupata matokeo yangu.

I then added the CONTAINS operator into the mix and it broke again. It turns out that the CONTAINS operator, hivyo mbali kama naweza kuwaambia, haifanyi kazi kwa lengo njia ile ile kama GEQ rahisi / LEQ operators. I did some searching and learned that the query’s ViewAttributes should be set to "Recursive", kama katika:

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

That solved the problem for CONTAINS. Kwa kweli, hii pia kutatuliwa tafuta yangu ya awali tatizo na kama alikuwa maalum sifa kujirudia mara ya kwanza, Mimi bila kuwa na kukimbia katika suala tena.

ukweli kwamba SPQuery maoni makao kazi kwa waendeshaji baadhi (GEQ/LEQ) na si watu wengine (Ina), pamoja na ukweli kwamba KPIs hawaonekani kazi wakati wote na maktaba hati folder zenye inaongoza mimi kuamini kwamba SPQuery ina baadhi ya masuala orthogonality.

Shukrani maalum:

</mwisho>

Kujiunga na blog yangu!

MOSS KPI mdudu? Orodha Kiashiria Amefungwa kwa Maktaba Kudhibiti Kwa 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. Mimi alielezea kwamba katika undani zaidi kidogo hapa.

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 (kutumia mbinu sawa na kile aliandika kuhusu hapa). 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" lakini badala yake kuunda maandiko ndani ya nchi na kisha kuzipeleka).

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

Hii ni kawaida rahisi kufanya na mimi ilivyoelezwa kitu sana kama hii ifikapo Beagle SharePoint kwa kura ya screen shots kama wewe ni nia ya.

Kwa kifupi, Nilifanya zifuatazo:

  • Create a view on the doc library called "Pending".
  • Configure maoni kupuuza folder muundo.
  • Kujenga Orodha KPI.
  • Create an indicator in the list that points to the doc lib and that "Pending" mtazamo.

This simply does not work. The KPI shows my target (e.g. tano ya haraka nyaraka) but always shows the actual number of urgent documents as zero. Paradoxically, kama wewe kuchimba chini kwa maelezo, 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:

picha

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

Inaonekana kwangu kwamba hata kama wewe bayana mtazamo, the KPI doesn’t honor the "show all items without folders" kuweka na badala yake, mipaka yenyewe ya folder mzizi.

Kama mimi nina makosa, tafadhali tone mimi line au kuacha maoni.

</mwisho>

Kujiunga na blog yangu!

Tags technorati:

Ufumbuzi wa tatizo: “FileNotFoundException” Pamoja na kupokea Makala yangu.

I was working on a feature last week that would add some event receivers to a specific list instance. (Mimi blogged kidogo kuhusu receiver kwamba orodha hapa).

Kutumia mstari amri, Mimi naweza kufunga kipengele na hakuna kosa (lakini angalia chini kwa ajili ya kosa ya siri). When I tried to deploy the feature on the site, MOSS complained of a "FileNotFoundException" kosa. This blog entry describes how I solved it.

This is the error that MOSS showed me in the web browser:

Feature ‘b2cb42e3-4f0a-4380-aaba-1ef9cd526f20’ could not be installed because the loading of event receiver assembly "xyzzyFeatureReceiver_0" failed: System.IO.FileNotFoundException: Could not load file or assembly ‘xyzzyFeatureReceiver_0’ au mmoja wa beroendet yake. The system cannot find the file specified.
File name: ‘xyzzyFeatureReceiver_0’
at System.Reflection.Assembly.nLoad(AssemblyName Filename, Kamba codebase, Ushahidi assemblySecurity, Bunge locationHint, StackCrawlMark& stack udongo, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Ushahidi assemblySecurity, StackCrawlMark& stack udongo, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(String assemblyString, Ushahidi assemblySecurity, StackCrawlMark& stack udongo, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)
at Microsoft.SharePoint.Administration.SPFeatureDefinition.get_ReceiverObject()
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) kwa 1.
Kumbuka: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Troubleshoot issues with Windows SharePoint Services.

I know how to deliberately cause that error: don’t install the assembly in the GAC. Lakini, 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% comfortable doing that because I always thought that gacutil existed for a reason … so I tried that. It made no difference.

I searched the Internets and found this post: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2243677&SiteID=1

The poster happened to be using the same root bit of code (from the Inside WSS book from this list) so that was a hopeful sign. Hata hivyo, the suggestion of decorating the assembly with an [assembly: ] 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.

Ijayo, I went to the trouble of enabling the "assembly bind failure log" (following the helpful and accurate instructions provided) 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. Lakini … it won’t search for it in the 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" for feature b2cb42e3-4f0a-4380-aaba-1ef9cd526f20: System.ArgumentNullException: Value cannot be null.
Parameter jina: aina
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at Microsoft.SharePoint.Administration.SPFeatureDefinition.get_ReceiverObject()

Troubleshoot issues with Windows SharePoint Services.

Time for one last trip to the Internets!

This time I find out, predictably enough, that MOSS issues this error because the assembly is not in GAC.

I want to get something positive out of this and try to feel a little proud that I’ve created the Fugitive of MSIL assemblies, but it’s not working. I’m just plain annoyed. I find myself muttering "chicken or the egg" under my breath.

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" but can’t find one).

I install the feature and activate it and … it works! Hivyo, after all that, I had to basically ‘reboot’ my project. This is another reason why I hate 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. Kwa sababu baadhi ya, I did not use the -force option when I installed the new project. Wakati huu, I did actually, truly forget to copy this new project’s assembly into the GAC. Kama matokeo, I received that "FielNotFoundException" kosa. Wakati huu, I got it from stsadm, not when I tried to activate the feature via the web browser. Hivyo, -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.

</mwisho>

Tags technorati: ,

Haraka & Rahisi: Rename Uploaded Picha Kutumia SharePoint Object Model Via kupokea Tukio

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

UPDATE 2: Katika mradi wangu wa sasa, users always upload documents. Kama matokeo, 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() receiver inaonekana kwa thamani halali ya hapo kabla ya kufanya kweli rename na tangu wakati huo, 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()" njia. Badala yake, sisi kutumia "MoveTo(…)". Here is a minimal bit of code to accomplish this:

 umma override utupu ItemAdded(SPItemEventProperties mali)
        {
            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.

Hili ni toleo la muhimu zaidi kwamba haina kitu kimoja, but assigns the name of the file to "Title":

 umma override utupu ItemAdded(SPItemEventProperties mali)
        {
            DisableEventFiring();

            // Hawawajui ilani ya bidhaa hii kwa jina la faili yenyewe.
 // NOTE: Zoezi hili lazima kuchukua nafasi kabla ya sisi kurekebisha faili yenyewe.
 // Wito update() juu ya SPFile inaonekana kubatilisha mali katika
 // baadhi ya hisia.  Updates to "Title" alishindwa mpaka mabadiliko ambayo (na update() wito)
 // walikuwa wakiongozwa mbele ya mabadiliko ya jina la faili.
            properties.ListItem["Title"] = Properties.ListItem.File.Name;

            properties.ListItem.Update();

            SPFile f = properties.ListItem.File;

            // Kupata ugani ya faili.  Tunahitaji kwamba baadaye.
 string spfileExt = mpya Picha Info(f.Name).Ugani;

            // Rename faili ID bidhaa orodha na kutumia faili ugani kuweka
 // kwamba sehemu yake intact.
            f.MoveTo(properties.ListItem.ParentList.RootFolder.Url +
                "/" + properties.ListItem["ID"] + spfileExt);

            // Kufanya hoja.
            f.Update();

            EnableEventFiring();
        }

Haraka Tip: Content Query Mtandao Sehemu ya, Luke Column Thamani na XSL

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

That column is of type "lookup".

Mimi tarehe <CommonViewFields> na ItemStyle.xsl kuonyesha safu.

rahisi <xsl:thamani ya kuchagua =…> anarudi nyuma thamani ya ndani kuwa ni pamoja na data nafasi makutano, kama vile:

1;#Miami

Kupata thamani ya binadamu ya kirafiki, kutumia XSL substring-baada ya, kama inavyoonekana:

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

Kutumia mbinu hii wakati wewe ni kufanya kazi na maadili lookup katika kuugeuza XSL na haja ya kupata thamani ya binadamu ya kirafiki.

<mwisho />

Tags technorati: , ,

Haraka na Easy: Kuamua Ndani Column Jina la Column Site

UPDATE: Jeremy Thake ina blogged kuhusu hili na kuweka baadhi kanuni kwa ajili ya maombi console kwamba inaonyesha majina ya ndani.

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", Mimi kudhani kwamba jina safu ya kutumia katika <CommonViewFields> is "Due_x0020_Date".

Vibaya!

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

Jinsi gani mimi kupata? I re-read Heather Suleimani blog kuingia kwenye kubadilisha 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" jina, Nilitaka kuongeza mwingine kwa shamba <CommonViewFields>. Using the Solomon technique, I was getting a column name like "XYZ_x0020_Project_x0020_Due_x00".

Mimi nilidhani, 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.

Ziada ncha: Wakati mimi alikuwa anafanya kazi na CQWP, kama mimi aliongeza mbaya ndani kwa jina <CommonViewFields>, the CQWP would tell me that the query had returned no results. Lakini, kama mimi aliongeza aina data kwa jina shamba, 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, lakini wakati nilijaribu kuonyesha thamani yake, I would always get a blank.

Hii si kufunika kosa:

<CommonViewFields>Due_x0020_Date;</CommonViewfields>

Hii hakuwa mask kosa:

<CommonViewFields>Due_x0020_Date,DATETIME;</CommonViewfields>

</mwisho>