Skip to main content
[ This file is autogenerated from apexdoc ]

AqResult

The result of an operation. Can represent any exception or set of exceptions, as well as success, failures, or warning results. Intended to be fully serializable and structured to allow programmatic analysis.

Implemented types

Aq.Formatable

Group apex/core

Constructors​

public AqResult(String type, String severity, String level, String scopeType, String source, String scope, String code, String message, Object detail, Object returnValue, Datetime resultDate, List<AqResult> subResults)​

Use AqResultBuilder to simplify AqResult creation

Usage Use AqResult as a response wrapper for your custom baseService.LightningElement LWC component. See lwc-core\main\lwc\networkService.js. Apex controller:

Example​

&#64;AuraEnabled
public static AqResult getTaskMetadata() {
try {
return new AqResultBuilder()
.setSeverity(AqResult.SEVERITY_SUCCESS)
.setReturnValue(new TaskMetadataModel())
.createAqResult();
} catch (Exception e) {
return AqResultBuilder.getBadResult(e.getMessage());
}
}
// LWC component (extending baseService.LightningElement):
// import getTaskMetadata from '&#64;salesforce/apex/YourController.getTaskMetadata';
// connectedCallback() {
// this.sfData.get(getTaskMetadata)
// .then(response => {
// this.taskMeta = response;
// })
// .catch(error => {
// this.showToast(error);
// });
// }

Fields​

Standard result types​

  • public RESULT_TYPE_VALIDATION → String
  • public RESULT_TYPE_SHIELDED → String
  • public RESULT_TYPE_DML_ROW_DETAIL → String
  • public RESULT_TYPE_SAVE → String
  • public RESULT_TYPE_DELETE → String
  • public RESULT_TYPE_UPSERT → String
  • public RESULT_TYPE_EMAIL → String
  • public RESULT_TYPE_EMAIL_ERROR → String
  • public RESULT_TYPE_DATABASE_ERROR → String

Valid severities​

  • public SEVERITY_SUCCESS → String - Success
  • public SEVERITY_INFORMATION → String - Success with information
  • public SEVERITY_WARNING → String - Success with warning
  • public SEVERITY_PARTIAL_ERROR → String - Some records succeeded and some failed
  • public SEVERITY_ABORTED → String - Never tried due to other errors
  • public SEVERITY_ROLLED_BACK → String - Would have succeeded but rolled back due to other errors
  • public SEVERITY_ERROR → String - Failure
  • public SEVERITIES_ALL → Set<String>
  • public SEVERITIES_ERROR → Set<String>
  • public SEVERITIES_ORDER → Map<String,Integer>

Valid levels​

  • public LEVEL_USER → String - Result relates directly to user actions -- end user can see details
  • public LEVEL_BUSINESS → String - Result relates to business rules -- end user can see details
  • public LEVEL_INTERNAL → String - Internal -- details should be shielded from end user
  • public LEVELS_ALL → Set<String>
  • public LEVELS_SHIELD → Set<String>

Standard scope types​

  • public SCOPE_TYPE_RECORD → String - Object record
  • public SCOPE_TYPE_FIELD → String - Object field
  • public SCOPE_TYPE_EMAIL → String

Standard codes​

  • public CODE_CREATED → String
  • public CODE_UPDATED → String
  • public CODE_DELETED → String

Other​

  • public BUSINESS_STATUS_CODES → Set<StatusCode> - Database status codes that can be considered business level not internal

Properties​

public Type → String​

Type of result, usually an exception type

public Severity → String​

AURAENABLED

Identifies severity of the result

public Level → String​

Identifies the audience that should be able to see the error details

public ScopeType → String​

Identifies the data being reported on. Could be object, field, record, etc. E.g. 'Field'

public Scope → String​

E.g. 'DocumentName__c'

public Source → String​

Identifies the source component/method.

public Code → String​

AURAENABLED

Invariant identifier for the result (vs. Message which is localized and may change)

public Message → String​

AURAENABLED

General message

public ResultDate → DateTime​

Date/time of result

public Detail → Object​

Object with additional detail, must be serializable

public ReturnValue → Object​

AURAENABLED

For use with Lightning server actions or any other case where the result needs to return a value of the operation When used, the Type field should indicate the type of the value

public SubResults → List<AqResult>​

AURAENABLED

Sub-results if relevant


Methods​

public Boolean hasError()​

Return true if has an error severity Does NOT include partial error

public Boolean severityAtLeast(String severity)​

Returns true if severity is at or worse than specified severity

public override String toString()​

Dump as text

public AqResult addSubResult(AqResult subResult)​

Convenience for adding subresult only if not null

public AqResult addSubResultAndRollup(AqResult subResult)​

Convenience for adding subresult only if not null

public void rollupSeverity()​

Go through all subresults and apply worst severity to this result. This method is never called recursively, only looks at immediate child subresults.

public String rollupSeverity(Boolean allOrNone, String successSeverity)​

Go through all subresults and apply worst severity to this result. This method is never called recursively, only looks at immediate child subresults.

public AqResult mergeResult(AqResult result)​

Merge the specified result into the current one. Use when you need to apply the result of an operation to some existing ongoing result. Essentially merges sub-results together and discards the result being merged in.

public static Boolean hasError(AqResult results)​

Returns whether any result in the list has an error. Results are allowed to be null.

public static AqResult shield(AqResult result)​

Decide whether the result details should be shown to the user, and if not, log and make generic result.

public static AqResult shield(System e)​

Shield directly from exception