Global Methods
23 min
approvals pro exposes a small set of global apex classes so you can drive approvals programmatically — from triggers, other managed packages, or custom apex use these when a flow isn't flexible enough; use invocable actions docid\ n1ojhuatlkkeigbtbigxu when a flow is enough the primary global entry points are on appro approvalutilscontroller method purpose apexapprovalsubmit(map\<string, object>) submit a record for approval updateapprovals(list\<string>, list\<string>, string, string, string) approve or reject one or more approvals (recall and reassign) see the invocable actions docid\ n1ojhuatlkkeigbtbigxu equivalents — a global apex method is exposed in 10 3x+ under the same class warning never update status c , path status c , or step status c directly via dml, flows, or data loader the global methods maintain audit history, recompute dependent steps, fire email templates, and lock/unlock records direct dml bypasses all of that and corrupts the approval state submit for approval submits a record for approval approvals pro evaluates all active approval processes on the record's object, picks the highest priority process whose entry criteria are met, and starts it signature appro approvalutilscontroller apexapprovalsubmit( map\<string, object> submitparams ); parameters key required type description recordid ✓ string the 15 or 18 character id of the record to submit processname string optional the name of a specific approval process to run if omitted, the highest priority eligible process runs use this when multiple processes exist on the object and you want to pin one example map\<string, object> submitparams = new map\<string, object>{ 'recordid' => '006xx000000abcdef', 'processname' => 'quote discount approval' }; try { appro approvalutilscontroller apexapprovalsubmit(submitparams); system debug('record submitted for approval '); } catch (exception e) { system debug('submit failed ' + e getmessage()); } behavior notes if no active approval process on the object matches the record's entry criteria, the call throws an exception wrap the call in a try/catch if the record is already in a pending approval, the call is a no op (no new request is created) the running user must have the submitrecordforapproval custom permission without it, the call fails approve / reject resolves one or more appro approval c records as approved or rejected use this to auto approve quick approval paths, build rubber stamp buttons, or implement bulk approval for a supervisor role signature appro approvalutilscontroller updateapprovals( list\<string> approvalids, list\<string> piwilist, string message, string status, string approveruserid ); parameters parameter required type description approvalids ✓ list\<string> record ids of appro approval c records to resolve status ✓ string 'approved' or 'rejected' case sensitive approveruserid ✓ string user id recorded as the approver usually userinfo getuserid() ; can be a different user id for delegated or system approvals piwilist list\<string> optional standard salesforce process instance work item ids, if you're also resolving standard salesforce approvals in the same call pass an empty list if unused message string optional approval / rejection comment saved on the appro approval c 's message field required if the step has make approval message required or make rejection message required set example — approve list\<string> approvalids = new list\<string>{ 'a0axx0000001abcdef' }; list\<string> piwilist = new list\<string>(); string message = 'approved — within policy'; string status = 'approved'; string approveruserid = userinfo getuserid(); try { appro approvalutilscontroller updateapprovals( approvalids, piwilist, message, status, approveruserid ); } catch (exception e) { system debug('approve failed ' + e getmessage()); } example — reject appro approvalutilscontroller updateapprovals( new list\<string>{ approvalid }, new list\<string>(), 'rejected — discount exceeds policy cap', 'rejected', userinfo getuserid() ); behavior notes the approveruserid must be an active user if it isn't, the call throws if the approval is already resolved, the call is idempotent (no op, no error) the decision fires any step, path, and process level emails registered for the rejected / approved transition recall available in 10 3x+ invokes a recall on a pending approval request use this to auto recall when the submitted record materially changes (e g , the quote amount is edited while an approval is pending) signature appro approvalutilscontroller apexapprovalrecall( map\<string, object> recallparams ); parameters key required type description recordid ✓ string id of the submitted record to recall example appro approvalutilscontroller apexapprovalrecall( new map\<string, object>{ 'recordid' => quote id } ); behavior notes only recalls pending requests by default to recall an approved request as well, set the org wide allowrecallofapprovedrecord custom setting to true see permissions → custom settings docid\ ystatgnrufhelmt mgduc the running user must have recallanyapprovalrequest custom permission unless they are the original submitter preview the approval path available on appro approvalpathinvocableservice returns the approval path that would be taken for a given record, without submitting use this to build custom preview uis signature list\<appro approvalpathinvocableservice previewresult> appro approvalpathinvocableservice previewapprovalpath( list\<appro approvalpathinvocableservice previewrequest> requests ); use case embed in a screen flow or a custom lightning component to let submitters see exactly who will approve before they click submit — useful for reducing surprise rejections on high stakes deals see best practices → preview vs submit docid\ h8xc9gykfudb7auncqlpu for design guidance invocable actions vs global methods — which do i use? need use record triggered flow on standard object invocable action submit for approval docid\ n1ojhuatlkkeigbtbigxu custom apex trigger or batch global method (this page) subscription / managed package integration global method (this page) custom lightning web component global method, called from an @auraenabled wrapper bulk approve from a list view button invocable action inside a screen flow global methods and invocable actions call the same underlying engine — the difference is the entry point error handling patterns every global method throws appro approvalexception on business logic failures (no matching process, invalid status, missing required message, etc ) and system dmlexception on platform failures catch them separately for clear logging try { appro approvalutilscontroller apexapprovalsubmit(params); } catch (appro approvalexception e) { // business rule failure — e g , no process matches the record logbusinesserror(recordid, e getmessage()); } catch (dmlexception e) { // platform failure — e g , record lock contention logplatformerror(recordid, e getmessage()); } catch (exception e) { logunknownerror(recordid, e); } related invocable actions docid\ n1ojhuatlkkeigbtbigxu — flow callable equivalents automation patterns docid\ tq b8u71vneelfvoomtix — end to end examples object model docid\ mvebvizbuokkqryr0cjui — the schema you're reading/writing through these methods