Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Hide fields in task list (JavaScript)

$
0
0

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.


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>