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
Shalini PurushothamanShalini Purushothaman 

Retrieve a text value for each picklist value selected

i have a Agent type picklist and a Agent Name lookup. How do i retrieve Agent Name for each Agent Type ?
Mathew Andresen 5Mathew Andresen 5
Where are you trying to retrieve it to, is this in Apex, or are you just trying to fill a field.

You can do create field, use the forumula type, choose text, and then input a forumula to get the field value from a related object.  It might look something like
 
Agent_Name__r.Agent_Field__c

Where Agent_Name__r is the lookup field, and Agent_Field__c is the field you want to get the data from.  You can use the insert field to help you get the proper forumula.  

Hope this helps,
Shalini PurushothamanShalini Purushothaman

[Shalini Purushothaman] Shalini Purushothaman
I need to retrive it to a email template. I need to retrieve Agent Name for Agent Type = Type1, Agent Name for Agent Type = Type 2 etc
 
Mathew Andresen 5Mathew Andresen 5
Are you using an HTML or visualforce email template?  HTML is easier, but it doesn't allow you to get related list data.  IE, you can't do an HTML template on opportunities but then fill in your product info.  In visualforce you can.

Here's an example, of a visualforce email template I did to send out details on a tasting (included the products) and the account.
 
<messaging:emailTemplate subject="{!relatedTo.Account__r.Name} Tasting on {!relatedTo.Date_of_Tasting__c}" 
recipientType="User" 
relatedToType="Tasting__c">


<messaging:htmlEmailBody >
        <html>
        <style> 
               
        table { border:solid black 2px; }
        td { border:solid black 1px; }
        </style>
        
        
                  <p>Hi Team,</p>
          <br/>
          <p>On &nbsp; <apex:outputText value="{0,date,MM/dd/yyyy}"> <apex:param value="{!relatedTo.Date_of_Tasting__c}" /> </apex:outputText> 
           we performed a tasting at the {!relatedTo.Location__c} location for {!relatedTo.Account__r.Name} 
          We gave out &nbsp; <apex:outputText value="{0,number,###,###,##0}"><apex:param value="{!relatedTo.Total_Samples_Given__c}" /></apex:outputText>   samples
           and sold &nbsp; <apex:outputText value="{0,number,###,###,##0}"><apex:param value="{!relatedTo.Total_Bottles_Sold__c}" /></apex:outputText> bottles.</p>
          <br/>
          <p><b>Comments:</b></p>
          
          <p>{!relatedTo.Comments__c}</p>
        
        

        <table>               
      <th>Brand</th>
      <th>Tier</th>
      <th>Variety</th>
      <th>Samples Given</th>
      <th>Bottles Sold</th>
      <th>Comments</th>
        
   
   <apex:repeat value="{!relatedTo.Tasting_Products1__r}" var="opp">
   <tr>
   <td>{!opp.Brand__c}</td>
   <td>{!opp.Tier__c}</td>
   <td>{!opp.Variety__c}</td>
   <td>{!opp.Samples_Given__c}</td> 
   <td>{!opp.Bottles_Sold__c}</td>
   <td>{!opp.Consumer_Comments__c}</td>
   

   
   </tr>
    </apex:repeat>

        
</table>
        </html>
    </messaging:htmlEmailBody>


</messaging:emailTemplate>

The key here is that you are getting the sub object and looping through it 
<apex:repeat value="{!relatedTo.Tasting_Products1__r}" var="opp">


If you don't need the child object details, you can just use regular merge fields in the HTML tempalte.
 
Kris KargonKris Kargon
Write the code for retrieve Agent Name for each Agent Type. It will work properly. Best wishes for your work.
There are lots of students struggling to complete their essay works. The essay writing service reviews (http://essaywriting-servicereviews.com/) helps them to make a best essay and gets them high grades in each subjects.