system.kanoa.lot.linkLotOperationsAssets
Description
Links a list of assets with a list of lot operations. If a link already exists, it is re-enabled; otherwise, a new link record is created.Syntax
linkLotOperationsAssets(assetIdList, lotOperationIdList, userId)Parameters:
– assetIdList (list[int]): List of asset IDs to link.
– lotOperationIdList (list[int]): List of lot operation IDs to link.
– userId (int): User performing the linking operation.
Returns:
– recordsModified (int): Number of links created or re-enabled.
– message (string or None): None if success; error details on failure.
Behavior
The function iterates through all combinations of the provided asset and lot operation IDs:– If a link already exists in mes.lotOperationAssetLink, the link is re-enabled and updated with the user and timestamp.
– If no link exists, a new record is inserted with the enabled flag set to True.
– Returns the total number of links created or updated.
Parameters
Parameter | Type | Required | Notes |
---|---|---|---|
assetIdList | list[int] | Yes | List of asset IDs to link to lot operations |
lotOperationIdList | list[int] | Yes | List of lot operation IDs to link to assets |
userId | int | Yes | User performing the link operation |
Code Examples
# Link multiple assets to multiple operations
assetIdList = [101, 102, 103]
lotOperationIdList = [5, 6]
recordsModified, msg = system.kanoa.lot.linkLotOperationsAssets(
assetIdList=assetIdList,
lotOperationIdList=lotOperationIdList,
userId=123
)
print(recordsModified, msg)
# Link a single asset to a single operation
assetIdList = [42]
lotOperationIdList = [9]
recordsModified, msg = system.kanoa.lot.linkLotOperationsAssets(assetIdList, lotOperationIdList, 123)
print(recordsModified, msg)