Calling Apex method from a Custom Button and Submit to Approval Process
Get link
Facebook
X
Pinterest
Email
Other Apps
To call Apex method from a Custom Button and Submit to Approval Process : Salesforce
1. Create a custom button
{!REQUIRESCRIPT("/soap/ajax/15.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/15.0/apex.js")}
var approval = confirm("Are you sure want to send it for approval process?");
if(approval == true)
{
sforce.apex.execute("ApprovalSubmit","sentToApproval",{recordId:"{!Interviewer__c.Id}"});
alert("Set Record for Approval");
}
2. Create a apex class :
global class ApprovalSubmit{
webservice static void sentToApproval(Id recordId) {
Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
req1.setComments('Submitted for Approval');
req1.setObjectId(recordId);
Approval.ProcessResult res = Approval.Process(req1);
}
}
Happy Sharing...
Everyone has their own favourites, so please feel free to share yours in the comments below!
Lightning Datatable with Mask and Unmasked Description : lightning-datatable displays tabular data where each cell with field values and value should be masked and unmasked. ADVANCED OPTIONS FOR lightning-datatable IN LWC : Component HTML Component JS import { LightningElement, track, api } from 'lwc'; import getContacts from '@salesforce/apex/ContactController.getContacts'; export default class MaskComp extends LightningElement { @track accounts; @api recordId; columns = [ { label: 'First Name', fieldName: 'FirstName', type: 'text' }, { label: 'Last Name', fieldName: 'LastName', type: 'text' }, { label: 'Email', fieldName: 'maskedEmail', type: 'button', ...
Comments
Post a Comment