Skip to main content
Version: V3 (Ignition 8.3)

tamaki.mes.apiResponse.getInUseMessage

Description

Builds a human-readable message describing why a record could not be deleted because it is still referenced by other entities.

If the response indicates success (apiResponse["success"] is truthy) the function returns an empty string. Otherwise it reads the entityReferenceViolation list from the response's error and lists each referencing table: its name cleaned with cleanTableName: together with the number of references found.

Syntax

tamaki.mes.apiResponse.getInUseMessage(entityType, apiResponse)

Parameters

ParameterTypeNullableDescription
entityTypeStringFalseA label for the entity that could not be deleted (for example "Location"), used in the message header.
apiResponseObjectFalseAn API response object with a success flag and, on failure, an error.entityReferenceViolation list. Each violation has a tableName and a references list.

Returns

A String: empty if the response was successful, otherwise a multi-line message naming each referencing table and its reference count, for example:

Cannot delete Location referenced by
Operation: 3
Oee Configuration: 1

Code Examples

# In a delete handler: if the record is still referenced, surface why it cannot be deleted
response = system.mes.dashboard.deleteWidgetParameter(widgetParameterId)
if bool(response["success"]):
system.perspective.sendMessage('widgetParameter-delete')
else:
self.view.custom.success = tamaki.mes.apiResponse.getInUseMessage("Dashboard Widget Parameter", response)