REST API UpdateEntity

Comments

2 comments

  • Avatar
    Shane Gilbert

    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!");

    1
    Comment actions Permalink
  • Avatar
    Christian Del Angel

    Hi Shane

    Thank you very much for the example, I will try it in my App.

    thanks again

    0
    Comment actions Permalink

Please sign in to leave a comment.