I have some javascript running behind my NewForm.aspx. I would like to modify a Choice field based on the Content Type being used. I can determine the Content Type by checking the parameter:


But I'm assuming this GUID will change once I move to production. So instead of hard coding this check, is there a more reliable way to get the current Content Type through JavaScript? Say, by name and not GUID

1 Answer 1


You can use below JavaScript

var clientContext = new SP.ClientContext.get_current();
var oList = clientContext.get_web().get_lists().getByTitle("ListName");

var listContentTypes = oList.get_contentTypes();
clientContext.executeQueryAsync(Function.createDelegate(this, onSuccess), Function.createDelegate(this, onFailed));

function onSuccess(sender, args) {    
    var e = listContentTypes.getEnumerator();
    while (e.moveNext()) {
        var ct = e.get_current();
        if (ct.get_name() == "ContentTypeName") {

function onFailed() {
    alert('Request Failed');

Your Answer

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

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