function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Hardy Vardès Tsialoungou NkoukaHardy Vardès Tsialoungou Nkouka 

to get validation rules and workflows for a Sobject

Hi !

I want to get validation rules for each Sobject (Account). I try this code :
List<ValidationRuleWrapper> vrs = new List<ValidationRuleWrapper>();
        ToolingAPIWSDL.QueryResult qr =
            toolingApi.query('Select Fullname, metadata From ValidationRule WHERE TableEnumOrId=\''+'Account+'\' '','ToolingAPIWSDL.ValidationRule');
        for(ToolingAPIWSDL.ValidationRule vr : (List<ToolingAPIWSDL.ValidationRule>)qr.records){
            ValidationRuleWrapper vrw = new ValidationRuleWrapper(vr);
        validationRules = vrs;
But it does'nt work.

About workflows, ilt works but when Sobject does'nt exist or when le returned list is empty, visualforce returns an erreur.
this my code :

public List<WorkflowRuleWrapper> getWorkflowList (){ 
        String currentO = 'Contact';
        ToolingAPIWSDL.QueryResult qr = toolingApi.query('Select Fullname, metadata From WorkflowRule WHERE TableEnumOrId=\''+currentO+'\' ' ,'ToolingAPIWSDL.WorkflowRule');
        List<WorkflowRuleWrapper> workflowruleWrappers = new List<WorkflowRuleWrapper>();
        for(ToolingAPIWSDL.WorkflowRule wr : (List<ToolingAPIWSDL.WorkflowRule>)qr.records){
            WorkflowRuleWrapper wrw = new WorkflowRuleWrapper(wr);            
            String wrActions = '';
            for(ToolingAPIWSDLMetadata.WorkflowActionReference war : wr.metadata.actions){
                    wrActions += + '  -  ';
            wrw.actions = wrActions;
        return workflowruleWrappers;

Thanks !