Hot answers tagged

12

AvailableContentTypes is readonly, so you need to use ContentTypes instead. $field = $web.Fields[$fieldName] $ct = $web.ContentTypes[$contentTypeName] $link = new-object Microsoft.SharePoint.SPFieldLink $field $ct.FieldLinks.Add($link) $ct.Update($true)


3

Interesting - I used this very scenario (upgrading a field from text to note) in a demo recently in a conference talk, to show off SharePoint 2010's new upgradable Features framework. In both SP2007 and SP2010, changing the type of fields which are in use is unsuppported, as you've discovered. My recommendation would be: Take a backup in case rolling ...


3

Is it correct you didn't install VS2010 SP1? After installation of SP1 I don't think it will happen again. When you're not able to install it now, you can restart Visual Studio and try to deploy the solution again.


3

According to the Docs, the best answer to me is that the AllowDuplicateValues attribute is used when defining the field in XML code while the other is used when writing .Net code.


3

Hello Michal: There is nothing out of the box that would offer that functionality. Indexes are unique on a per column-basis and each column index is independent. The ItemUpdating event receiver is the best place to do this. You could simply have the event receiver query the list to see if a duplicate record exists before the item is created or saved.


3

I had changed a field definition's property and found that the new definition was synced to the subscribing site after also republishing a content type that was using the customized site column. I did this on SharePoint 2010, and only had one content type that was using the customized site column. In this case I had changed a Date/Time field's default value ...


2

The problem is that when you create a column, the name you enter is just a constant string. SharePoint does not do translation based on known words. Internationalization is based on resource files. And while I have used resource strings with custom list definitions, I wasn't sure if they would work on lists and columns created in the browser. So tried a ...


2

Here's how to do it programatically: // Assuming list contains a SPList object string fieldID = "FieldUniqueID"; list.Fields.Add(fieldID, SPFieldType.Text, false); list.Fields[fieldID].Title = "$Resources:Example,FieldUniqueID"; list.Fields[fieldID].Update(); Note that you cannot stick "$Resources:Example,FieldNameI18N" right into Fields.Add() because ...


2

I have not tested this but try <Field Name ="aatColleague">-1;#Mathieu.Landry</Field>


2

Somewhere in your feature you have invalid GUID....check that and make it correct. Use VS create GUID option.


2

Your .cs, .ascx, .xml and .xsl files are only invoked when rendering the field, and each time the field is shown on forms & list views. The contents of the elements file will reference something in the Schema file, so the schema file is loaded first before the contents of the elements, and this is done only on Feature activation. For the rest, the ...


2

You can use UnlimitedLengthInDocumentLibrary="TRUE" attribute to enable more than 255 characters on a note field. But if you want more than 255 characters on your note field with rich text capabilities - why don't you just use an HTML field?


2

I have only seen this problem when fields were created as Number field, like <Field Type="Number" DisplayName="DemoNumber" Required="FALSE" Group=" Demo Field" ID="{1221b2d2-992d-4abf-a80a-55585c234c55}" SourceID="{e834bd2e-72bf-4aab-9ef4-4f3e118526e2}" StaticName="DemoNumber" Name="DemoNumber" Decimals="0" Percentage="FALSE"/> Did you by any chance ...


2

Could you add your field manifest? Also, what does the feature receiver do? Are you using sp2010or sp2007? I havent tried with choice fields, but setting DisplaceOnUpgrade="true" instead of owerwrite="true" for field declaration helps upgrading existing fields.


2

Have you tried this for other fields than Title? The spec for SPField.EnforceUniqueValues states that You cannot set this property to true for a built-in field or for a site column. Not 100% that this is valid for the declarative approachs for custom schemas, but test with another field "test" of type text and you will find out...


1

What you need to do to ensure that the fields you don't want to see are not exported, is create a view that shows only those fields that you want to see and export that view. As far as the "Path" that field is exported by default, and you will have to manually delete it from the excel spreadsheet.


1

Regardless of your encoding problem, updating the xml that was used to create fields will not push down the changes to existing fields based on that xml. If you want to update the DisplayName for existing fields, you would have to write some code (in a FeatureReceiver) to do this for you.


1

You are correct - InternalName and GUID must both be unique. If you don't specify an InternalName, the DisplayName will be used to generate one, and as this is the same for each, you're getting a collision. As to why the GUID as well - good question, much like why list items have both a GUID and an ID that is unique in a list. Still, it's worth noting that ...


1

Daniel is right in so far as the docs say to use AllowDuplicateValues in CAML schema and EnforceUniqueValues in code. The documentation is wrong, though; to make the CAML work you need to use the EnforceUniqueValues attribute.


1

I just ran across the same situation. I had imported some lists from SharePoint into VS2010 and saw StaticName in the definition. I never used it before. I deployed my custom lists without StaticName (and they always worked correctly), and then imported my list into VS2010, and StaticName was set. It appears SP takes care of it for you.


1

Maybe instead of using the ItemAdded event, you could try using the ItemAdding event? Example What you also could do is create a workflow on the listitem that activates when the item changed. First check if the "Issue ID" is not empty. If so, than send an email to a group. To let users subscribe to an "alert", I would create a webcontrol where users are ...


1

How I would approach this is the following: Create a custom field type http://msdn.microsoft.com/en-us/library/bb862248.aspx. This includes an xml definition and a class inheriting from SPField. Your field type would handling storing some sort of representation of the column as a string (Maybe ListName;ColumnName) and then resolving that representation to ...


1

This might be of some use. Try to get the user profile using UserProfileManager. Then using GetProfileValueCollection(PropertyConstants.PictureUrl) you can get the image url of the user.


1

Finally, we've managed to find a good solution. So, basically, in SharePoint 2013, instead of <Field Name="Employee" ID="{33c2ee31-2927-4de3-8e7d-cc1f2676378b}" DisplayName="Name" Type="User" Required="TRUE" UserSelectionMode="PeopleOnly" UserSelectionScope="0" ShowField="NameWithPicture" /> you need to use <Field Name="Employee" ...


1

in sharepoint 2010 => UserControl => CustomFieldControl protected override void OnLoad(EventArgs e) { this.Parent.Parent.Visible = true; base.OnLoad(e); if (SPContext.Current.FormContext.FormMode == SPControlMode.Edit || SPContext.Current.FormContext.FormMode == SPControlMode.New) ...


1

I figured it out. It looks like it was a SharePoint "retention" issue. It seems that retracting a solution does not truly remove everything. Using SharePoint Manager 2013, I was able to see that the Comment field was still defined in the List even though the Content Types were removed from the List and the solution was retracted. In addition, when the ...


1

For number field accepting only Integers (no decimal), do following: $spFieldType = [Microsoft.SharePoint.SPFieldType]::Number $myField = $myCustomList.Fields.Add("myInteger",$spFieldType,$false) $myIntegerField = [Microsoft.SharePoint.SPFieldNumber]$myCustomList.Fields[$myField] $myCustomList.Fields[$myIntegerField].DisplayFormat = ...


1

Try something like this SPList lista = sitio.RootWeb.Lists[listaP]; SPFieldUser columna = (SPFieldUser)lista.Fields[columnaP]; if (!columna.AllowMultipleValues) { columna.AllowMultipleValues = true; columna.Update(); }


1

Did not get your code clearly, what is fieldId and how are you getting this fieldId? my guess is location is already there in the content type you can not add the same field again, create a new field if you wish, in that case your code will be (after foreach) - string fldName = fields.Add(fieldToAdd.Title, fieldToAdd.Type, fieldToAdd.Required); SPField ...


1

I found these script, but it don't need the folder query... but there are some things in (e.g. the Caml-Query and the move function) that i need, but i dont know how i can customize These script for my idea. Donwloadlink



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