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
cloud-developmentcloud-development 

Chatter Approvals

All,

 

I have some standard code in place to auto-submit cases for approval when they are created. This is working fine.

 

We are now hoping to incude the approvals in the chatter feed for the case record, as well as the approvers user feed.

 

If I remove my auto-submit code and submit the record for approval manually, it appears in the chatter feed as expected. However with code in place, it does not appear to work.

 

Code below:

 

if(c.Type=='IT - Request' && c.Status=='Open' && c.Origin == 'Web') {

List<Contact> contacts = [ select id, thus_manager__c from Contact where email =: c.suppliedEmail limit 1 ];

 

if(contacts[0].Thus_Manager__c != null) {

Approval.ProcessSubmitRequest req =  new Approval.ProcessSubmitRequest();

req.setComments('Auto submitting IT Request Case for Managers approval');

req.setObjectId(c.id);

req.setNextApproverIds(new ID[] {contacts[0].thus_manager__c} );

Approval.ProcessResult result = Approval.process(req);

} else {

c.addError('The associated contact has no manager listed - the case cannot be raised.');

}

}

 

Am I missing something obvious that I need to make Chatter work?

 

Cheers,

Andrew