ValidateCustomProperties Activity
Purpose: This activity validates custom property values before updating them in a SolidWorks document. It checks if the provided property values meet validation rules and requirements. Use this activity to ensure data quality before performing bulk updates.
Input Properties
The custom properties as a JSON string in dictionary format. Each key is a property name and each value is the property value to validate.
Type: string
Required: Yes
Example: {"Material": "Steel", "Part Number": "PN-12345", "Revision": "A"}
Note: The JSON must be a valid dictionary/object format with string keys and string values.
Output Properties
Indicates whether all properties are valid according to validation rules.
Type: bool
Note: Returns false if any property fails validation, if the JSON is invalid, or if an error occurs during validation.
Validation error message if any. Contains details about validation failures or errors that occurred during the validation process.
Type: string
Note: If validation succeeds, this will contain: "All properties are valid." If validation fails, it will contain: "Some properties failed validation." or a specific error message.
Usage Example
Scenario: Validate custom properties before updating a document
Configuration:
- PropertiesJson: "{\"Material\": \"Steel\", \"Part Number\": \"PN-12345\", \"Revision\": \"A\"}"
Result:
- IsValid: true (if all properties are valid)
- ErrorMessage: "All properties are valid."
Scenario: Validation fails
Configuration:
- PropertiesJson: "{\"Material\": \"\", \"Part Number\": \"PN-12345\"}"
Result:
- IsValid: false
- ErrorMessage: "Some properties failed validation."
Next Steps:
If IsValid is true, proceed with BulkUpdateCustomProperties. If false, review the ErrorMessage and fix the property values.
Error Handling
Important: The activity handles errors gracefully:
- If
PropertiesJsonis null or empty,IsValidwill befalseandErrorMessagewill contain: "Properties JSON is null or empty." - If the JSON string is invalid or cannot be deserialized,
IsValidwill befalseandErrorMessagewill contain: "Validation error: {error message}" - If the properties dictionary is empty or null after deserialization,
IsValidwill befalseandErrorMessagewill contain: "No properties provided to validate." - If validation rules are not met,
IsValidwill befalseandErrorMessagewill contain: "Some properties failed validation." - Any other unexpected errors will be caught and
IsValidwill befalsewith an error message
Always check the IsValid output before proceeding with property updates. Review the ErrorMessage to understand why validation failed.
Important Notes
- This activity validates properties before updating them - use it to ensure data quality
- The JSON format must be a valid dictionary:
{"Key1": "Value1", "Key2": "Value2"} - Validation rules are enforced by the service layer - check documentation for specific validation requirements
- Use this activity in combination with BulkUpdateCustomProperties to ensure only valid data is updated
- If validation fails, review the
ErrorMessageto identify which properties need to be corrected - This is a data quality check - it helps prevent invalid data from being written to documents
- Validation is performed on the property values, not on the document itself
Related Activities
- BulkUpdateCustomProperties - Update multiple custom properties after validation
- AddOrUpdateCustomProperty - Update a single custom property
- OpenSolidWorksFile - Open a SolidWorks file to get a DocumentId
- GetActiveDoc - Get the active document ID