tag:blogger.com,1999:blog-20229785577111180712024-02-18T23:57:37.886-08:00SharePoint CommentsAndrey Shchurovhttp://www.blogger.com/profile/04807057547080579722noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-2022978557711118071.post-78353073675413300192014-04-16T01:04:00.002-07:002014-04-16T01:05:28.796-07:00SharePoint Site Explorer (SPSE)<div dir="ltr" style="text-align: left;" trbidi="on">
Check out my new SharePoint App at <a href="http://office.microsoft.com/en-au/store/sharepoint-site-explorer-spse-WA104281518.aspx">http://office.microsoft.com/en-au/store/sharepoint-site-explorer-spse-WA104281518.aspx</a><br />
<br />
<div class="separator" style="clear: both; text-align: left;">
<a href="http://office.microsoft.com/en-au/store/sharepoint-site-explorer-spse-WA104281518.aspx"><img alt="http://office.microsoft.com/en-au/store/sharepoint-site-explorer-spse-WA104281518.aspx" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9A2akHWEA8etT1sJqbKOrQPrY_YwRreVx45YOC48PXZSvISpuGzdWTO83_g9yiCaWX-zu4GUWANbmhmVTW84C-sgPfU0E5TCHO9S10wY84IHrw1Um7ycAPrtx5Ad46LB_PigCl7WPVyv-/s1600/AppIcon.png" /></a></div>
<div class="title">
<h2>
SharePoint Site Explorer</h2>
</div>
SharePoint Site Explorer (SPSE) is our flag-ship app that provides you
with an in-depth understanding of site configuration, structure and
settings. It lets you quickly perform breadth-first or depth-first site
analysis. It offers a faster way of exploring the site objects than
using out-of-the box user interface. Additionally you will get a load
more information, presented in a structured way. If you are technical
savvy then it can reveal the JSON requests/response data. You can use
this information for troubleshooting and further enhancing your
solutions. Furthermore, SPSE installation is breeze with no server side
code is deployed. Whether you have your site in the cloud (SharePoint
online/Office 365) or on premise in SharePoint 2013 SharePoint Site
Explorer can be added to your site in no time.<br />
<br />
<div class="separator" style="clear: both; text-align: left;">
</div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<div class="separator" style="clear: both; text-align: left;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiP12z8OcRdVPxhpuRdIA7yCEg-XHzK8zSYRPFqNOBqcnMnvcCU95OaNVtXQgVcAx3bvj7R3ShRsXlEZkEkeFmX0e5X5tFlG6ApXHKgDtvuzEE0deoRDbHDT-7bd7Gu_8mnl8xqYSCP5GCJ/s1600/SharePonintExplorer.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiP12z8OcRdVPxhpuRdIA7yCEg-XHzK8zSYRPFqNOBqcnMnvcCU95OaNVtXQgVcAx3bvj7R3ShRsXlEZkEkeFmX0e5X5tFlG6ApXHKgDtvuzEE0deoRDbHDT-7bd7Gu_8mnl8xqYSCP5GCJ/s1600/SharePonintExplorer.PNG" height="315" width="400" /> </a></div>
More details at <a href="http://www.aurorabits.com/spsexplorer/">http://www.aurorabits.com/spsexplorer/ </a><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
<br /></div>
Andrey Shchurovhttp://www.blogger.com/profile/04807057547080579722noreply@blogger.com0tag:blogger.com,1999:blog-2022978557711118071.post-6084021324290585632009-05-03T18:10:00.000-07:002009-05-03T18:36:54.970-07:00Wrong Content Type value displayed for a new document<p>I troubleshot a problem when a wrong content type value was displayed for a new document in document library with multiple content types. Content type “Electronic Letter” was created a while after content type “Letter” and used the same template MS Word 2007 document. The root of the problem was in the document template itself. It was taken from content type “Letter” and contained this content type metadata and when I tried to use it in other content types it still had the original binding to “Letter”. Microsoft says that this problem happens with Office 2007 document only and recommendation is to keep the master copy of the document template on disk and never take it from SharePoint. In my case the problem was that I did not have the master copy on my disk and could only use the document already loaded to SharePoint and bound to the other content type. And finally I found the way how to detach the document.</p> <p>Open the document from disk and go to Prepare->Inspect Document menu item.</p> <p><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxZqMgFNRHsQbf6yoeaewSVNxoxlARtSmKLOutGhBYywrlFNncMkw6YQkRx-71Y_i-rln5D0EnxDAo2jMVymyeuCBqGAkXZdfR2C4lsePnCgb1JRHspk0ff4Qz-codYDeH9nhaKUPJL_pQ/s1600-h/1.jpg"><img style="cursor: pointer; width: 320px; height: 293px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxZqMgFNRHsQbf6yoeaewSVNxoxlARtSmKLOutGhBYywrlFNncMkw6YQkRx-71Y_i-rln5D0EnxDAo2jMVymyeuCBqGAkXZdfR2C4lsePnCgb1JRHspk0ff4Qz-codYDeH9nhaKUPJL_pQ/s320/1.jpg" alt="" id="BLOGGER_PHOTO_ID_5331774618169190322" border="0" /></a></p> <p>Check “Document Properties and Personal Information” item and press “Inspect” button.</p> <p><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZZmJXBNnCGf3WHGaWynnHlHLMEQLFUBsVqS1-o8QdnRQVEqmv8VDyRgtSwWbMXdlsAb2D7vBusJfQ7QBUUwxPoz6CF8xN6v9Y3EsB0YVOTd5kqYzI9RU5NysEGAv1yQpymxGZlWvx4mli/s1600-h/2.jpg"><img style="cursor: pointer; width: 320px; height: 291px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZZmJXBNnCGf3WHGaWynnHlHLMEQLFUBsVqS1-o8QdnRQVEqmv8VDyRgtSwWbMXdlsAb2D7vBusJfQ7QBUUwxPoz6CF8xN6v9Y3EsB0YVOTd5kqYzI9RU5NysEGAv1yQpymxGZlWvx4mli/s320/2.jpg" alt="" id="Img1" border="0" /></a></p> <p>Press “Remove All” button against “Document Properties and Personal Information” item. This will remove all the content type binding of this document.</p> <p><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSXUmN9WXX8aYzHbz6wnT5zPmVexNXUKKxcWSzLUxfp9Qa5jnT4grUy5tJWkJGxLKHhl-u78VXtOd1NDv8q7UUDQyvBE-i-ocyQ8KMOJlO5ak_u0dJJKW4DoZSOlBwo-ZbDNkvQ02k2kFY/s1600-h/3.jpg"><img style="cursor: pointer; width: 320px; height: 291px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSXUmN9WXX8aYzHbz6wnT5zPmVexNXUKKxcWSzLUxfp9Qa5jnT4grUy5tJWkJGxLKHhl-u78VXtOd1NDv8q7UUDQyvBE-i-ocyQ8KMOJlO5ak_u0dJJKW4DoZSOlBwo-ZbDNkvQ02k2kFY/s320/3.jpg" alt="" id="Img2" border="0" /></a></p> <p>Press “Close” button and save the document. </p> <p><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjf2XMXInSbNPcKEuihuvDMegKt29xkDaU8NT93r38cJvZgcRkmqb4NxjV03dOz1DNa-Vb6BTJbzppaBa711uG4dh00oZip52DKN0W7U9hbeikBEHvthrTP3Ppa5qgO45PO05QGWrtHzDoT/s1600-h/4.jpg"><img style="cursor: pointer; width: 320px; height: 291px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjf2XMXInSbNPcKEuihuvDMegKt29xkDaU8NT93r38cJvZgcRkmqb4NxjV03dOz1DNa-Vb6BTJbzppaBa711uG4dh00oZip52DKN0W7U9hbeikBEHvthrTP3Ppa5qgO45PO05QGWrtHzDoT/s320/4.jpg" alt="" id="Img3" border="0" /></a></p> <p>After that you can use this document as a master copy for all the other content types where it is used as a template. </p>Andrey Shchurovhttp://www.blogger.com/profile/04807057547080579722noreply@blogger.com0tag:blogger.com,1999:blog-2022978557711118071.post-84599661507937014192008-06-09T22:30:00.000-07:002008-06-09T22:41:55.775-07:00Be careful using non-alphanumeric field names in SharePoint<p>I found
that there are some inconsistency in internal name generating in WSS 3.0. I
encountered with it when receiving en error on checking in a file. SharePoint
log file did not reveal the problem as usual :) and I used my custom code to
troubleshoot. This is the exception description and a stack trace I received:</p>
<pre>
at Microsoft.SharePoint.SPFieldCollection.GetFieldByInternalName(String strName, Boolean bThrowException)
at Microsoft.SharePoint.SPFieldCollection.GetFieldByInternalName(String strName)
at Microsoft.SharePoint.SPListItem.get_MissingRequiredFields()
at Microsoft.SharePoint.ApplicationPages.Checkin.OnLoad(EventArgs e)
</pre>
<p>I
started to review code in Reflector and discovered that
<code>SPListItem.MissingRequiredFields</code> property is checked on page check in. For this
purpose it uses <code>SPFieldLink.Name</code> from <code>SPListItem.ContentType.FieldLinks</code>
collection to retrieve <code>SPField</code> object from <code>SPListItem.ParentList.Fields</code>
collection for every field which is <code>SPFieldLink.Required=true</code>. In order to get
<code>SPField</code> object <code>SPFieldCollection.GetFieldByInternalName()</code> method is used and if
<code>SPFieldLink.Name</code> field value is not found as internal name of any <code>SPField</code> then
we receive "Value does not fall within the expected range" exception. </p>
<p>In my
case I have a field named "Description of Change/New document" which is
translated to internal name as
"<code>Description_x0020_of_x0020_Change_x002F_New_x0020_Document</code>" but for some reason
<code>SPFieldLink.Name</code> field value for this field is
"<code>Description_x0020_of_x0020_Change_x002f_New_x0020_Document</code>". Feel the
difference in unicode of symbol "/": <code>x002f</code> (small 'f') and <code>x002F</code> (capital 'F').
That gives me two different internal names and I have these troubles. I guess
there is inconsistency and there are several functions which generate internal
name and these functions produce different result in some cases. </p>
<p>When I
recreated my field the problem was fixed for which I do not have any
explanation.</p>Andrey Shchurovhttp://www.blogger.com/profile/04807057547080579722noreply@blogger.com2tag:blogger.com,1999:blog-2022978557711118071.post-2191891079991807972007-07-22T18:08:00.000-07:002007-07-22T18:11:33.111-07:00Convert Java to .NET<p>Some project required me to port Java source code into .NET environment. I
had to import this code into J# project and then compile it. It worked ok if you
had entire source code but usually I did not have it or Java project used some
third party JARs. Searching for some solution I found
<a target="_blank" href="http://www.ikvm.net">IKVM.NET</a> This is a striking
solution and it solves 99% of problems of usage Java in .NET. It converts Java
byte code into .NET CLR and you do not need to any source code any more. It is
amazing and many thanks to its author Jeroen Frijters.</p>Andrey Shchurovhttp://www.blogger.com/profile/04807057547080579722noreply@blogger.com0tag:blogger.com,1999:blog-2022978557711118071.post-81967784061551849552007-05-11T20:28:00.000-07:002007-05-12T00:03:01.005-07:00Yet another scripting host - MyScriptHost<p>Developing for SharePoint I found myself in situation when I had an access
the the server (direct or remote desktop) and need to run some ad-hoc code on it
but the server did not have Visual Studio or any other development environment
installed. I think this is familiar to some of us. These are some possible
options:</p>
<ul>
<li>install Visual Studio or any other development environment (very
unlikely that administrator will allow you to do it for test or production
environment)</li>
<li>develop the code on the other machine and run on the server (good
approach but you loose code flexibility especially if you want to write and
test your code interactively)</li>
<li>use
<a target="_blank" href="http://www.sliver.com/dotnet/SnippetCompiler/">SnippetCompiler</a>. This is a very good tool and I would choose it if
it supported command line execution of C# files.</li>
<li>use Windows Scripting Host (WSH) to create and run scripts (good
approach but you need to use JScript of VBScript)</li>
<li>use
<a target="_blank" href="http://www.codeproject.com/dotnet/DotNetScript.asp">
Dot Net Script</a> (good tool, but it uses its own file format and does not
have IDE)</li>
</ul>
<p>I wanted to have some kind of a combination of
<a target="_blank" href="http://www.sliver.com/dotnet/SnippetCompiler/">SnippetCompiler</a> and
<a target="_blank" href="http://www.codeproject.com/dotnet/DotNetScript.asp">Dot
Net Script</a> where I could create some scripts and maybe execute them
automatically in future. </p>
<p>So meet <a href="http://www.andreyshchurov.com/projects/MyScriptHost/default.aspx">MyScriptHost</a>.
</p>
<p><img border="0" src="http://www.andreyshchurov.com/blogimages/004_01.jpg" width="600" height="341"></p>
<p>This is a console application with a windowed code editor. It works with one
file at a time which can be executed with or without code editor. It can
associate .mysh files to itself (I have taken this idea from
<a target="_blank" href="http://www.codeproject.com/dotnet/DotNetScript.asp">Dot
Net Script</a> project).</p>
<p>Command line usage:</p>
<p><code>MyScriptHost.exe <filename> <command></code></p>
<p>where <filename> is a name of a file and <command> is one of the following:</p>
<table border="1">
<tr>
<td><code>/open</code></td>
<td>open the file for editing. This is a default behavior if no other
command is specified.</td>
</tr>
<tr>
<td><code>/compile</code></td>
<td>compile the file without execution</td>
</tr>
<tr>
<td><code>/run</code></td>
<td>compile and execute the file</td>
</tr>
<tr>
<td><code>/runandwait</code></td>
<td>compile and execute the file and keep the console window open after
execution</td>
</tr>
</table>
<p>Code file should be a C# class containing <code>public static void Main()</code> as entry point.
The only addition to pure C# code is a metatag <code><@ Reference Name="assembly name
or path" %></code> in order to define external references. Code file can
have any number of these tags at the beginning of the file.</p>
<p>MyScriptHost contains internal static class MyshDebug which has some methods
useful for debugging:</p>
<table border="1" id="table1">
<tr>
<td valign="top"><code>static void Watch(params object[] values)</code></td>
<td valign="top">Opens a watch window for specified values</td>
</tr>
<tr>
<td valign="top"><code>static void Print(object obj)</code><p><code>static void Print(object obj, int levels)</code></td>
<td valign="top">Prints object properties to console. It also allows to specify a
number of levels to print out.</td>
</tr>
</table>
<p>Watch window is a modal window and allows you to see and change properties in
PropertyGrid. Invoke tab allows you to print property value with a specified
level of details.</p>
<p><img border="0" src="http://www.andreyshchurov.com/blogimages/004_02.jpg"><img border="0" src="http://www.andreyshchurov.com/blogimages/004_03.jpg"></p>
<p> </p>
<p>This is an example of a script I used with MOSS to import news items from xml
file to SharePoint document library. </p>
<div lang='CS' class='codepane'><span class='cs-metatag'><%@ Reference Name="C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\ISAPI\Microsoft.SharePoint.dll" %></span><br/>
<span class='cs-keyword'>using</span> System;<br/>
<span class='cs-keyword'>using</span> System.Collections.Generic;<br/>
<span class='cs-keyword'>using</span> System.Diagnostics;<br/>
<span class='cs-keyword'>using</span> Microsoft.SharePoint;<br/>
<span class='cs-keyword'>using</span> Microsoft.SharePoint.Administration;<br/>
<span class='cs-keyword'>using</span> System.IO;<br/>
<span class='cs-keyword'>using</span> System.Xml;<br/>
<br/>
<span class='cs-keyword'>public</span> <span class='cs-keyword'>class</span> Class1<br/>
{<br/>
<span class='cs-keyword'>private</span> <span class='cs-keyword'>const</span> <span class='cs-keyword'>string</span> m_destNewsItemsFolder = <span class='cs-string'>@"C:\My Projects\Sharepoint Scripts\ImportNews\Items\"</span>;<br/>
<span class='cs-keyword'>private</span> <span class='cs-keyword'>const</span> <span class='cs-keyword'>string</span> m_destNewsAttachmentsFolder = <span class='cs-string'>@"C:\My Projects\Sharepoint Scripts\ImportNews\Attachments\"</span>;<br/>
<span class='cs-keyword'>private</span> <span class='cs-keyword'>const</span> <span class='cs-keyword'>string</span> m_siteUrl = <span class='cs-string'>@"http://localhost:1003/"</span>;<br/>
<span class='cs-keyword'>private</span> <span class='cs-keyword'>const</span> <span class='cs-keyword'>string</span> m_prefix = <span class='cs-string'>"newPage_"</span>;<br/>
<span class='cs-keyword'>private</span> <span class='cs-keyword'>const</span> <span class='cs-keyword'>string</span> m_pageTemplateName = <span class='cs-string'>"page1.aspx"</span>;<br/>
<br/>
<span class='cs-keyword'>public</span> <span class='cs-keyword'>static</span> <span class='cs-keyword'>void</span> Main()<br/>
{<br/>
SPSite site = <span class='cs-keyword'>new</span> SPSite(m_siteUrl);<br/>
SPWeb web = site.OpenWeb(<span class='cs-string'>"News"</span>);<br/>
<span class='cs-comment'>//MyshDebug.Watch(web);</span><br/>
SPFolder pages = web.Folders[<span class='cs-string'>"Pages"</span>];<br/>
<span class='cs-comment'>//MyshDebug.Watch(pages);</span><br/>
SPFile pageTemplate = pages.Files[m_pageTemplateName];<br/>
<span class='cs-comment'>//MyshDebug.Watch(pageTemplate);</span><br/>
<br/>
<br/>
<span class='cs-comment'>// delete old files</span><br/>
Console.WriteLine(<span class='cs-string'>"Deleting previous files..."</span>);<br/>
List<SPFile> filesToDelete = <span class='cs-keyword'>new</span> List<SPFile>();<br/>
foreach(SPFile file in pages.Files)<br/>
{<br/>
Console.WriteLine(String.Format(<span class='cs-string'>"{0}"</span>, file.Name));<br/>
<span class='cs-keyword'>if</span>(file.Name.StartsWith(m_prefix))<br/>
{<br/>
filesToDelete.Add(file);<br/>
}<br/>
}<br/>
foreach(SPFile file in filesToDelete)<br/>
{<br/>
Console.WriteLine(<span class='cs-string'>"Deleting "</span> + file.Name);<br/>
file.Delete();<br/>
}<br/>
<br/>
<br/>
<span class='cs-keyword'>string</span>[] fileNames = Directory.GetFiles(m_destNewsItemsFolder);<br/>
<br/>
<span class='cs-comment'>// Create new files first</span><br/>
<span class='cs-keyword'>for</span> (<span class='cs-keyword'>int</span> i = 0; i < fileNames.Length; i++)<br/>
{<br/>
<span class='cs-keyword'>string</span> fileName = Path.GetFileNameWithoutExtension(fileNames[i]);<br/>
fileName = m_prefix + fileName;<br/>
<span class='cs-comment'>//MyshDebug.Watch(fileName);</span><br/>
Console.WriteLine(<span class='cs-string'>"Creating "</span> + fileName);<br/>
pageTemplate.CopyTo(pages.Url + <span class='cs-string'>"/"</span> + fileName + <span class='cs-string'>".aspx"</span>, <span class='cs-keyword'>true</span>);<br/>
}<br/>
<br/>
<span class='cs-comment'>// This is to refresh file list</span><br/>
pages = web.Folders[<span class='cs-string'>"Pages"</span>];<br/>
<br/>
<span class='cs-comment'>// Upload news content to already created files</span><br/>
<span class='cs-keyword'>for</span> (<span class='cs-keyword'>int</span> i = 0; i < fileNames.Length; i++)<br/>
{<br/>
<span class='cs-keyword'>string</span> fileName = Path.GetFileNameWithoutExtension(fileNames[i]);<br/>
fileName = m_prefix + fileName;<br/>
<span class='cs-comment'>//MyshDebug.Watch(fileName);</span><br/>
Console.WriteLine(<span class='cs-string'>"Uploading "</span> + fileName);<br/>
<br/>
XmlDocument doc = <span class='cs-keyword'>new</span> XmlDocument();<br/>
doc.Load(fileNames[i]);<br/>
<br/>
<span class='cs-keyword'>string</span> body = GetNodeText(doc, <span class='cs-string'>"//body"</span>);<br/>
<span class='cs-keyword'>string</span> date = GetNodeText(doc, <span class='cs-string'>"//date"</span>);<br/>
<span class='cs-keyword'>string</span> sourceName = GetNodeText(doc, <span class='cs-string'>"//sourceName"</span>);<br/>
<span class='cs-keyword'>string</span> newsType = GetNodeText(doc, <span class='cs-string'>"//newsType"</span>);<br/>
<span class='cs-keyword'>string</span> title = GetNodeText(doc, <span class='cs-string'>"//title"</span>);<br/>
<span class='cs-keyword'>string</span>[] attachments = GetNodeTextArray(doc, <span class='cs-string'>"//attachment"</span>);<br/>
<br/>
<span class='cs-keyword'>string</span> creator = GetNodeText(doc, <span class='cs-string'>"//creator"</span>);<br/>
<span class='cs-keyword'>string</span> creatorName = GetNodeText(doc, <span class='cs-string'>"//creatorName"</span>);<br/>
<span class='cs-keyword'>string</span> author = GetNodeText(doc, <span class='cs-string'>"//author"</span>);<br/>
<span class='cs-keyword'>string</span> entity = GetNodeText(doc, <span class='cs-string'>"//Entity"</span>); //????<br/>
<br/>
SPFile newPage = pages.Files[fileName + <span class='cs-string'>".aspx"</span>];<br/>
<br/>
<br/>
<span class='cs-comment'>// adjust body</span><br/>
body = <span class='cs-string'>"<p>"</span> + body.Replace(<span class='cs-string'>"\r\n"</span>, <span class='cs-string'>"</p><p>"</span>) + <span class='cs-string'>"</p>"</span>;<br/>
<span class='cs-comment'>//MyshDebug.Watch(body);</span><br/>
<span class='cs-comment'>//break;</span><br/>
<br/>
newPage.CheckOut();<br/>
SPListItem item = newPage.Item;<br/>
item[<span class='cs-string'>"Page Content"</span>] = body;<br/>
item[<span class='cs-string'>"Article Date"</span>] = date;<br/>
<span class='cs-comment'>//item["NewsType"] = newsType;</span><br/>
item[<span class='cs-string'>"Title"</span>] = title;<br/>
item[<span class='cs-string'>"Contact Name"</span>] = author;<br/>
item.Update();<br/>
newPage.CheckIn(<span class='cs-string'>""</span>);<br/>
newPage.Publish(<span class='cs-string'>""</span>);<br/>
<span class='cs-comment'>//newPage.Versions.DeleteAllMinorVersions();</span><br/>
<span class='cs-comment'>//break;</span><br/>
}<br/>
}<br/>
<br/>
<span class='cs-keyword'>private</span> <span class='cs-keyword'>static</span> <span class='cs-keyword'>string</span> GetNodeText(XmlNode root, <span class='cs-keyword'>string</span> xpath)<br/>
{<br/>
XmlNode node = root.SelectSingleNode(xpath);<br/>
<span class='cs-keyword'>if</span> (node == <span class='cs-keyword'>null</span>)<br/>
{<br/>
<span class='cs-keyword'>return</span> <span class='cs-string'>""</span>;<br/>
}<br/>
<span class='cs-keyword'>return</span> node.InnerText;<br/>
}<br/>
<br/>
<span class='cs-keyword'>private</span> <span class='cs-keyword'>static</span> <span class='cs-keyword'>string</span>[] GetNodeTextArray(XmlNode root, <span class='cs-keyword'>string</span> xpath)<br/>
{<br/>
XmlNodeList nodes = root.SelectNodes(xpath);<br/>
List<<span class='cs-keyword'>string</span>> values = <span class='cs-keyword'>new</span> List<<span class='cs-keyword'>string</span>>();<br/>
foreach (XmlNode node in nodes)<br/>
{<br/>
values.Add(node.InnerText);<br/>
}<br/>
<span class='cs-keyword'>return</span> values.ToArray();<br/>
}<br/>
<br/>
}<br/>
</div>
I am not going to
explain how this script works. It just demonstrates the power and flexibility I
gained in development for SharePoint in restricted environment.
I started this project for fun and now it becomes a very useful tool for me.Andrey Shchurovhttp://www.blogger.com/profile/04807057547080579722noreply@blogger.com0tag:blogger.com,1999:blog-2022978557711118071.post-41628240569033688832007-05-11T20:20:00.000-07:002007-05-11T20:27:20.722-07:00Personal web site<p>Finally I opened my personal web site
<a target="_blank" href="http://www.andreyshchurov.com">www.andreyshchurov.com</a> </p>Andrey Shchurovhttp://www.blogger.com/profile/04807057547080579722noreply@blogger.com0tag:blogger.com,1999:blog-2022978557711118071.post-60402355496399986452007-03-08T14:36:00.000-08:002007-03-08T14:38:59.631-08:00Video Tutorials on SharePoint from LearnVu.comSharePointHosting.com provides on-demand access to SharePoint tutorials from LearnVu to all our SharePoint hosting customers. This is a significant value-add service to our SharePoint hosting offerings.
<a href="http://www.sharepointhosting.com/video_tutorials.html">Check it out here</a>Andrey Shchurovhttp://www.blogger.com/profile/04807057547080579722noreply@blogger.com0tag:blogger.com,1999:blog-2022978557711118071.post-24397886098772533372007-02-14T20:04:00.000-08:002008-12-11T15:25:28.309-08:00How to disable fields on EditForm.aspx. WSS 3.0 version.I had a task to disable or make read-only some of a SharePoint list fields. I did not wanted to do much development and found some very good solutions
for WSS 2.0:
<a href="http://wss.collutions.com/Lists/FAQ/DispForm.aspx?ID=118">How can I make a field read-only?</a>
<a href="http://cakriwut.wordpress.com/2006/07/31/how-can-javascripters-create-custom-editform-without-understanding-caml-and-net/">How can JavaScript’ers create custom EditForm without understanding CAML and .NET !</a>
<p>But in case with WSS3.0 these solutions do not work properly because it is
very hard to calculate edit element <b>name</b> or <b>id</b> and in my solution I use
<b>title</b>
attribute of <b>input </b>or <b>select </b> elements generated by <b>
ListFormWebPart</b> web
part:</p>
<div style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 1pt; BORDER-TOP: #cccccc 1pt solid; PADDING-LEFT: 1pt; BACKGROUND: #f5f5f5; PADDING-BOTTOM: 1pt; OVERFLOW: auto; BORDER-LEFT: #cccccc 1pt solid; WIDTH: 100%; PADDING-TOP: 1pt; BORDER-BOTTOM: #cccccc 1pt solid; HEIGHT: 150pxfont-family:Courier New;font-size:10pt;color:black;" ><pre style="MARGIN: 0px"><span style="color:blue;"><</span><span style="color:#a31515;">SELECT</span> </pre><pre style="MARGIN: 0px"><span style="color:red;">id</span><span style="color:blue;">=ctl00_m_g_4cfb4dc8_9323_4849_bbfb_95af4cc4f470_ctl00_ctl02_ctl00_ctl01_ctl00_ctl00_ctl02_ctl00_ctl00_ctl04_ctl00_Lookup</span> </pre><pre style="MARGIN: 0px"><b><span style="color:red;">title</span><span style="color:blue;">=Company</span> </b></pre><pre style="MARGIN: 0px"><span style="color:red;">name</span><span style="color:blue;">=ctl00$m$g_4cfb4dc8_9323_4849_bbfb_95af4cc4f470$ctl00$ctl02$ctl00$ctl01$ctl00$ctl00$ctl02$ctl00$ctl00$ctl04$ctl00$Lookup></span> </pre><pre style="MARGIN: 0px"><span style="color:blue;"><</span><span style="color:#a31515;">OPTION</span> <span style="color:red;">value</span><span style="color:blue;">=0</span> <span style="color:red;">selected</span><span style="color:blue;">></span>(None)<span style="color:blue;"></</span><span style="color:#a31515;">OPTION</span><span style="color:blue;">></span> </pre><pre style="MARGIN: 0px"><span style="color:blue;"><</span><span style="color:#a31515;">OPTION</span> <span style="color:red;">value</span><span style="color:blue;">=6></span>Transfield Services<span style="color:blue;"></</span><span style="color:#a31515;">OPTION</span><span style="color:blue;">></span></pre><pre style="MARGIN: 0px"><span style="color:blue;"></</span><span style="color:#a31515;">SELECT</span><span style="color:blue;">></span></pre></div>
<p>So I created a JavaScript function and placed it after the <b>ListFormWebPart</b>:</p>
<div style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 1pt; BORDER-TOP: #cccccc 1pt solid; PADDING-LEFT: 1pt; BACKGROUND: #f5f5f5; PADDING-BOTTOM: 1pt; OVERFLOW: auto; BORDER-LEFT: #cccccc 1pt solid; WIDTH: 100%; PADDING-TOP: 1pt; BORDER-BOTTOM: #cccccc 1pt solid; HEIGHT: 150pxfont-family:Courier New;font-size:10pt;color:black;" ><pre style="MARGIN: 0px"><span style="color:blue;"><</span><span style="color:#a31515;">SCRIPT</span> <span style="color:red;">language</span><span style="color:blue;">=javascript></span></pre><pre style="MARGIN: 0px"><span style="color:green;">/// <summary></span></pre><pre style="MARGIN: 0px"><span style="color:green;">/// Disables EditForm field for the specified column title</span></pre><pre style="MARGIN: 0px"><span style="color:green;">/// </summary></span></pre><pre style="MARGIN: 0px"><span style="color:blue;">function</span> DisableField(title)</pre><pre style="MARGIN: 0px">{</pre><pre style="MARGIN: 0px"> <span style="color:blue;">for</span>(<span style="color:blue;">var</span> i = 0; i < document.all.length; i++)</pre><pre style="MARGIN: 0px"> {</pre><pre style="MARGIN: 0px"> <span style="color:blue;">var</span> el = document.all[i];</pre><pre style="MARGIN: 0px"> <span style="color:green;">// find html element with specified title</span></pre><pre style="MARGIN: 0px"> <span style="color:blue;">if</span>(el.title == title)</pre><pre style="MARGIN: 0px"> {</pre><pre style="MARGIN: 0px"> el.disabled = <span style="color:blue;">true</span>; <span style="color:green;">// disable</span></pre><pre style="MARGIN: 0px"> <span style="color:blue;">break</span>;</pre><pre style="MARGIN: 0px"> }</pre><pre style="MARGIN: 0px"> }</pre><pre style="MARGIN: 0px">}</pre><pre style="MARGIN: 0px">DisableField(<span style="color:#a31515;">"Company"</span>);</pre><pre style="MARGIN: 0px">DisableField(<span style="color:#a31515;">"Site/Industry"</span>);</pre><pre style="MARGIN: 0px"><span style="color:blue;"></</span><span style="color:#a31515;">SCRIPT</span><span style="color:blue;">></span></pre></div><p> </p>
<p>And these two fields are disabled for editing.</p>
<p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-uCV0x-MwJaZ5Oir0vaLkS36Aqodxu2q2y0IAM_RNfPJk9aBIZCpyhx8521A3AIOBiULwUbvBzBvRETH7xJEuE-DTQZdh5Dyz77JGEZkqOZGCZB5CCEX4GEuyAwBtmRwBLcnRJYF7ULaG/s1600-h/2007-01.jpg"><img id="BLOGGER_PHOTO_ID_5040819074362480162" style="FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-uCV0x-MwJaZ5Oir0vaLkS36Aqodxu2q2y0IAM_RNfPJk9aBIZCpyhx8521A3AIOBiULwUbvBzBvRETH7xJEuE-DTQZdh5Dyz77JGEZkqOZGCZB5CCEX4GEuyAwBtmRwBLcnRJYF7ULaG/s320/2007-01.jpg" border="0" /></a>
</p>
<p>But this <b>ListFormWebPart</b> web part is a tricky thing and creates dropdown lists in different
way depending on amount of their items:</p>
<p>Drop down list 1:</p>
<div style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 1pt; BORDER-TOP: #cccccc 1pt solid; PADDING-LEFT: 1pt; BACKGROUND: #f5f5f5; PADDING-BOTTOM: 1pt; OVERFLOW: auto; BORDER-LEFT: #cccccc 1pt solid; WIDTH: 100%; PADDING-TOP: 1pt; BORDER-BOTTOM: #cccccc 1pt solid; HEIGHT: 150pxfont-family:Courier New;font-size:10pt;color:black;" ><pre style="MARGIN: 0px"><span style="color:blue;"><</span><span style="color:#a31515;">SELECT</span> </pre><pre style="MARGIN: 0px"><span style="color:red;">id</span><span style="color:blue;">=ctl00_m_g_4cfb4dc8_9323_4849_bbfb_95af4cc4f470_ctl00_ctl02_ctl00_ctl01_ctl00_ctl00_ctl02_ctl00_ctl00_ctl04_ctl00_Lookup</span> </pre><pre style="MARGIN: 0px"><span style="color:red;">title</span><span style="color:blue;">=Company</span> </pre><pre style="MARGIN: 0px"><span style="color:red;">name</span><span style="color:blue;">=ctl00$m$g_4cfb4dc8_9323_4849_bbfb_95af4cc4f470$ctl00$ctl02$ctl00$ctl01$ctl00$ctl00$ctl02$ctl00$ctl00$ctl04$ctl00$Lookup></span> </pre><pre style="MARGIN: 0px"><b><span style="color:blue;"><</span><span style="color:#a31515;">OPTION</span> <span style="color:red;">value</span><span style="color:blue;">=0</span> <span style="color:red;">selected</span><span style="color:blue;">></span>(None)<span style="color:blue;"></</span><span style="color:#a31515;">OPTION</span><span style="color:blue;">></span> </b></pre><pre style="MARGIN: 0px"><b><span style="color:blue;"><</span><span style="color:#a31515;">OPTION</span> <span style="color:red;">value</span><span style="color:blue;">=6></span>Transfield Services<span style="color:blue;"></</span><span style="color:#a31515;">OPTION</span><span style="color:blue;">></span></b></pre><pre style="MARGIN: 0px"><span style="color:blue;"></</span><span style="color:#a31515;">SELECT</span><span style="color:blue;">></span></pre></div>
<p>Drop down list 2:</p>
<div style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 1pt; BORDER-TOP: #cccccc 1pt solid; PADDING-LEFT: 1pt; BACKGROUND: #f5f5f5; PADDING-BOTTOM: 1pt; OVERFLOW: auto; BORDER-LEFT: #cccccc 1pt solid; WIDTH: 100%; PADDING-TOP: 1pt; BORDER-BOTTOM: #cccccc 1pt solid; HEIGHT: 150pxfont-family:Courier New;font-size:10pt;color:black;" ><pre style="MARGIN: 0px"><span style="color:blue;"><</span><span style="color:#a31515;">INPUT</span> <span style="color:red;">class</span><span style="color:blue;">=ms-lookuptypeintextbox</span> </pre><pre style="MARGIN: 0px"><span style="color:red;">onkeypress</span><span style="color:blue;">=HandleChar()</span> </pre><pre style="MARGIN: 0px"><span style="color:red;">id</span><span style="color:blue;">=Text1</span> </pre><pre style="MARGIN: 0px"><span style="color:red;">onkeydown</span><span style="color:blue;">=HandleKey()</span> <span style="color:red;">title</span><span style="color:blue;">=Site/Industry</span> </pre><pre style="MARGIN: 0px"><span style="color:red;">onfocusout</span><span style="color:blue;">=HandleLoseFocus()</span> </pre><pre style="MARGIN: 0px"><span style="color:red;">onchange</span><span style="color:blue;">=HandleChange()</span> </pre><pre style="MARGIN: 0px"><span style="color:red;">value</span><span style="color:blue;">="Transfield Services Generic Documents"</span> </pre><pre style="MARGIN: 0px"><span style="color:red;">name</span><span style="color:blue;">=ctl00$m$g_4cfb4dc8_9323_4849_bbfb_95af4cc4f470$ctl00$ctl02$ctl00$ctl01$ctl00$ctl00$ctl03$ctl00$ctl00$ctl04$ctl00$ctl01</span> </pre><pre style="MARGIN: 0px"><b><span style="color:red;">choices</span><span style="color:blue;">="ACT Housing TFM Contracts232ADI Alliance - FFG Refit &amp; Upgrade Project6...<here goes a very long list of choices>"</span></b> </pre><pre style="MARGIN: 0px"><span style="color:red;">match</span><span style="color:blue;">=""</span> <span style="color:red;">optHid</span><span style="color:blue;">="SPSite_x002F_Industry_Hidden"</span> </pre><pre style="MARGIN: 0px"><span style="color:red;">opt</span><span style="color:blue;">="_Select"></span></pre><pre style="MARGIN: 0px"><span style="color:blue;"><</span><span style="color:#a31515;">IMG</span> </pre><pre style="MARGIN: 0px"><span style="color:red;">style</span><span style="color:blue;">="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; VERTICAL-ALIGN: middle; BORDER-RIGHT-WIDTH: 0px"</span> </pre><pre style="MARGIN: 0px"><b><span style="color:red;">onclick</span><span style="color:blue;">="ShowDropdown('ctl00_m_g_4cfb4dc8_9323_4849_bbfb_95af4cc4f470_ctl00_ctl02_ctl00_ctl01_ctl00_ctl00_ctl03_ctl00_ctl00_ctl04_ctl00_ctl01');"</span></b> </pre><pre style="MARGIN: 0px"><span style="color:red;">alt</span><span style="color:blue;">="Display lookup values"</span> </pre><pre style="MARGIN: 0px"><span style="color:red;">src</span><span style="color:blue;">="INFORM%20Documents%20-%20TMB-0000-SA-9898_files/dropdown.gif"></span></pre></div>
<p>Thus dropdown list 2 is made of text box and image button which should be
disabled as well.</p>
<p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiePCZ7Y7F8ADLR5KK0nxewiLNQi2_cQptCEPCWgkcn8G6-cBJTnUoTxlPWHySHY4UbD54oA3SszSjOrKZZdEqzAH6AO3Qn8KDZ5aJqkCQJw4h5T0LHhoQl2MUKo0nPwOnIYAN3i5Vk1jLc/s1600-h/2007-02.jpg"><img style="cursor:pointer; cursor:hand;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiePCZ7Y7F8ADLR5KK0nxewiLNQi2_cQptCEPCWgkcn8G6-cBJTnUoTxlPWHySHY4UbD54oA3SszSjOrKZZdEqzAH6AO3Qn8KDZ5aJqkCQJw4h5T0LHhoQl2MUKo0nPwOnIYAN3i5Vk1jLc/s320/2007-02.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5040819525334046258" /></a>
</p>
<p> </p>
<p>This image button can be found by control id of a text box mentioned in <b>
onclick</b> event handler which uses this id in ShowDropdown function call. So
this button can be found by content of <b>onclick</b> attribute. Since
collection of elements in <b>document.all</b> places elements in order of their
declaration in document then we do not need to search all this image button in
all the elements but instead of this can check the next element after the have
just found element.</p>
<p>Disable field javascript version 2:</p>
<div style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 1pt; BORDER-TOP: #cccccc 1pt solid; PADDING-LEFT: 1pt; BACKGROUND: #f5f5f5; PADDING-BOTTOM: 1pt; OVERFLOW: auto; BORDER-LEFT: #cccccc 1pt solid; WIDTH: 100%; PADDING-TOP: 1pt; BORDER-BOTTOM: #cccccc 1pt solid; HEIGHT: 150pxfont-family:Courier New;font-size:10pt;color:black;" ><pre style="MARGIN: 0px"><span style="color:blue;"><</span><span style="color:#a31515;">SCRIPT</span> <span style="color:red;">language</span><span style="color:blue;">=javascript></span></pre><pre style="MARGIN: 0px"><span style="color:green;">/// <summary></span></pre><pre style="MARGIN: 0px"><span style="color:green;">/// Disables EditForm field for the specified column title</span></pre><pre style="MARGIN: 0px"><span style="color:green;">/// </summary></span></pre><pre style="MARGIN: 0px"><span style="color:blue;">function</span> DisableField(title)</pre><pre style="MARGIN: 0px">{</pre><pre style="MARGIN: 0px"> <span style="color:blue;">for</span>(<span style="color:blue;">var</span> i = 0; i < document.all.length; i++)</pre><pre style="MARGIN: 0px"> {</pre><pre style="MARGIN: 0px"> <span style="color:blue;">var</span> el = document.all[i];</pre><pre style="MARGIN: 0px"> <span style="color:green;">// find html element with specified title</span></pre><pre style="MARGIN: 0px"> <span style="color:blue;">if</span>(el.title == title)</pre><pre style="MARGIN: 0px"> {</pre><pre style="MARGIN: 0px"> el.disabled = <span style="color:blue;">true</span>; <span style="color:green;">// disable</span></pre><pre style="MARGIN: 0px"> </pre><pre style="MARGIN: 0px"> <span style="color:green;">// if the next element has a reference to the current element</span></pre><pre style="MARGIN: 0px"> <span style="color:green;">// then disable if as well</span></pre><pre style="MARGIN: 0px"> <span style="color:blue;">if</span>(i < document.all.length - 1)</pre><pre style="MARGIN: 0px"> {</pre><pre style="MARGIN: 0px"> <span style="color:blue;">var</span> el2 = document.all[i + 1];</pre><pre style="MARGIN: 0px"> <span style="color:blue;">if</span>(el2.outerHTML.indexOf(el.id) > 0)</pre><pre style="MARGIN: 0px"> {</pre><pre style="MARGIN: 0px"> el2.disabled = <span style="color:blue;">true</span>;</pre><pre style="MARGIN: 0px"> }</pre><pre style="MARGIN: 0px"> }</pre><pre style="MARGIN: 0px"> <span style="color:blue;">break</span>;</pre><pre style="MARGIN: 0px"> </pre><pre style="MARGIN: 0px"> }</pre><pre style="MARGIN: 0px"> }</pre><pre style="MARGIN: 0px">}</pre><pre style="MARGIN: 0px">DisableField(<span style="color:#a31515;">"Company"</span>);</pre><pre style="MARGIN: 0px">DisableField(<span style="color:#a31515;">"Site/Industry"</span>);</pre><pre style="MARGIN: 0px"><span style="color:blue;"></</span><span style="color:#a31515;">SCRIPT</span><span style="color:blue;">></span></pre></div>Andrey Shchurovhttp://www.blogger.com/profile/04807057547080579722noreply@blogger.com16