19
FieldLinkCollection.Reorder() can reorder fields in list forms. Followings are the steps of reordering fields.
Find the list
Find ContentType
Find FieldLinks of the ContentType
Reorder columns of FieldLinks
Reorder() takes an array of Internal Names of the fields. Based on the order of this array, Reorder() method reorders the fields in list forms.
...
answered Jan 3 '16 at 7:04
Atish Dipongkor - MVP
12.8k44 gold badges2727 silver badges6060 bronze badges
14
John,
Never tried this myself, but a comment is made http://msdn.microsoft.com/en-us/library/ms437580.aspx stating
"In order to allow enter multiple values into field with Type="UserMulti"
you must set attribute Mult="TRUE"."
10
You need to get the values into a collection object and then iterate through them and test it it is a group, if not assume it is a user, as follows:
SPFieldUserValueCollection objUserFieldValueCol = new SPFieldUserValueCollection(web, listitem["UserGroupField"].ToString());
for (int i = 0; i < objUserFieldValueCol.Count; i++)
{
SPFieldUserValue ...
8
You can add fields programmatically using list.Fields.AddFieldAsXml, providing CAML field definition with resource tokens in it.
Or you can wrap SetValueForUICulture in a nice helper method, and gain a capability to use it for any SPUserResource object. We're using this approach at work, and I would not say, that it is unclear or smth like this :) It's ok, ...
8
Modified: Identifies a field that contains the last modified date and time information that is associated with the specified SharePoint Foundation object.
Last_x0020_Modified: Identifies a field that contains version control
information for the last modified version of the specified SharePoint
Foundation list object.
The ‘Modified’ column as we see in the ...
7
I believe with that technique you are creating a Field object for that list but it does not actually add a column, similar to adding columns to a Datatable().
For creating fields via code I typically go with
//Add Column to list
//GUID SPList.Fields.ADD(name,type,required);
list.Fields.Add("Field Name", SPFieldType.Choice, false);
//Get Field ...
7
Yes, the short answer is you can't do anything to the field if you accidently deployed it with a version attribute. Whoops.
As this is something I've done a few times - ow - and I needed to fix, I've finally gotten around to writing a script to fix it. The script needs to remove the current field from all content types, then delete the field. Then remove ...
5
In the second content type which you may have created for the ListB specify the Inherits attribute to False for ContentType property. An then in FieldRefs section rename the Status field.
<ContentType ID="CTID"
Name="CTName"
Group="CTGroup"
Description="CTDescription"
Inherits="...
5
Using jQuery, find the nearest item with a unique identifier. Not all fields in a form have unique IDs, as you found with the date fields, which all have the id="SPFieldDateTime". The corresponding label column, however, contains the field name and this one must be unique.
Use this as your hook. You can then go to the sibling of the unique element with the ...
4
You need to return the field value in HTML/Plain text format and update it. Here you go:
SPSite site = new SPSite("http://site"))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists["YourList"];
SPListItem item= list.GetItemById(1);
SPFieldMultiLineText multilineField = item.Fields.GetField(...
4
In SharePoint 2013, client-side rendering (CSR) provides a way to control the output/design of your fields and set of controls by leveraging HTML and JavaScript technologies for example how should the fields render in list views (edit, new or quick edit), search, list forms etc. Now, every field definition comes with JSLink property that can be overridden, ...
4
One hint is to use AddRange() method to add array of strings as choices instead of adding choices with Add() one by one
string[] Choices = { "choice1", "choice2", "choice3", "choice4", "choice5" };
col.Choices.AddRange(Choices);
4
After some effort I converted it into PowerShell YAY!
[Microsoft.SharePoint.SPList] $list = $web.Lists["Stakeholders Register"];
if(($list.Fields["Job Number"] -ne $null) -and ($list.Fields["Role within project"] -ne $null)) {
$fieldReorderable = [string]::Empty;
$fieldNonReorderable = [string]::Empty;
$firstField = "...
4
You can use the SPBuiltInFieldId.Author:
listItem[SPBuiltInFieldId.Author] = new SPFieldUserValue(web, userId, userName);
listItem.SystemUpdate(false);
4
Try:
spfield.SelectionGroup = newgroup.ID;
spfield.Update();
spList.Update();
MSDN: SPFieldUser.SelectionGroup property
Sample: Programmatically Set "Person Or Group" Column To Select User From A Specified Group
answered Jul 4 '17 at 14:31
Juan Pablo Pussacq Laborde
3,32911 gold badge1010 silver badges2222 bronze badges
3
Minimum value is 1/1/1900. We have run into the minimum value issue with trying to date some documents from the 1800's. - Stackoverflow reference
3
Could be Double or Decimal or Integer.
Use the ParseAndSetValue method to make sure it converts it to Double (see here http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfieldnumber.parseandsetvalue.aspx)
3
To set a taxonomy field you should use TaxonomyFieldValue or TaxonomiFieldValueCollection
You first need to find the term in your term store:
TaxonomyField taxonomyField = item.Fields[field] as TaxonomyField;
TaxonomyFieldValue taxValues = new TaxonomyFieldValue(taxonomyField);
TaxonomySession session = new ...
3
SPFieldChoice has a property named FieldRenderingControl. Using reflector you can find this code in the FieldRedneringControl property:
....
switch (this.EditFormat)
{
case SPChoiceFormatType.Dropdown:
control = new DropDownChoiceField();
break;
case SPChoiceFormatType.RadioButtons:
control = new RadioButtonChoiceField();
...
3
Gets the user that is associated with the field value.
SPFieldUserValue userValue=someValue;
SPUser user = userValue.User;
answered Jun 1 '15 at 7:14
Sivakumar Piratheeban
1,96255 gold badges3232 silver badges5454 bronze badges
3
Have a look at SPUtility.GetLocalizedString()
3
Found a proper javascript client object model solution for my problem:
Here is the solution:
this.listFields = list.get_fields();
ctx.load(this.listFields);
And then in the function: onQuerySucceeded
var fieldEnumerator = this.listFields.getEnumerator();
while (fieldEnumerator.moveNext()) {
var field = fieldEnumerator.get_current();
...
3
The simplest way to make any field read only would be to use SPutility Jquery
You can use it like below:
SPUtility.GetSPField('Column Name').MakeReadOnly();
For the comment made by David on Dmitry Kozlov answer,
to make People picker readonly, you can use the below JQuery code:
$(".sp-peoplepicker-delImage").css({ 'display' : 'none'});
$(".sp-...
3
It sounds like you're using the ItemUpdated event. If you used ItemUpdating I believe you could modify the AfterProperties instead of performing a second update.
This may be of use to you: NBSP: Event Receivers
3
a shot in the dark here, you can try this that iv just put together?
using (SPSite site = new SPSite("url goes here"))
{
using (SPWeb oWebsite = site.OpenWeb())
{
SPList oList = oWebsite.Lists["discussion list name"];
SPListItem item = oList.GetItemById(12);
...
3
If there is a possibility of an AD group in there and you would like to handle that, have a look at my solution:
public static List<string> GetUserLogins(SPListItem item)
{
//create empty list of usernames
List<string> Users = new List<string>();
//retrieve user value collection from the "AssignedTo" field and iterate
...
3
If you want the field to appear as read-only or display than you can change its SPControlMode to Display
MyCode.ControlMode = SPControlMode.Display
answered Mar 23 '13 at 22:21
Arsalan Adam Khatri
14.3k33 gold badges2929 silver badges5252 bronze badges
3
When looping through the fields you will look for ones that are TaxonomyFields
if( fld is TaxonomyField ){
//code here for metadata fields
}
3
There is projects like SharePoint Permission Extension (http://sppex.codeplex.com) on codeplex. if you take a look at code they override CreateChildControls method of EditControlListFieldIterator which cause control of SharePoint field rendering.
Take a look at this class for example.
SharePoint Permission Extension has an application page for field ...
3
You can use the Field type HTML.
Here is a XML markup of that field:
<Field ID="{E2CC0231-FA6C-4F90-839C-118C304DFCF1}" StaticName="PMediaDescription"
Name="PMediaDescription" DisplayName="MediaDescription" Type="HTML" RichText="TRUE"
RichTextMode="ThemeHtml" Group="Site Columns" UnlimitedLengthInDocumentLibrary ="TRUE" />
the real key here is: ...
Only top voted, non community-wiki answers of a minimum length are eligible
Related Tags
spfield × 173list × 23
development × 22
column × 21
sharepoint-enterprise × 19
2013 × 18
splistitem × 15
powershell × 12
content-type × 12
sharepoint-foundation × 11
splist × 11
2010 × 10
2007 × 9
sharepoint-server × 7
event-receivers × 7
custom-field-types × 7
sharepoint-online × 6
javascript × 6
document-library × 6
visual-studio × 6
site-column × 6
calculated-column × 5
default-value × 5
csom × 4
custom-list × 4