Professional Documents
Culture Documents
// Use the ID from the newly created item to specify the item to be worked
req2.setWorkitemId(newWorkItemIds.get(0));
System.assertEquals(
'Approved', result2.getInstanceStatus(),
'Instance Status'+result2.getInstanceStatus());
}
}
ProcessRequest Class
The ProcessRequest class is the parent class for the ProcessSubmitRequest and ProcessWorkitemResult classes.
Use the ProcessRequest class to write generic Apex that can process objects from either class.
You must specify the Approval namespace when creating an instance of this class. The constructor for this class takes no
arguments. For example:
ProcessResult Class
After you submit a record for approval, use the ProcessResult class to process the results of an approval process.
502
Reference Apex Classes
A ProcessResult object is returned by the process method. You must specify the Approval namespace when creating an
instance of this class. For example:
The ProcessResult class has the following methods. These methods take no arguments.
ProcessSubmitRequest Class
Use the ProcessSubmitRequest class to submit a record for approval.
You must specify the Approval namespace when creating an instance of this class. The constructor for this class takes no
arguments. For example:
The following methods are unique to the ProcessSubmitRequest class. In addition to these methods, the
ProcessSubmitRequest class has access to all the methods in its parent class, ProcessRequest.
503
Reference Apex Classes
ProcessWorkitemRequest Class
Use the ProcessWorkitemRequest class for processing an approval request after it is submitted.
You must specify the Approval namespace when creating an instance of this class. The constructor for this class takes no
arguments. For example:
The following methods are unique to the ProcessWorkitemRequest class. In addition to these methods, the
ProcessWorkitemRequest class has access to all the methods in its parent class, ProcessRequest.
504
Reference Apex Community (Zone) Classes
Zones help organize ideas and answers into logical groups with each zone having its own focus and unique ideas and answers
topics. Apex includes the following classes related to a zone:
• Answers Class
• Ideas Class
See Also:
Answers Class
Ideas Class
Answers Class
Answers is a feature of the Community application that enables users to ask questions and have community members post
replies. Community members can then vote on the helpfulness of each reply, and the person who asked the question can mark
one reply as the best answer.
The following are the static methods for answers.
505
Reference Apex Classes
For more information on answers, see “Answers Overview” in the Salesforce online help.
Answers Example
The following example finds questions in an internal zone that have similar titles as a new question:
question.communityId = community.id;
ID questionId = [SELECT Id FROM Question WHERE Title = 'Testing setBestReplyId' LIMIT 1].Id;
ID replyID = [SELECT Id FROM Reply WHERE QuestionId = :questionId LIMIT 1].Id;
Answers.setBestReply(questionId,replyId);
See Also:
Apex Community (Zone) Classes
Ideas Class
Ideas Class
Ideas is a community of users who post, vote for, and comment on ideas. An Ideas community provides an online, transparent
way for you to attract, manage, and showcase innovation.
A set of recent replies (returned by methods, see below) includes ideas that a user has posted or commented on that already
have comments posted by another user. The returned ideas are listed based on the time of the last comment made by another
user, with the most recent ideas appearing first.
The userID argument is a required argument that filters the results so only the ideas that the specified user has posted or
commented on are returned.
The communityID argument filters the results so only the ideas within the specified zone are returned. If this argument is
the empty string, then all recent replies for the specified user are returned regardless of the zone.
506