Hey guys, today in this post we are going to learn about How to find Quote owner’s manager’s Name and Email using apex soql query in Visualforce Salesforce.
Visualforce is a web development framework that enables developers to build sophisticated, custom user interfaces for mobile and desktop apps that can be hosted on the Lightning Platform. You can use Visualforce to build apps that align with the styling of Lightning Experience, as well as your own completely custom interface. To Know more details, Click Here.
Final Output →
You can download file directly from github by Click Here.
Other related post that would you like to learn in Salesforce
- Find the below steps ▾
Create Visualforce Page
Step 1:- Create Visualforce Page : ownerManagerFromQuoteVf.vfp
From Developer Console >> File >> New >> Visualforce Page
ownerManagerFromQuoteVf.vfp [Visualforce Page]
<apex:page standardController="Quote" extensions="ownerManagerFromQuoteVfCtrl">
<div class="slds" style="padding:10px;">
<p style="font-size:16px; display:block; margin-bottom:15px; color:#008ee8;">
Find Owner's <strong>Manager name</strong> from Quote
</p>
<br/>
<table width="50%" border="1" cellspacing="0" cellpadding="5" bordercolor="#ccc" class="slds-table slds-table_bordered slds-table_col-bordered" style="border-collapse:collapse;">
<tr style="background:#eee;">
<th>Owner Name</th>
<th>Manager Name</th>
<th>Manager Email</th>
</tr>
<apex:repeat value="{!quoteObj}" var="qItm">
<tr>
<td><apex:outputField value="{!qItm.Owner.Name}"/></td>
<td><apex:outputText value="{!managerName}"/></td>
<td><apex:outputText value="{!managerEmail}"/></td>
</tr>
</apex:repeat>
</table>
</div>
</apex:page>
Create Apex Class Extension Controller in Visualforce
Step 2:- Create Apex Class : ownerManagerFromQuoteVfCtrl.apxc
From Developer Console >> File >> New >> Apex Class
ownerManagerFromQuoteVfCtrl.apxc [Apex Class Controller]
public class ownerManagerFromQuoteVfCtrl {
public String MstrId{GET;SET;}
public Quote quoteObj{GET;SET;}
public USER userObj{GET;SET;}
public USER userMngrId{GET;SET;}
public String managerName{GET;SET;}
public String managerEmail{GET;SET;}
public ownerManagerFromQuoteVfCtrl(ApexPages.StandardController Controller){
MstrId = ApexPages.currentPage().getParameters().get('id');
quoteObj = [SELECT Id, Name, OwnerId, Owner.Name FROM Quote WHERE Id=:MstrId ];
userObj= [SELECT id, Name, Manager.id, ManagerId FROM USER WHERE id=:quoteObj.OwnerId];
system.debug('userObj## ' + userObj);
IF(userObj.ManagerId !=NULL || userObj.ManagerId ==''){
userMngrId= [SELECT id, Name, Email, ManagerId FROM USER WHERE id=:userObj.Manager.id];
managerName = userMngrId.Name;
managerEmail = userMngrId.Email;
system.debug('userMngrId#' + userMngrId) ;
}
}
}
Further post that would you like to learn in Salesforce
How do I query a Quote owner in Salesforce?
Just use Owner.name in the select of your soql. This should give you the owner name.
How do I run a SOQL query in Visual Studio?
To execute SOQL you can simply select the text and run the command SFDX: Execute SOQL Query with Currently Selected Text . You can choose to execute your query against the REST or Tooling APIs. After the query is executed the results display in the output pane.
How do I find the owner of a role in Salesforce?
Click on Setup. In the Quick Find box, enter Roles then click Roles. Click Edit next to the Role Name.
Related Topics | You May Also Like
Our Free Courses →
👉 Get Free Course →
📌 Salesforce Administrators 📌 Salesforce Lightning Flow Builder 📌 Salesforce Record Trigger Flow Builder |
👉 Get Free Course →
📌 Aura Lightning Framework 📌 Lightning Web Component (LWC) 📌 Rest APIs Integration |