How to get name of Custom Fields of Project Online/Project Center using REST API?
Get name of Custom Fields of Project Online/Project Center using REST API:
function getCustomFieldInfo(fieldInfo){
$.ajax({
url : _spPageContextInfo.webAbsoluteUrl+'/_api/ProjectServer/CustomFields',
type : "GET",
async : false,
headers: {
"accept": "application/json;odata=verbose",
"content-Type": "application/json;odata=verbose"
},
success: function(data) {
data.d.results.forEach(function(cosField){
if(cosField.Id == fieldInfo){
// Get Field Data using Field Id
console.log(cosField);
console.log("InternalName: "+cosField.InternalName);
console.log("Field Name: "+cosField.Name);
console.log("Description: "+cosField.Description);
}else if(cosField.Name == fieldInfo){
// Get Field Data using Field Name
console.log(cosField);
console.log("InternalName: "+cosField.InternalName);
console.log("Field Name: "+cosField.Name);
console.log("Description: "+cosField.Description);
}
})
},
error: function(error) {
console.log(JSON.stringify(error));
}
});
}
// just call the function with Field Name/Id
getCustomFieldInfo('Project Priority');
Output =
Comments
Post a Comment