REST API UpdateEntity
Good morning
I have a question about how to use the REST POST method /AgilePointServer/DataEntity/UpdateEntity
I am looking to update a value in my entity using the API, example user column place a new user.
But I don't understand how to generate the body request
-
Here is an example of how I used this API:
This helper function is used. The action parameter is optional.function updateEntity(entityName, id, data, message, action) {
debugger;
// Setup options for the API call
var options = {};
options.relativePath = "DataEntity/UpdateEntity";
options.data = {
"Target": {
"EntityName": entityName,
"PropertiesJSON": JSON.stringify(data),
"Id": id
},
"EntityName": entityName,
"EntityId": id
};
options.apiOptions = {
headers: { "Content-Type": "application/json;" }
};//Call the API with all of the options setup above
eFormHelper.agilePointAPI.post(options, (result) => {
if (result.isSuccess) {
if (action) { action(); }
alert(message);
} else {
console.log(result.error);
alert('Unable to update, an error occurred.');
}
});
}Here is an example of calling this function:
//Setup data object to send for the update to the Data Entity
var reminder = {
Description__u: $('#UpdateDescription').val(),
BeginDate__u: $('#UpdateBeginDate').val(),
EndDate__u: $('#UpdateEndDate').val(),
NumberOfDays__u: $('#UpdateIntervalNumberofDays').val(),
Status__u: $('#UpdateStatusList').val(),
Title__u: $('#UpdateTitle').val(),
ReceipientList__u: getRecipientsList(),
ReminderType__u: $('#UpdateReminderType').val(),
OwnerUsername__u: $('#UpdateOwner').val()
};
updateEntity("MaintenanceReminder__u", $('#RecordID').val(), reminder, "Updated!");
Please sign in to leave a comment.
Comments
2 comments