Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a SharePoint listview with Title, Name and Address as its columns. I am passing parameter Name in the url The url of this list view is "http://site/Lists/Listl1/ListViewl1.aspx?name=testname"

So whenever the user clicks on the "add a new item"

  1. I want the Name=testname to go and fill in the Name coloumn of the newlistform of the list.
  2. And once the Name value field is filled, I want it to be readonly.
share|improve this question
    
I can see at the very least two different questions here. To get more precise answers, it would be a good idea to put your question separately :) –  Andrey Markeev Jan 3 '12 at 23:15
add comment

3 Answers

up vote 4 down vote accepted

Since you didn't provide version information, I'm assuming that you have SharePoint 2010. So, you have two links for adding a new item there:

  1. Add new item link under the list view
  2. New Item button in ribbon

enter image description here

I reckon the most right way here is to change these two links and provide the same query string parameter ('Name') from the view page along to the New item form page.

Also, I assume that once the item with specified name has been created, the new item links should start working differently (or probably should stop working), because I anticipate that the Name value is supposed to be unique (and when the new item is created, the execution falls back to the same view page with the same Name parameter provided, and nothing would prevent the user from clicking the New item link once again...). So you will probably need some additional javascript checks here.

The first link could be modified from the XSLT (using <Xsl> tag in SharePoint Designer, and overriding the Freeform XSL template). Or probably you could consider modifying this link with javascript or jquery.

The second link could be changed using custom action, by replacing the OOTB ribbon button with your custom one (Location of the CommandUIDefinition element should be "Ribbon.ListItem.New.NewListItem").

The New item form page should be customized (probably again using SharePoint Designer), and through the generated XSLT, you can pre-set the 'Name' field control value there. Since the DataFormWebPart will use server-side controls to render field inputs, you will have to put the values into them using jquery or js, and probably hide them from the user and display a read-only text label instead of the hidden textbox.

Finally, the Update item form page should be customized either, the 'Name' field control should be switched to Display mode.

Although I admit, that the solution is not very elegant, it is all not so complicated as it might appear at the first glance, and all the work could be done within 1/2 hour. Of course, I think you understand, that this approach is far away from being secure, and advanced user could change the "readonly" field, for example by using ECMAScript Client Object Model.

share|improve this answer
add comment

spStacker see this http://spservices.codeplex.com/documentation. to get the querystring value or just use javascript. You can use Jquery to set the field to be readonly in Editform.aspx. Hope this helps Patrick

share|improve this answer
add comment

Actually about this : http://spff.codeplex.com/ Hope this helps

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.