List of validation rule results in workflow
Summary: BUAmina is seeking help on how to access the results of all validation rules for a specific asset in a workflow triggered by a status change event. They want to ensure that the status change is allowed only if all validation rules are met. Grant Rollerson expresses interest in the solution to this problem. BUAmina shares their approach of splitting validation rules into multiple components and using code to handle the validations, noting a challenge in maintaining visibility of the validation results without revalidation.
Hi all
I am trying to access the results of all validation rules validating one specific asset. The idea is to have a workflow that starts on status change event, and triggers all the validation rules with the outcome of allowing the status change if all validation rules are met (valid).
I can't figure out how to get all the results at once, and not only the result of the first failed validation rule.
Any ideas?
Eleftheria Makrydaki
·1 year agoHello,
Thank you for your question; to achieve that, you can follow these steps:
Create validation rules.
Assign them to the specific asset type.
Run the validation process for the asset (his can be done either through the user interface or via an API).
Check results on the validation results page to determine if the asset passes or fails the validation.
Use the validation results to control the workflow. If the asset passes all validation rules, you can proceed with the status change. If it fails, you may need to make corrections and re-run the validation.
I hope this helps!
Grant Rollerson
·1 year ago · Editedlet me know if you solve ... keen to do the same!
BUAmina
OP1 year ago · Edited@grantrollerson1 Currently working with the code below and splitting the validation rule into multiple rules. The issue I am facing is that while the workflow won't proceed if not all rules are met (which is what I wanted) the validation results are only visible (or refreshed) if you revalidate again.
import com.collibra.dgc.core.api.component.instance.AssetApi import com.collibra.dgc.core.api.component.validation.ValidationApi import com.collibra.dgc.core.api.component.logger.LoggerApi import com.collibra.dgc.workflow.api.exception.WorkflowException // Fetch the current asset def currentAsset = assetApi.getAsset(item.getId()) loggerApi.info("AssetId has been taken:") // Initialize result flag boolean final_result = true // Run validations on the asset List validation_results = validationApi.validate(item.id) // Loop through each validation result for (result : validation_results) { if (result.getResult() == false) { final_result = false } } // If any validation failed, log and throw if (final_result == false) { loggerApi.error(errorMsg) throw new WorkflowException(errorMsg) }