Créer un site internet

Sharepoint REST set ShowInEditForm

fredericdietrich By On 28/11/2019

With this script you can Show / hide your field in standard sharepoint forms
ShowInDisplayForm
ShowInEditForm
ShowInNewForm
 
var xhr = new XMLHttpRequest();
var url = _spPageContextInfo.webAbsoluteUrl;
if (url === "undefined {
console.log("_spPageContextInfo.webAbsoluteUrl undefined");
url = "http://siteUrl;
}
 
xhr.open('POST', url + "/_api/web/Lists(guid'bec2b6d5-3183-4bd7-87a5-0989610b2e25')/Fields(guid'341eeecb-e5ff-447c-9cd0-84c9f00c80c6')/setShowInEditForm(true)");
xhr.setRequestHeader("Accept", "application/json; odata=verbose");
xhr.setRequestHeader("X-RequestDigest", document.getElementById("__REQUESTDIGEST").value;
xhr.setRequestHeader("X-HTTP-Method", "MERGE");
xhr.setRequestHeader("If-Match", "*");
 
xhr.onload = function () {
if (xhr.status === 200) {
var kk = JSON.parse(xhr.responseText);
console.dir(kk);
}
else {
console.dir(xhr);
alert('Request failed. Returned status of ' + xhr.status);
}
};
xhr.send();
 
see script in mode text here
 

Sharepoint REST

  • No ratings yet - be the first to rate this.