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
Raksha NarayanRaksha Narayan 

Auto Response Rule from Apex

Is it possible to create Auto Response Rule from Apex? Please let me know
SwethaSwetha (Salesforce Developers) 
HI Raksha,
What is the use case you are looking at? Basically Auto-response rules let you automatically send email responses to lead or case submissions based on the record’s attributes.

You could write a trigger for this functionality. Thanks
Raksha NarayanRaksha Narayan
I want to retrieve the existing auto response rule in my org and create new auto response rule through apex. I tried with the metadataservice but that did not help. Below is the code which I tried.
 MetadataService.MetadataPort service = createService();
         MetadataService.AutoResponseRules resprule = (MetadataService.AutoResponseRules) service1.readMetadata('AutoResponseRules', new String[] { 'AutoResponseRule' }).getRecords()[0];
         MetadataService.RuleEntry[] rulesentrylist = resprule.autoResponseRule[0].ruleEntry;
        system.debug('resprule.autoResponseRule'+resprule);
The above debug log is giving the result as null even when there are auto response rules.