Hello, I have two content types in task list "Aufgaben" and "WorkfowAufgaben". I must hide few field in first content type, programmatically from JavaScript. How can I achive this?
I tried with this code:
function hideTaskListFields() {
var appContextSite = new SP.AppContextSite(context, hostweburl + "/" + subWebUrl);
var field = new SP.Field(context);
field = appContextSite.get_web().get_lists().getByTitle("Aufgaben").get_fields().getByInternalNameOrTitle("DueDate");
field.set_hidden(true);
field.update();
field = appContextSite.get_web().get_lists().getByTitle("Aufgaben").get_fields().getByInternalNameOrTitle("Description");
field.set_hidden(true);
field.update();
context.load(field);
context.executeQueryAsync(hideTLFSuccess, hideTLFFail);
}
function hideTLFSuccess() {
alert("fields success hidded");
}
function hideTLFFail(sender, args) {
alert(args.get_message());
}But this not working for me in content type's settings next to that fields is checked "optional", not "hidden". Fields was hidded only in default view, don't displayed in it. I want hide their in first of content types.
Please help.