none
Single calculated Site Column for multiple content types... RRS feed

  • Question

  • Hi,

    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? 

    Regards,
    Arsalan.




    Tuesday, January 27, 2015 4:27 PM

Answers

  • Hi Arsalan- to expand on Scott's answer, there are different ways you can accomplish what you want using a SharePoint Designer workflow. If you want to use a calculated column, you should have the workflow copy the info from the content type field to another text column. Then create the calculated column based off that.

    cameron rautmann

    • Marked as answer by Eric Tao Tuesday, February 10, 2015 2:15 AM
    Tuesday, January 27, 2015 9:29 PM
  • workflow.

    Scott Brickey
    MCTS, MCPD, MCITP
    www.sbrickey.com
    Strategic Data Systems - for all your SharePoint needs

    • Marked as answer by Eric Tao Tuesday, February 10, 2015 2:15 AM
    Tuesday, January 27, 2015 8:23 PM
  • As long as your users are entering/editing items via the New Item and Edit Item forms, rather than via datasheet view or inline editing, you can add JavaScript to the forms that will retrieve the content type ID from the query string parameters 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.setAttribute("value",ctid);
    }

    If you have access to create SharePoint Designer workflows, then copying the content type to another field would accomplish the same thing, while also allowing users to edit items in datasheet view/inline editing. Again, you would just update your calculation to reference the new field instead of referencing the Content Type.
    • Edited by thriggle Tuesday, January 27, 2015 10:51 PM
    • Marked as answer by Eric Tao Tuesday, February 10, 2015 2:15 AM
    Tuesday, January 27, 2015 9:44 PM

All replies

  • workflow.

    Scott Brickey
    MCTS, MCPD, MCITP
    www.sbrickey.com
    Strategic Data Systems - for all your SharePoint needs

    • Marked as answer by Eric Tao Tuesday, February 10, 2015 2:15 AM
    Tuesday, January 27, 2015 8:23 PM
  • Hi Arsalan- to expand on Scott's answer, there are different ways you can accomplish what you want using a SharePoint Designer workflow. If you want to use a calculated column, you should have the workflow copy the info from the content type field to another text column. Then create the calculated column based off that.

    cameron rautmann

    • Marked as answer by Eric Tao Tuesday, February 10, 2015 2:15 AM
    Tuesday, January 27, 2015 9:29 PM
  • As long as your users are entering/editing items via the New Item and Edit Item forms, rather than via datasheet view or inline editing, you can add JavaScript to the forms that will retrieve the content type ID from the query string parameters 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.setAttribute("value",ctid);
    }

    If you have access to create SharePoint Designer workflows, then copying the content type to another field would accomplish the same thing, while also allowing users to edit items in datasheet view/inline editing. Again, you would just update your calculation to reference the new field instead of referencing the Content Type.
    • Edited by thriggle Tuesday, January 27, 2015 10:51 PM
    • Marked as answer by Eric Tao Tuesday, February 10, 2015 2:15 AM
    Tuesday, January 27, 2015 9:44 PM