0

I have a list with three content types. I need to have a calculated status column in items for all three content types. The status calculation formula is different for all the content types. Since SharePoint 2010 the content type field is also unavailable in the formulas.

Can't write server side code. Also need to filter a view on this field so I don't think JSLink would work.

Any idea how to work around this?

3 Answers 3

0

Assuming your users are entering items via the New Item form, rather than via datasheet view or inline editing, you can add JavaScript to the New Item and Edit Item forms that will retrieve the content type ID from the query string parameters (if specified) and store it in a text field on the form.

You can then reference that text field instead of referencing Content Type in your calculated column.

Assuming you add a text field to your content types named "Content Type ID" your JavaScript might look something like this:

var fieldToPopulate = document.querySelector("[title='Content Type ID']"); // Get textbox
fieldToPopulate.setAttribute("disabled","disabled"); // Prevent user from entering value
var ctid = GetUrlKeyValue("ContentTypeId"); // Get ContentTypeId from query string
if(ctid.length > 0){
   fieldToPopulate.value = ctid;
}
0

Possibly you can write some jQuery and Javascript and fix it in the browser instead of the Site Columns. It is easier to maintain and does not contain any Server Side code.

2
  • I considered that, also looked into JSLink. The thing is that I need to filter the view based on that value of this field so it must contain some value on the server side. Jan 27, 2015 at 17:17
  • Yes, why don't you do an Ajax call back to the server to retreive that specific value. For example using JSON? Jan 27, 2015 at 18:18
0

Create a new SiteColumn in each of the 3 ContentTypes with a static (unique) Text value for each (eg. the ContentType name)

Hide these SiteColumns in the 3 ContentTypes

Create a new Calculated SiteColumn where you can reference the above 3 SiteColumns and output the value you want.

Assign this Calculated Column to all 3 ContentTypes

ét voila you have a Formula referencing your ContentType

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.