system.kanoa.lot.unlinkLotOperationAsset
Description
Unlinks an asset from a lot operation. The function attempts to delete the link record; if deletion fails, it disables the link instead.Syntax
unlinkLotOperationAsset(lotOperationAssetLinkId, userId)Parameters:
– lotOperationAssetLinkId (int): The ID of the asset-operation link to remove.
– userId (int): User performing the unlink operation.
Returns:
– message (string): Indicates the result of the action. Returns either “Deleted”, “Disabled”, or an error message if the link could not be found.
Behavior
The function:– Checks if the provided link ID exists in mes.lotOperationAssetLink.
– Attempts to delete the link record from the database.
– If deletion fails (for example, due to referential constraints), disables the link instead via system.kanoa.lot.enableLotOperationAssetLink().
– Returns “Deleted” if removed successfully, “Disabled” if disabled, or an error message if not found.
Parameters
Parameter | Type | Required | Notes |
---|---|---|---|
lotOperationAssetLinkId | int | Yes | ID of the lot-operation-to-asset link record to remove |
userId | int | Yes | User performing the unlink operation |
Code Examples
# Delete a specific lot-operation-to-asset link
lotOperationAssetLinkId = 305
message = system.kanoa.lot.unlinkLotOperationAsset(
lotOperationAssetLinkId=lotOperationAssetLinkId,
userId=123
)
print(message) # "Deleted" or "Disabled"
# Attempt to unlink a non-existent link
message = system.kanoa.lot.unlinkLotOperationAsset(
lotOperationAssetLinkId=9999,
userId=123
)
print(message) # "This asset link cannot be found"