0

I did some research on this, found bit difficult to implement the solution. Looking for easiest way/solution.

I need get related Validation Rules, Workflow Rules etc when I select an object on VF page. I may need to get those in PDF or excel, but that's other part of implementation. I did not found any difficulties while getting Objects descriptions and its field descriptions. But getting validation and Workflows seems to be little lengthy as per my finding.

Vickal
  • 592
  • 11
  • 32
  • What did you find so far in your research but didn't work for you? – Folkert Nov 16 '17 at 09:13
  • This one is the one... https://developer.salesforce.com/forums/?id=906F0000000Ai6kIAC

    And most of them are having same way of implementation, which is using Metadata API, and It requires some files to be deployed from Git. I attempted to deploy but it was unsuccessful. I'm looking for some System or Standard Methods if there is any.

    – Vickal Nov 16 '17 at 09:18
  • I'm afraid that metadata api wrapper is the only way to do it. Describe methods in Apex only give information on fields, object permissions, etc https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_sobject_describe.htm#apex_methods_system_sobject_describe – Folkert Nov 16 '17 at 09:23

1 Answers1

1

I have not tried it myself, but i hope this link can help you.

Reference : how-to-search-workflow-rules-or-validation-rules-etc-in-apex-i-e-metadata-search

This will allow you to list the Validation Rules and Workflow Rules from Apex.

   MetadataService.MetadataPort service = MetadataServiceExamples.createService();     
    List<MetadataService.ListMetadataQuery> queries = new List<MetadataService.ListMetadataQuery>();        
    MetadataService.ListMetadataQuery queryWorkflow = new MetadataService.ListMetadataQuery();
    queryWorkflow.type_x = 'WorkflowRule';
    queries.add(queryWorkflow);     
    MetadataService.ListMetadataQuery queryValidationRule = new MetadataService.ListMetadataQuery();
    queryValidationRule.type_x = 'ValidationRule';
    queries.add(queryValidationRule);           
    MetadataService.FileProperties[] fileProperties = service.listMetadata(queries, 25);
    for(MetadataService.FileProperties fileProperty : fileProperties)
        System.debug(fileProperty.fullName);
NITHESH K
  • 2,525
  • 2
  • 15
  • 43
  • It requires some files(MetadataService, MetadataServiceExamples,) to be deployed from Git. I attempted to deploy but it was unsuccessful. Do you have any idea how do we get those dependent Metadata Classes files. – Vickal Nov 16 '17 at 09:27
  • @SFDCMafia-Vickal I just tried with git-hub now, it was deployed successfully – NITHESH K Nov 16 '17 at 09:51