SharePoint 2010: RemoveFieldRef and Inherits="TRUE" - sharepoint-2010

I have created a custom content type that inherits from the OOTB SharePoint Picture content type. The only customisations I have made is to add a simple URL field, and remove two of the fields on the base type. See below:
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<!-- Parent ContentType: Picture (0x010102) -->
<ContentType ID="0x0101020027f16ab27e6e45a6848c25c47aaa7053"
Name="Custom Picture"
Description=""
Group="Custom"
Inherits="TRUE"
Version="0">
<FieldRefs>
<RemoveFieldRef ID="{b66e9b50-a28e-469b-b1a0-af0e45486874}" Name="Keywords" />
<RemoveFieldRef ID="{a5d2f824-bc53-422e-87fd-765939d863a5}" Name="ImageCreateDate" />
<FieldRef ID="{c29e077d-f466-4d8e-8bbe-72b66c5f205c}" Name="URL" DisplayName="URL" Required="FALSE" />
</FieldRefs>
</ContentType>
</Elements>
If I create a picture library based on my custom content type, the "URL" field that I added appears in the new/edit forms, however the two fields that I have attempted to remove are also displayed, i.e. the RemoveFieldRef's are being ignored. If I look at the content type in "Site Settings -> Content Type Gallery", these two fields are still listed there.
Setting Inherits="FALSE" on my custom content type (see MSDN definition) successfully removes just these two fields from the "Site Settings -> Content Type Gallery" page, however then none of the base fields are displayed in the new/edit forms -- only my custom "URL" field.
What can I do to ensure that all the fields from the base "Picture" content type are displayed on the new/edit forms of my picture library except the two fields that I have specifically removed?

I believe the nature of this issue to be the understanding of how content type inheritance works.
From MSDN (http://msdn.microsoft.com/en-us/library/aa544268.aspx)
If Inherits is TRUE, the child content type inherits all fields that are in the parent, >including fields that users have added.
If Inherits is FALSE or absent and the parent content type is a built-in type, the child >content type inherits only the fields that were in the parent content type when >SharePoint Foundation was installed. The child content type does not have any fields that >users have added to the parent content type.
If Inherits is FALSE or absent and the parent content type was provisioned by a sandboxed >solution, the child does not inherit any fields from the parent.
I think the key phrase above is "If Inherits is TRUE, the child content type inherits ALL fields that are in the parent including fields that users have added."
This means that in order to accomplish what you set out to do you will have inherits set to false and you will have to include FieldRef elements for all fields you wish to use in your content type.
You make no reference / don't include code for how the content type was added to your list instance. Make sure this has been updated to support the removal or setting of inherits to false.
These sites support what is described here.
http://kvdlinden.blogspot.com/2011/06/issues-with-removefieldref-and.html
http://nelsonlamprecht.wordpress.com/2010/08/25/sharepoint-2010-removefieldref-and-inherits%E2%80%9Dtrue%E2%80%9D/

Related

OpenERP. Add image into field dynamically in a tree view

I am using v7 and I want to show in a tree view a field with image icons (like a semaphore) depending of other field values in the same row.
Actually, I get the functionality I want with a function field and put the result as string but I really want it as an image. I don't know if is possible to return HTML from the function so I decided to do that with jQuery.
I implemented the jQuery code using the browser console and works but when I put the jQuery code in the view the "data-field" selector does not selected.
Please, can anyone explain me why or tell me another way to get my objective?
Lists
The root element of list views is tree. The list view's root can have the following attributes:
editable, default_order, colors, fonts, create, edit, delete, on_write, string
See more about ListView
You can achieve this by defining child elements button in list view.
I have added icon in product to show whether product is available / hold / sold based on product's status.
button
icon: icon to use to display the button
Xml code to display icon in listview.
<xpath expr="//notebook/page[#string='Order Lines']/field[#name='order_line']/tree[#string='Sales Order Lines']/field[#name='product_id']" position="before">
<field name="product_status" invisible="1" />
<button icon='Hold' readonly="1" attrs="{'invisible':[('product_status', '!=', 'hold')]}"/>
<button icon='Available' readonly="1" attrs="{'invisible':[('product_status', '!=', 'available')]}"/>
<button icon='sold' readonly="1" attrs="{'invisible':[('product_status', '!=', 'sold')]}"/>
</xpath>
NOTE
Remember base field on which you defined button's visibility must be
present on listview, doesn't matter whether it's visible or not but it
must be there, like product_status in above example.
base field must be store=True.
Why store=True ?
Reason: when you set any function field store=True then it will physically created in database, while you give this field name in
domain the odoo framework add this field directly in WHERE clause,
it will not access through browsable object, so if your field is
store=False then it won't be able to find that field and gives you an error.
icons must be present in web/static/src/img/icons.
if you want to keep icons in your custom module then you have to create the same hierarchy for that in side your module folder create /static/src/img/icons and keep all the icons there.
xpath is used to define at which location you want to add/update fields.
See more about xpath

How can I pass a context (in a view, in a field tag) from another field's value?

I want to create a many2one field which, in view, passes a context:
<field name="my_m2o_field" context="{'foo': 'bar'}" />
The goal here is to affect the related view (i.e. When you click on "Create and Edit" in a dropdown, you get a popup rendered by the related object's current view).
Such field tag works as expected if, in context, I have something like "{'default_code': 'my.code'}", provided code field exists in the related object.
However, the context I actually need is too large (20 entries), and I have to generate 5 contexts like that (with a minor diference, since I have 5 similar fields).
I would like to wrap the context in a -non-storable- functional field (I'd need, actually, 5 similar functional fields), and pass such context as value for the context attribute:
<field name="my_context_field" invisible="1" />
<field name="my_m2o_field" context="my_context_field" />
Is it possible? What type should I use (type= argument in the function constructor).

Accessing 'Modified By' field in a reusable workflow

I'm creating a reusable workflow in SharePoint designer 2010. I've created a custom content type with all the necessary fields that I'll be used in the workflow. But I'm not able to get the Modified By field (Editor) inside the workflow.
<FieldRef ID="{d31655d1-1d5b-4511-95a1-7a09e9b75bf2}" ReadOnly="TRUE" Name="Editor" DisplayName="Last Updated By" FromBaseType="TRUE" Required="FALSE" PITarget="" PrimaryPITarget="" PIAttribute="" PrimaryPIAttribute="" Aggregation="" Node="" />
I really doubt whether the ID is matching with the inbuilt editor field. How can I cross-verify this? Any ideas?
Not sure but do you really need to include it explicitly? Editor is part of base content type : Item, and down the hierarchy all other content types should be inheriting it without the need to explicitly include it.
Regards,
Nitin Rastogi

When does SPMetal generate EntityRef properties for lookup fields?

I have a defined a content type called SPVideoDataItem containing those two fields:
<Field ID="{487F2AD6-D9D6-47AA-AA99-B3FFF893E689}" Name="LUVideoQuality" Group="Custom Columns" Type="Lookup" DisplayName="Video Quality" List="Lists/GlobalVideoQualityList" ShowField="Title" PrependId="TRUE" ShowInEditForm="TRUE" ShowInNewForm="TRUE"/>
<Field ID="{F348A825-764D-41EE-AF92-8CF1DC246E47}" Name="LUVideoTitle" Group="Custom Columns" Type="Lookup" DisplayName="Video Title" List="Lists/VideoItemList" ShowInEditForm="TRUE" ShowInNewForm="TRUE" ShowField="VideoItemTitle" PrependId="TRUE" Required="TRUE"/>
For LUVideoQuality I get a property in a class called VideoItemDataListSPVideoDataItem:
public SPVideoQualityItem VideoQuality
which exposes a EntityRef-Member, so I can access all properties of SPVideoQualityItem.
However, for LUVideoTitle spmetal just generates two properties in the parent class SPVideoDataItem
public string VideoTitleVideoItemTitle
public System.Nullable<int> VideoTitleId
where I can only access title and ID.
I wonder why spmetal handles this two lookups differently. Can anyone explain this behaviour? I would prefer that all lookups are handled like LUVideoQuality in my example.
I've encountered the same issue.
When I let go of the principle to create a separate content type and just created a list based on content type Item it did generate the entity refs.
Apparently it has something to do with the "WebId" property of the lookup fields. A colleague told me that they got it working by adding
WebId="~sitecollection"
to all lookup fields in the content type definitions (Elements.xml). Im not marking this as an answer because I did not check if it is working now because of this attribute or some other change in the definitions.

in struts where can we find the property_name of <bean:write name="name" property="property_name" />

I am new to struts and i am viewing an example of struts project and it has a table in which it has various number of data and to obtain that data from the data base it uses the code in the place of field to gain the data from database but i didn't see the name main_actvt_name which is the property anywhere.where can i find that in the action or in the form or in the jsp file.Guys help me out