system.kanoa.event.assetOperationChange(assetOperationInfo, userId)
Call this function whenever the mode on an asset changes. Will set all child assets to the same mode if includeChildren is true
Parameters
assetOperationInfo dict.: All keys are required unless otherwise stated.
| - assetId | Integer | |
| - checkAssetSchedule | Boolean | Not required. If true, the schedule will be checked after setting the mode. If not set, will be set to false, |
| - includeChildren | Boolean | Not required. If not set, will be set to false |
| - itemId | Integer | |
| - modeCode | Integer | |
| - setChildModeOnly | Boolean | Not required. If false, then itemId will also be set on child assets. If not set, will be set to true. |
| - standardRate | Float | Not required. If not set or None, the standardRate for the assetItem will be used. Allows the standardRate to be adjusted say based on the number of workers on the line |
| - tStamp | DateTime | |
| - workOrderId | Integer |
userId Integer:Id of the user executing the function
Returns
modeEventId Integer
message String None if successful
Example
assetOperationInfo = {
'assetId': 13,
'modeCode': 1,
'workOrderId': None,
'itemId': 3,
'standardRate': 100.0,
'modeSourceId': 1,
'tStamp': system.date.now(),
'includeChildren': True,
'setChildModeOnly': True
}
modeEventId, msg = system.kanoa.event.assetOperationChange(assetOperationInfo, userId)
if msg: system.perspective.sendMessage('showWarningToast', {'message': 'Could not change asset mode. %s'%msg})
else: system.perspective.sendMessage('showSuccessfulToast', {'message': 'Asset has been set to %s'%values['mode']})