Difference between revisions of "DeleteRecord"

From AgileApps Support Wiki
imported>Aeric
imported>Aeric
m (Text replace - '// Error dialog' to '// Error message')
 
(3 intermediate revisions by the same user not shown)
Line 11: Line 11:


:;recordID:The identifier of the record to delete.
:;recordID:The identifier of the record to delete.
:;params:
::* Turn off rules that might otherwise be triggered as a result of this action:
:::<syntaxhighlight lang="java" enclose="div">
params.add(PLATFORM.PARAMS.RECORD.DO_NOT_EXEC_RULES,"1");
</syntaxhighlight>


;Return:[[Result Class|<tt>Result</tt> object]]
;Return:[[Result Class|<tt>Result</tt> object]]
Line 25: Line 31:
     // Some error happened.
     // Some error happened.
     String msg = "Account could not be deleted";
     String msg = "Account could not be deleted";
     Functions.debug(msg + ":\n" + result.getMessage());  // Log details
     Logger.info(msg + ":\n" + result.getMessage(), "Delete");  // Log details
     Functions.throwError(msg + ".");                    // Error dialog
     Functions.throwError(msg + ".");                    // Error message
}
}
else  
else  

Latest revision as of 22:30, 10 September 2013

Delete a record.

Syntax

Result result = Functions.deleteRecord(String objectName, String recordID);

Parameters

objectName
The object name or identifier
recordID
The identifier of the record to delete.
params
  • Turn off rules that might otherwise be triggered as a result of this action:
params.add(PLATFORM.PARAMS.RECORD.DO_NOT_EXEC_RULES,"1");
Return
Result object
Example
This example calls deleteRecord, assigning the returned value to an instance of Result and calling Result.getCode to assign the error code to a variable which is then conditionally checked to determine the code to execute. If the call was not successful, the code calls throwError to display an error dialog.
String accountID = "";
// Some logic to populate accountID variable.
Result result = Functions.deleteRecord("ACCOUNT", accountID);
int resultCode = result.getCode();
if(resultCode < 0)
{
    // Some error happened.
    String msg = "Account could not be deleted";
    Logger.info(msg + ":\n" + result.getMessage(), "Delete");  // Log details
    Functions.throwError(msg + ".");                     // Error message
}
else 
{
    // Take other actions on successful addition
    // of the account.
}