SPListItem.Add method bug. Always create Folder instead of Item

Namwar Rizvi
  • SPListItem.Add method bug. Always create Folder instead of Item Namwar Rizvi

    I have created a custom lookup field inherited from SPFieldLookup. It works exactly like SPLookupField but allows user to add new values. These new values gets added in the Lookup list and becomes available next time in the drop down.

    To achieve this, I am first checking the value in lookup list. If value exists then I just return the normal "ID;#Value" otherwise; I first add the new text value to the target list and then return the newly added item's "ID;#Value" pair.

    My Field is working fine if I add it in any list where "Folder" is not a default content type. For example, I can create a custom list and add my custom lookup field as a column. It works perfectly.

    The problem is with "Discussion Board". In Discussion Board, whenever user enters a new value in custom lookup column, a new item added to the lookup list, as expected, but the content type of new item is always "Folder" instead of normal "Item".

    I have tested my field with different types of list but there is no issue with anyone of them except "Discussion Board" list. I don't know why new item automatically becomes "Folder" in Target List, if field is used in "Discussion Board".

    Can anybody help? It is very urgent please!!!

  • Have you tried setting the content type to something else if it is a discussion board? Or, what about changing the ordering of the content types in the discussion board, so that something else is the default?

  • Well, there is a specific function for creating Discussions:

    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.utilities.sputility.createnewdiscussion.aspx

    and a similar one for replies:

    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.utilities.sputility.createnewdiscussionreply.aspx

    Have you tried looking at this in Reflector? Are you specifying a content type?

Tags
custom-field-types discussion-board
Related questions and answers
  • So I did create on an SPWeb 20 custom lists and then a tasks list. For each of those 20 lists I've created 20 site lookup columns. I then created 20 Content Types based on Task content type. Then I've added each content type to the Tasks list. After that I've added each lookup site column to the corresponding list content type. So far so good. I've built a custom WebPart that displays task items...); Update: I've built a C# console app which creates all lists / lookup columns / content types and add the lookup column to corresponding content type. Result: same thing, same magic number 13. Anyone

  • . Scoped to Site. Registration: contains a ListTemplate and a ListInstance that just modifies a basic Custom List to enable content types and add my custom content type. Scoped to Web. Here's what's happening. When I activate ContentTypes, the content type and field are deployed as expected into my site collection. When I activate Registration, the list is provisioned and the content type is added as expected. When I try to add a new item to the list, the list form only shows the Title field from Item. Now, here's the weird part. If I add a second content type to the list (through the UI

  • I have a document library using a document set content type. I can create a new document set through the UI and it works perfectly. I'm now trying to create a document set in this library... for the set looks like a folder instead of the document set icon clicking on the document set doesn't show the document set home page, it just behaves like a normal document library running CAML queries shows that both internal fields HTML File Type and ProgId should be SharePoint.DocumentSet but instead they are blank changing a field value on the document set folder doesn't propogate to its contents

  • I have created a recursive query that contains 2 multi user fields. After much thrashing, where I would add the and had my query return no results, I found that the FieldRef needed to include Nullable="TRUE" and Type="UserMulti". This works, in the query now returns the correct number of records, however the value in my 2 multi user fields is empty. <View> <Webs Scope="Recursive...; <FieldRef Name="ID" /> <!-- Field which do not return values --> <FieldRef Name="Responsible" Nullable="TRUE" Type="UserMulti" /> <FieldRef Name="Accountable

  • lists (UserInfo table in the Content database). You then validate list of resolved users and copy some of them to another node in the primary data source. The field displays copied contacts as a concatenated string. Your logic works when tested in the rich InfoPath client. Resolved contacts are not copied when tested with Internet Explorer. IE does more postbacks than other browsers. In my... the Contact Selector Control I can add that it is rendered in the browser (Firefox) as HTML table, div and span elements handling events with functions declared in Core.js for all ContactPicker controls

  • content type. Each of the derived content types have custom form rendering templates. I am using a custom usercontrol with codebehind added to the .ascx page as a control to redraw the forms differently... did on the other form. I am wondering if it is because both lists share the same type number (107) or if it might be something else. So does each list need to have a custom type number or does... changed the content type and redeployed the entire solution. There is no error message but it does not load the rendering template from the controltemplates folder. I can see that it is there and I

  • In our quest to handle some requirements to levelize the type of data users are adding to Sharepoint, we have come up with the idea that we need to add a choice field to all existing content types to categorize each item/document/discussion as to the level of data it contains at the item level. This should ensure that when a user creates a new custom list or new task etc this field... and then somehow be added to all the content types or even the base content type. It seems that if you can add it to the 0x base content type it should work. Can this be done?

  • I'm pretty new to SP, but I had to bite the bullet and create a custom new form for a custom list schema. I mirrored the field structure with textboxes and such, added some custom javascript, validators and business logic, but my problem is that Sharepoint keeps injecting the old ListFormWebPart into my page. I can set the WebPartZone's Visible property to false and thus hide it, but I'd like to get rid of it altogether. Not to mention that, since its fields are all empty, my Page.Valid property will always return false. Is there some code snippet that will do this job for me?

  • I can create a CQWP for the Announcement content type, but when I export the .webpart and add <property name="CommonViewFields" type="string">Expires,Date;Body,text</property> In my ItemStyles.xsl I have added this to show all the returned fields <xsl:template name="ShowXML" match="Row[@Style='ShowXML']" mode="itemstyle"> <xsl:for-each select="@*"> <br...; But Body always comes back blank. I have two site collections; one to test and one for production. The Test collection works and returns the body of the announcement, but the Production does

Data information