Modify Custom Attributes
Custom attributes are stored as part of an item.
- Connect to the configuration web service.
- Set the unique identifiers of the required item, custom attribute, and the new values to assign.
- The example uses the AddCustomAttribute helper method to automatically create and add the custom attribute of the appropriate type, or update the existing custom attribute with the specified identifier.
- The item must be checked out and checked back in.
- The user must have write permissions to the item.
Code Sample
# Set the variables.
$itemID = 1234;
# Get the item.
$item = $xia.GET_Item($itemID, 0);
# Get the custom attributes.
$customAttributes = $item.CustomAttributes;
# Check out the item.
$xia.DO_CheckOutItem($itemID);
# Add or update the specified custom attribute.
$xia.DO_AddCustomAttribute([ref]$customAttributes, [GUID]"00b0c5f6-800a-4866-be2a-75927c50fe53", "Enhanced");
$xia.DO_AddCustomAttribute([ref]$customAttributes, [GUID]"a85b928e-bad3-4a09-84ab-ad2ff625faf2", "A12345");
# Update the item.
$item.CustomAttributes = $customAttributes;
$item.VersionDescription = "Updated custom attributes";
$xia.SET_Item($item);
# Check in the item back in.
$xia.DO_CheckInItem($itemID);