Hot answers tagged

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


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


9

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


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


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

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

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

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

You can use the SPBuiltInFieldId.Author: listItem[SPBuiltInFieldId.Author] = new SPFieldUserValue(web, userId, userName); listItem.SystemUpdate(false);


4

You need to use 'DisplayFormat` SPFieldUrl fldURLImage = (SPFieldUrl)list.Fields.CreateNewField(SPFieldType.URL.ToString(), "Picture"); fldURLImage.DisplayFormat = SPUrlFieldFormatType.Image; myList.Fields.Add(fldURLImage,SPFieldType.URL, true);


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


3

Gets the user that is associated with the field value. SPFieldUserValue userValue=someValue; SPUser user = userValue.User;


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


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


3

Status workflow you can get using the following method public string GetWorkflowStatus(SPListItem item, String workFlowName) { SPWorkflowManager manager = item.Web.Site.WorkflowManager; foreach (SPWorkflow instance in manager.GetItemWorkflows(item)) { if (instance.ParentAssociation.Name == workFlowName) { foreach (...


3

In Survey list the question is a field. In order to determine whether field is a question or regular field you could utilize SourceID attribute, in case of questions its value is not http://schemas.microsoft.com/sharepoint/v3: /// <summary> /// Get questions in Survey List /// </summary> /// <param name="list"></param> /// <...


3

Try below solution, It should help (Tested & Working) function createField() { var webUrl = _spPageContextInfo.webAbsoluteUrl; var formdigestValue = $("#__REQUESTDIGEST").val(); var fieldMetadata = { __metadata: { 'type': 'SP.FieldNumber' }, 'FieldTypeKind': 9, 'Title': 'MyNumerField', 'ShowAsPercentage': true }; $.ajax ({ ...


3

ShowAsPercentage does not work in SharePoint 2013. It is supported in SharePoint Online only. You can set it in SchemaXml. Try with following request body. { "__metadata": { "type": "SP.FieldNumber" }, "Required": false, "SchemaXml": "<Field Type=\"Number\" DisplayName=\"{Your Field Name}\" Required=\"FALSE\" EnforceUniqueValues=\"FALSE\" ...


2

The Group property is a string, it's used to Group fields on the Site Columns page. If you do this through the UI it provides a default of "Custom Columns". Typically I use something descriptive for the particular customer and project, e.g. "{Customer}: {Project}"


2

Here's a function to find the lookup ID from the lookup table: public static int GetLookupIDFromList(SPWeb web, string strListName, string strLookupColumnName, string strLookupValue) { try { SPList list = web.Lists[strListName]; string strCAMLQuery = "<Where><Eq><FieldRef Name='"+...


2

Lookup fields (which user extends) supports AllowMultipleValues. Then you can do: var multi = field is SPFieldMultiChoice || (field is SPFieldLookup && (field as SPFieldLookup).AllowMultipleValues); Same for Taxonomy


Only top voted, non community-wiki answers of a minimum length are eligible