You need to sign in to do that
Don't have an account?

query to retrieve count of all validation rule in salesforce org
Any how can we get the count of all validation rules and workflows in salesforce org.
I tried---
private static MetadataService.MetadataPort createService()
{
MetadataService.MetadataPort service = new MetadataService.MetadataPort();
service.SessionHeader = new MetadataService.SessionHeader_element();
service.SessionHeader.sessionId = UserInfo.getSessionId();
return service;
}
MetadataService.MetadataPort service = createService();
List<MetadataService.ListMetadataQuery> queries = new List<MetadataService.ListMetadataQuery>();
MetadataService.ListMetadataQuery queryWorkflow = new MetadataService.ListMetadataQuery();
queryWorkflow.type_x = 'Workflow';
queriesWorkflow.add(queryWorkflow);
But no luck plz help its urgent
I tried---
private static MetadataService.MetadataPort createService()
{
MetadataService.MetadataPort service = new MetadataService.MetadataPort();
service.SessionHeader = new MetadataService.SessionHeader_element();
service.SessionHeader.sessionId = UserInfo.getSessionId();
return service;
}
MetadataService.MetadataPort service = createService();
List<MetadataService.ListMetadataQuery> queries = new List<MetadataService.ListMetadataQuery>();
MetadataService.ListMetadataQuery queryWorkflow = new MetadataService.ListMetadataQuery();
queryWorkflow.type_x = 'Workflow';
queriesWorkflow.add(queryWorkflow);
But no luck plz help its urgent
For workflows, you would need to list the files using the above code, and then use retreive call to get list of workflow rules.
You seem to be using Metadata API Apex Wrapper, see if you have a VF page titled "metadataretrieve" in the wrapper, if you do, try the VF page, select workflow, and click "List", then select any object that has workflow, and click "Retreive". Once you see the result, you can change and use the code in controller class.
Link to wrapper : https://github.com/financialforcedev/apex-mdapi
All Answers
For workflows, you would need to list the files using the above code, and then use retreive call to get list of workflow rules.
You seem to be using Metadata API Apex Wrapper, see if you have a VF page titled "metadataretrieve" in the wrapper, if you do, try the VF page, select workflow, and click "List", then select any object that has workflow, and click "Retreive". Once you see the result, you can change and use the code in controller class.
Link to wrapper : https://github.com/financialforcedev/apex-mdapi
MetadataService.MetadataPort service = new MetadataService.MetadataPort();
service.SessionHeader = new MetadataService.SessionHeader_element();
service.SessionHeader.sessionId = UserInfo.getSessionId();
List<MetadataService.ListMetadataQuery> queries = new List<MetadataService.ListMetadataQuery>();
MetadataService.ListMetadataQuery queryLayout = new MetadataService.ListMetadataQuery();
//queryLayout.folder = 'Ezone_dashboard/TestDashboard';
//queryLayout.folder = 'dashboards/Ezone_dashboard';
queryLayout.folder = 'Ezone_dashboard';
queryLayout.type_x = 'Dashboard';
queries.add(queryLayout);
MetadataService.FileProperties[] fileProperties = service.listMetadata(queries, 31);
if(fileProperties!=null)
{
for(MetadataService.FileProperties fileProperty : fileProperties)
{
System.debug('***************'+fileProperty.fullName);
}
}
However I am getting null response. I guess I am not able to set the folder attribute properly .. Can any body help ?
I am trying to execute the same script in developer console but getting error Invalid Type : MetadataService.MetadataPort.
Could you please suggest. It is bit urgent for me to get list of all validation rules and workflow rule in my org.
Thanks in Advance,
Bala