[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Computed Field in SP list

Posted on 2010-08-25
9
Medium Priority
?
981 Views
Last Modified: 2012-05-10
I have need to do the exact thing described on the following page in one of our doc libraries - except I can't figure out how to add the Computed Field that is described.  Can somebody help me step by step ... would greatly appreciate it.

http://stefan-stanev-sharepoint-blog.blogspot.com/2010/05/how-to-display-all-versions-in.html 
0
Comment
Question by:sandipkharde
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 7

Expert Comment

by:arduk
ID: 33527030
You could add the computed field using powershell

The link below describes how to do this. Adding at the site collection level will mean that you can then include the column in any of the document libraries in your site collection:
http://get-spscripts.com/2010/06/create-new-site-column.html 

shouldn't be too difficult to change this script to add a column at doc lib level if you preferred - I think you would just have to change the line
$web.Fields.AddFieldAsXml($fieldXML)
to be:
$docLib.Fields.AddFieldAsXml($fieldXML)
Where $docLib is a reference to your document library.

Hope this helps!
0
 
LVL 7

Expert Comment

by:arduk
ID: 33527038
sorry, forgot to add, the $fieldXML value should be set to the schema xml of the computed field in the link you have provided (I would probably generate a new guid for the ID field as well)
0
 
LVL 8

Author Comment

by:sandipkharde
ID: 33528134
I am using MOSS 2007 not SharePoint 2010, could you pelase tell for sharepoint 2007.Thanks.
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 7

Accepted Solution

by:
arduk earned 1000 total points
ID: 33528355
the attached code is a powershell script that will create the field.

After running the code in powershell, you can edit a view, and include this column in the view.

You will need to update the code with your values for site collection URL, site name and list name.

Hope this helps.
[System.Reflection.Assembly]::Load("Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c") 

# get the site collection 
$site = new-object Microsoft.SharePoint.SPSite("http://YOURSITECOLLECTION") 

# get the web site
$web = $site.OpenWeb("YOURWEBNAME") 

# get the list in the web site and create the new field
$documentLibrary = $web.Lists["Your List Name"]
$fieldXML = "<Field ID=`"{ccccdddd-3710-4374-b433-61cb4a686c12}`" ReadOnly=`"TRUE`" Type=`"Computed`" Name=`"VersionLinkFilename`" DisplayName=`"Version link`" DisplayNameSrcField=`"FileLeafRef`" Filterable=`"FALSE`" AuthoringInfo=`"(linked to version)`" SourceID=`"http://schemas.microsoft.com/sharepoint/v3`" StaticName=`"VersionLinkFilename`" FromBaseType=`"TRUE`"><FieldRefs><FieldRef Name=`"FileLeafRef`" /><FieldRef Name=`"FileRef`" /><FieldRef Name=`"_UIVersion`" /></FieldRefs><DisplayPattern><HTML><![CDATA[<a href=`']]></HTML><HttpVDir CurrentWeb=`"TRUE`" ></HttpVDir><HTML><![CDATA[/_layouts/versionredir.aspx?FileRef=%2f]]></HTML><LookupColumn Name=`"FileRef`" URLEncode=`"TRUE`" /><HTML><![CDATA[&Version=]]></HTML><Column Name=`"_UIVersion`" /><HTML><![CDATA[`'>]]></HTML><LookupColumn Name=`"FileLeafRef`" /><HTML><![CDATA[</a>]]></HTML></DisplayPattern></Field>"
$documentLibrary.Fields.AddFieldAsXml($fieldXML)

# clean up...
$web.Dispose()
$site.Dispose()

Open in new window

0
 
LVL 8

Author Comment

by:sandipkharde
ID: 33536132
Thanks for your prompt reply..

I am aware of stsdm command I never used pawershell ...even I don't know how to execute it.

is there any other way please?
0
 
LVL 8

Author Comment

by:sandipkharde
ID: 33550210
Hi Arduk,
your code seems use ful for me.
could you please help me how can use the powershell code...how can I execute..pls help me out.
thanks in advance.
0
 
LVL 7

Assisted Solution

by:arduk
arduk earned 1000 total points
ID: 33555037
I strongly recommend that you try this out in a dev environment first:
- goto your Sharepoitn server
- create a file called createfield.ps1 and save it to (for example) c:\powershellscripts
- edit the file, and paste in the code above. Make sure you update the url of your site collection, the web site name (empty string if it is the root of the site collection), and list name
- save the file
- on your Sharepoint server go to Start->all Programs->accessories->windows powershell
- right click Windows powershell and choose "run as administrator"
- change to the directory that you saved the file to (eg cd powershellscripts)
- if you haven't used powershell before, you may need  to change the execution policy using the following command:
set-executionpolicy unrestricted
NOTE: setting to unrestricted has security implications that you should ensure you are comfortable with - you will need to research this yourself in order to make sure you are happy with this, and that it meets your company's security expectations and guidelines. I do not recommend unrestricted, but am giving you this information to ensure that this script will work.
- type .\createfield.ps1 and press enter to run the script

hope this helps
0
 
LVL 8

Author Comment

by:sandipkharde
ID: 33560802
Thanks a lot...Your rock !!!
0
 
LVL 8

Author Closing Comment

by:sandipkharde
ID: 33560812
.
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Scenario: Let’s say you have a quote worksheet in Excel that you use to work up sales figures and such for your clients. You utilize SharePoint to manage and keep track of these documents. You would like values from your worksheet to populate Sh…
SharePoint Designer 2010 has tools and commands to do everything that can be done with web parts in the browser, and then some – except uploading a web part straight into a page that is edited in SPD. So, can it be done? Scenario For a recent pr…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question