Skip to main content

system.mes.location.saveLocation

Description

Creates or updates a Locations record in the system based on the provided parameters.

Syntax

system.mes.location.saveLocation(**location_data)

Parameters

ParameterTypeNullableDescription
nameStringFalseThe name of the location.
descriptionStringTrueA detailed description of the location.
parentIdString (ULID)TrueThe ULID of the parent location.
typeStringFalseThe type of the location (e.g., ENTERPRISE, COMPANY, SITE, AREA, LINE, CELL_GROUP, CELL, UNIT). Default value is ENTERPRISE.
processTypeStringFalseThe process type for the location (e.g., STORAGE, CONTINUOUS, BATCH, DISCRETE, NONE). Default value is NONE.
sortOrderIntegerTrueDetermines the display order of the location. Default value is 0.
allowNegativeInventoryBooleanTrueAllows inventory to go negative at this location. Default value is false.
storageCapacityDoubleTrueMaximum storage capacity allowed at the location.
storageCapacityUnitIdString (ULID)TrueThe ULID for the storage capacity unit to be used as the default unit of measure for this location. See unit_of_measure.
lotStorageStrategyStringTrueDefines the lot storage strategy (e.g, ALLOW_MULTIPLE, ALLOW_SINGLE_OR_THROW, MERGE_INTO_PREVIOUS, MERGE_INTO_NEW, NO_STORAGE). Default value is NO_STORAGE.
lotUseStrategyStringTrueDefines the lot usage strategy, such as FIFO or FEFO. Default value is FIFO.
pathStringTruePath of the location within the hierarchy.
idString (ULID)TrueThe ULID of the location (optional, used for updating an existing location).
notesStringTrueNotes related to the location.
enabledBooleanTrueIndicates if the location is active and enabled. Default value is true.
spare1StringTrueAdditional field for user-defined context.
spare2StringTrueAdditional field for user-defined context.
spare3StringTrueAdditional field for user-defined context.

Returns

Returns a JSON representation of the saved location.

Code Examples

# Generate the object structure for a new location object, set the name and save it
new_location = system.mes.location.newLocation()
new_location['name'] = 'Warehouse'
saved_location = system.mes.location.saveLocation(**new_location)

# Output the JSON representation of the saved location
print(saved_location)

# Generate the object structure for another new location object to update the previous location
location_data = system.mes.location.newLocation()

# Set basic attributes for the updated location
location_data['id'] = saved_location.id
location_data['name'] = 'Warehouse'
location_data['description'] = 'Main storage location for raw materials.'
location_data['type'] = 'AREA'
location_data['processType'] = 'STORAGE'
location_data['sortOrder'] = 1
# (You can continue setting other properties as needed here)

# Save the location to update it in the system
updated_location = system.mes.location.saveLocation(**location_data)

# Output the JSON representation of the updated location
print(updated_location)