How are you trying to retrieve the workflow rule and status..if you will create a workflow list view you can get all status and description of all workflow rule..
You can also use tool api to query the workflow rule...Go to workbech and select REST Explore and execute below url.
You need to use tooling API if you want to query the workflow rule.. Check this sample code that may help you to get the status of an individual workflow.
Set the endpoint as your org URL in remote site setting and execute this code in developer console you will see all the attributes of workflow rule..
Public class DemoforToolingApi
{
public String returnValuestr ;
public HttpResponse response;
public Http http;
public HttpRequest request;
public DemoforToolingApi ()
{
returnValuestr = httpCalloutMethod('/services/data/v41.0/tooling/sobjects/WorkflowRule/{ID}');
System.debug('returnValuestr –> '+returnValuestr );
}
public String sToken=UserInfo.getSessionId();
public String httpCalloutMethod(String str)
{
try
{
http = new Http();
request = new HttpRequest();
String getORGURL=URL.getSalesforceBaseUrl().toExternalForm();
request.setEndpoint(getORGURL+str); //Your URI
request.setMethod('GET');
request.setHeader('Authorization', 'Bearer ' + sToken);
//if the request and response for your REST call is JSON, use the code below.
request.setHeader('Content-Type', 'application/json');
request.setHeader('accept', 'application/json');
response = http.send(request);
return response.getBody();
}
catch(Exception e) {
System.debug('Error —-> '+e);
return null;
}
}
}
Avinash,
How are you trying to retrieve the workflow rule and status..if you will create a workflow list view you can get all status and description of all workflow rule..
You can also use tool api to query the workflow rule...Go to workbech and select REST Explore and execute below url.
--
Thanks,
Prashant
You can create a new view and in filter criteria,specify Active equals TRUE. Let me know if this helps
I am trying to get workflow information in apex code. but i am not able to get status(Active or not) in the apex code.
Is there any way to access to workflow rules from SOQL query
Check this sample code that may help you to get the status of an individual workflow.
Set the endpoint as your org URL in remote site setting and execute this code in developer console you will see all the attributes of workflow rule..
In the above example you are passing ID.Is it workflow rule ID.
If yes , It can only get one work flow details ryt?
My requirement is to get all WorkFlowRules in the org.
If you have some work arounds , Please Let me know.
If you don't want to get the details of specific workflow then just remove the id and give a try.
--
Thanks,
Prashant