• Anshul Kapoor 13
  • NEWBIE
  • 15 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 14
    Replies
Hi All,

My issue is: In my code, only 2 SOQL's are processing, but I am getting 6 SOQL is processed as per debug log. Could somebody tell me, why I am getting these many SOQL's are processed.

Below is my code:

Apex Trigger:

Trigger AccountTrigger on Account (after update){
    if (StopRecurssion.OnetimeRun5 && Trigger.isUpdate && Trigger.isAfter){ //after update
        AccountTriggerHandler ATH = new AccountTriggerHandler();
        ATH.BillingEventAccountUpdate(Trigger.oldMap, Trigger.newMap); //Calls method on change of 'Account Owner' 
        StopRecurssion.OnetimeRun5 = false;
    }
}

Class:

 public class AccountTriggerHandler{
    public void BillingEventAccountUpdate(Map<Id, Account> oldMapAcnt, Map<Id, Account> newMapAcnt){
        List<Billing_Event__c> lstBE = new List<Billing_Event__c>(); //List of Billing Events
        Set<Id> setAcntId = new Set<Id>(); //Set of Account Ids
        Map<Id, Id> mapDealId_AcntOwnerId = new Map<Id, Id>(); //Map of 'Deal' Id & 'Account-OwnerId'
        
        for (Account acc : newMapAcnt.values()){ //Get the Set of 'AccountIds'
            if (oldMapAcnt.get(acc.Id).OwnerId != newMapAcnt.get(acc.Id).OwnerId){
                setAcntId.add(acc.Id);
            }
        }
        
        if (setAcntId.size() > 0){ //Get the Map of 'DealId' & 'Account-OwnerId'
            for (Deal__c deal : [select Id, Vendor__r.OwnerId from Deal__c where Deal_Status__c = 'Active' AND Event_Total__c > 0 AND Vendor__c IN :setAcntId]){
                system.debug('dealId** ' + deal.Id);
                mapDealId_AcntOwnerId.put(deal.Id, deal.Vendor__r.OwnerId);
            }
        }   
        
        //Update the 'Account-Owner' to all the corresponding 'Billing Events Owners'
        if (mapDealId_AcntOwnerId.size() > 0){ 
            for (Billing_Event__c be : [select Id, Deal_1__c, OwnerId from Billing_Event__c where Deal_1__c IN :mapDealId_AcntOwnerId.keySet() AND OwnerId != :mapDealId_AcntOwnerId.values()[0] LIMIT 2]){
                system.debug('beId** ' + be.Id);
                be.OwnerId = mapDealId_AcntOwnerId.get(be.Deal_1__c);
                lstBE.add(be);
            }
        }
        if (lstBE.size() > 0){
            system.debug('Size** ' + lstBE.size());
                    update lstBE;
        }
    }
}
Hi all,

Please someone solve my issue:

I have four fields:
'A' = 54321, 'B' = 8888888, 'C' = 201701, 201702,201703,201704 & 'D' = HI 

The Result, I need to store into the field 'E' = 54321_8888888_201701_HI, 54321_8888888_201702_HI, 54321_8888888_201703_HI, 54321_8888888_201704_HI

In field A, there will  always be 1 element. The E field always has the Permulation of four combination of fields A, B, C & D. For the above case: 1 * 1 * 4 * 1 = 4

For the same case, A = 98765, B = 111111, 222222, 333333, 444444, C = 201705,201706, 201707, 201708, D = HI,PR,ML
The Result into E = 
98765_111111_201705_HI,
98765_111111_201706_HI,
98765_111111_201707_HI,
98765_111111_201708_HI,
98765_111111_201705_PR,
98765_111111_201706_PR,
98765_111111_201707_PR,
98765_111111_201708_PR,
98765_111111_201705_ML,
98765_111111_201706_ML,
98765_111111_201707_ML,
98765_111111_201708_ML,
98765_222222_201705_Hi,
98765_222222_201706_HI,
98765_222222_201707_HI,
98765_222222_201708_HI,
98765_222222_201705_PR,
98765_222222_201706_PR,
98765_222222_201707_PR,
98765_222222_201708_PR,
98765_222222_201705_ML,
98765_222222_201706_ML,
98765_222222_201707_ML,
98765_222222_201708_ML,
98765_333333_201705_Hi,
98765_333333_201706_HI,
98765_333333_201707_HI,
98765_333333_201708_HI,
98765_333333_201705_PR,
98765_333333_201706_PR,
98765_333333_201707_PR,
98765_333333_201708_PR,
98765_333333_201705_ML,
98765_333333_201706_ML,
98765_333333_201707_ML,
98765_333333_201708_ML,
98765_444444_201705_HI,
98765_444444_201706_HI,
98765_444444_201707_HI,
98765_444444_201708_HI,
98765_444444_201705_PR,
98765_444444_201706_PR,
98765_444444_201707_PR,
98765_444444_201708_PR,
98765_444444_201705_ML,
98765_444444_201706_ML,
98765_444444_201707_ML,
98765_444444_201708_ML

The E field has 48 combinations separated by comma. I have shown the result into vertical form for understanding.
Hi All,

My formula is Deal_1__r.Parent_Deal__r.Parent_Deal__r.Id. 
I am getting an error 'The formula has no column type'.

Please provide me the solution.
Hi,

How to get the pick list values dynamically using record type- 
Below is the code- 

vf Page-

<apex:selectList id="countries" value="{!Office_Location__c.Country__c}"
         size="1" required="true">
  <apex:selectOptions value="{!countries}"/>
</apex:selectList>


public List<SelectOption> getCountries()
{
  List<SelectOption> options = new List<SelectOption>();
        
   Schema.DescribeFieldResult fieldResult =
 OfficeLocation__c.Country__c.getDescribe();
   List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        
   for( Schema.PicklistEntry f : ple)
   {
      options.add(new SelectOption(f.getLabel(), f.getValue()));
   }       
   return options;
}

I have 2 record types - Scanback & AutoBill & field country having different values as per record Type.
Lookup Image

<a href="#" id="acc4_lkwgt" onclick="openLookupPopup();" tabindex="2" title="Level  Description Lookup (New Window)" style="text-decoration: none;">
         <img src="/s.gif" alt="Level  Description Lookup (New Window)" class="lookupIcon" onblur="this.className = 'lookupIcon';" onfocus="this.className = 'lookupIconOn';" onmouseout="this.className = 'lookupIcon';this.className = 'lookupIcon';" onmouseover="this.className = 'lookupIconOn';this.className = 'lookupIconOn';" title="Level  Description Lookup (New Window)"/>
Hi All,

<messaging:emailTemplate subject="Need the access" recipientType="User" relatedToType="X411_Support__c">
<messaging:htmlEmailBody >

        <html>
            <body>

            <p>Dear {!recipient.name},</p>
            
            <apex:outputField value="{!relatedTo.Comment__c}" />
            
            </body>
        </html>
    </messaging:htmlEmailBody>
</messaging:emailTemplate>

Above is the line of code of Visualforce email template. Comment is the Rich Text Area field of object 'X411_Support__c'. On firing an email, the email does not show the image of rich text area field. 

I have used the tag <apex:outputText value =  "{!relatedTo.Comment__c}" escape = "false"/>. But no use.

Could some body help me regarding code, so the image is displayed on email.
Hi,

VF-1:

apex:page controller="TwitterListApi" 
apex:form 
apex:pageBlock 
br/><br/> <h1
Please Press the button to get the List of Twitter Account Users
/h1><br/><br/
apex:commandLink value="Submit" action="{!Submit}" target="_blank" styleClass="btn"/
/apex:pageBlock
/apex:form
/apex:page

VF-2:

apex:page controller="TwitterListApi" showHeader="false" sidebar="false" action="{!generatecsv}" contentType="application/octet-stream#Twitter_Acoount Information.csv"
User Name, Name, Location, Mobile
apex:repeat value="{!Generate}"
{!screenname}, {!username}, {!location}, {!mobile}
/apex:repeat
/apex:page

Apex Code:

public class TwitterListApi
{
    public String oAuthConsumerKey = 'BlsoC839h5czptk6oHyyAgTGq';
    public String oAuthConsumerSecret = 'iAF4rc2AFEOP1h9rNVx4ZM8B86GXo4IGPcl2DN67iiMi6mdxnu';
    public String oAuthUrl = 'https://api.twitter.com/oauth2/token';
    public String oAuthUrl_1 = 'https://api.twitter.com/1.1/users/lookup.json?screen_name=';
    public String username{get;set;}
    public String location{get;set;}
    public String mobile{get;set;}
    public String screenname{get;set;}
    public String stoken;
    public List<Companies> list_com;
               
    public pageReference Submit()
    {
        pageReference pageRef= new pageReference('/apex/GenerateListApi');
        pageRef.setRedirect(false);
        return pageRef;
    }
    
    public pageReference generatecsv()
    {
         String name;
        //List<String> list_name= new List<String>();
        List<username__c> list_user;
        try
        {
            list_user=[select name__c from username__c];
        }
        catch (System.QueryException e)
        {
            system.debug('Error in generatecsv method for list_user query** '+e);
        }
        for (username__c user:list_user)
        {  
           if (name==null)
           {
               String url=EncodingUtil.urlEncode(user.name__c,'UTF-8');
               name=url;               
           }
           else 
           {
               String url=EncodingUtil.urlEncode(user.name__c,'UTF-8');
               name=name+','+url;
           }
        }
        system.debug('name** '+name);
        //Encode them
        String keyencoded = EncodingUtil.urlEncode(oAuthConsumerKey, 'UTF-8');
        String secretkeyencoded = EncodingUtil.urlEncode(oAuthConsumerSecret, 'UTF-8');

        //Create Final Key String
        String sFinal = keyencoded + ':' + secretkeyencoded;
        //Convert to Blob
        Blob headerValue = Blob.valueOf(sFinal);
        system.debug('headerValue** '+headerValue);

        //Build Request
        HttpRequest req = new HttpRequest();
        req.setEndpoint(oAuthUrl);
        req.setMethod('POST');

        //Add Auth Header
        String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);
        req.setHeader('Authorization', authorizationHeader);
        system.debug('authorizationHeader** '+authorizationHeader);

        //You need to add this to the request - proved easy to miss in instructions...
        req.setBody('grant_type=client_credentials');

        //Make request
        Http http = new Http();
        try{
        HTTPResponse res = http.send(req);
        system.debug('Body_1** '+res.getBody());           

        //Parse JSON for Bearer Token
        
        JSONParser parser = JSON.createParser(res.getBody());
        while (parser.nextToken() != null) {
        if (parser.getCurrentToken() == JSONToken.FIELD_NAME && parser.getText() == 'access_token'){
        parser.nextToken();
        stoken = parser.getText();
        }
        }
        }
        catch(System.CalloutException e)
        {
            system.debug('Error_1** '+e.getMessage());
        }
     
    HttpRequest req2 = new HttpRequest();
    //I actually store the endpoint in the same custom setting and build dynamically, but for purposes of demo:
    req2.setEndpoint(oAuthUrl_1 + name);
    req2.setMethod('GET');

    //Call Bearer token Method
    //Note - unless invalidated, I believe you can store this and keep using it indefinitely, but again, to demo concept
    String authorizationHeader_1 = 'Bearer ' + stoken;
    req2.setHeader('Authorization', authorizationHeader_1);
    system.debug('authorizationHeader_1** '+ authorizationHeader_1);

    try{
    HTTPResponse res = http.send(req2);
    String sBody = res.getBody();
    system.debug('Body_2** ' + sBody);
    boolean success=true;
    
    JSONParser parser=JSON.createparser(res.getBody());
    while (parser.nextToken()!=null)
    {
        if(parser.getCurrentToken()== JSONToken.START_OBJECT)
        {    
            while (parser.nextToken()!=null)
            {
                if((parser.getCurrentToken()==JSONToken.FIELD_NAME) && (parser.getText()=='screen_name'))
                {
                    parser.nextToken();
                    screenname=parser.getText();
                    system.debug('screenname** '+screenname);
                    success=true;
                }
                
                if((parser.getCurrentToken()==JSONToken.FIELD_NAME) && (parser.getText()=='name')) 
                {
                    parser.nextToken();
                    username=parser.getText();
                    system.debug('username** '+username);
                }
                
                if((parser.getCurrentToken()==JSONToken.FIELD_NAME) && (parser.getText()=='location'))
                {
                    parser.nextToken();
                    location=parser.getText();
                    location = '"'+location+'"';
                    system.debug('location** '+location );
                }
                
                if (success)
                {
                    if ((parser.getCurrentToken()==JSONToken.FIELD_NAME) && (parser.getText()=='description'))
                    {
                        parser.nextToken();
                        mobile=parser.getText();
                        success=false;
                        system.debug('mobile** '+mobile);
                        List<Companies> list_com=new List<Companies>();
                        Companies com=new Companies(screenname, username, location, mobile);
                        system.debug('com** '+com);
                        list_com.add(com);
                        system.debug('list_com-1** '+list_com);
                    }
                 }
                 
            }
        }
    }
    }
    catch(System.CalloutException e)
    {
        system.debug('Error_2** '+e.getMessage());
    }
        return null;
    }
    
    public List<Companies> getGenerate()
    {
            system.debug('list_com** '+list_com);
            return list_com;
    }
    
    public class Companies
    {
        String screenname;
        String username;
        String location;
        String mobile;
        
        public  Companies(String screename, String username, String location, String mobile)
        {
             this.screenname=screenname;
             this.username=username;
             this.location=location;
             this.mobile=mobile;   
        }
    }
}
VF-1:

apex:page controller="TwitterListApi" 
 apex:form 
apex:pageBlock
<br/><br/> <h1>
Please Press the button to get the List of Twitter Account Users</h1><br/><br/> 
apex:commandLink value="Submit" action="{!Submit}" target="_blank" styleClass="btn"/
/apex:pageBlock
/apex:form
/apex:page

VF-2:

apex:page controller="TwitterListApi" showHeader="false" sidebar="false" action="{!generatecsv}" contentType="application/octet-stream#Twitter_Acoount Information.csv">User Name, Name, Location, Mobile
    apex:repeat value="{!Generate}"
       {!screenname}, {!username}, {!location}, {!mobile}
    /apex:repeat
  /apex:page
Apex Code:

public class TwitterListApi
{
    public String oAuthConsumerKey = 'BlsoC839h5czptk6oHyyAgTGq';
    public String oAuthConsumerSecret = 'iAF4rc2AFEOP1h9rNVx4ZM8B86GXo4IGPcl2DN67iiMi6mdxnu';
    public String oAuthUrl = 'https://api.twitter.com/oauth2/token';
    public String oAuthUrl_1 = 'https://api.twitter.com/1.1/users/lookup.json?screen_name=';
    public String username{get;set;}
    public String location{get;set;}
    public String mobile{get;set;}
    public String screenname{get;set;}
    public String stoken;
    public List<Companies> list_com;
           
    
    public pageReference Submit()
    {
        pageReference pageRef= new pageReference('/apex/GenerateListApi');
        pageRef.setRedirect(true);
        pageRef.setRedirect(false);
        return pageRef;
    }
    
    public pageReference generatecsv()
    {
         String name;
         List<username__c> list_user;
        try
        {
            list_user=[select name__c from username__c];
        }
        catch (System.QueryException e)
        {
            system.debug('Error in generatecsv method for list_user query** '+e);
        }
        for (username__c user:list_user)
        {  
           if (name==null)
           {
              String url=EncodingUtil.urlEncode(user.name__c,'UTF-8');
               name=url;               
           }
           else 
           {
               String url=EncodingUtil.urlEncode(user.name__c,'UTF-8');
               name=name+','+url;
           }
        }
        system.debug('name** '+name);
        //Encode them
        String keyencoded = EncodingUtil.urlEncode(oAuthConsumerKey, 'UTF-8');
        String secretkeyencoded = EncodingUtil.urlEncode(oAuthConsumerSecret, 'UTF-8');

        //Create Final Key String
        String sFinal = keyencoded + ':' + secretkeyencoded;
        //Convert to Blob
        Blob headerValue = Blob.valueOf(sFinal);
        system.debug('headerValue** '+headerValue);

        //Build Request
        HttpRequest req = new HttpRequest();
        req.setEndpoint(oAuthUrl);
        req.setMethod('POST');

        //Add Auth Header
        String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);
        req.setHeader('Authorization', authorizationHeader);
        system.debug('authorizationHeader** '+authorizationHeader);

        //You need to add this to the request - proved easy to miss in instructions...
        req.setBody('grant_type=client_credentials');

        //Make request
        Http http = new Http();
        try{
        HTTPResponse res = http.send(req);
        system.debug('Body_1** '+res.getBody());           
        //String stoken;
        //Parse JSON for Bearer Token
        
        JSONParser parser = JSON.createParser(res.getBody());
        while (parser.nextToken() != null) {
        if (parser.getCurrentToken() == JSONToken.FIELD_NAME && parser.getText() == 'access_token'){
        parser.nextToken();
        stoken = parser.getText();
        }
        }
        }
        catch(System.CalloutException e)
        {
            system.debug('Error_1** '+e.getMessage());
        }
        
     
    HttpRequest req2 = new HttpRequest();
    //I actually store the endpoint in the same custom setting and build dynamically, but for purposes of demo:
        req2.setEndpoint(oAuthUrl_1 + name);
        req2.setMethod('GET');

    //Call Bearer token Method
    //Note - unless invalidated, I believe you can store this and keep using it indefinitely, but again, to demo concept
    String authorizationHeader_1 = 'Bearer ' + stoken;
    req2.setHeader('Authorization', authorizationHeader_1);
    system.debug('authorizationHeader_1** '+ authorizationHeader_1);

    try{
    HTTPResponse res = http.send(req2);
    String sBody = res.getBody();
    system.debug('Body_2** ' + sBody);
    boolean success=true;
    JSONParser parser=JSON.createparser(res.getBody());
    while (parser.nextToken()!=null)
    {
        if(parser.getCurrentToken()== JSONToken.START_OBJECT)
        {    
            while (parser.nextToken()!=null)
            {
                if((parser.getCurrentToken()==JSONToken.FIELD_NAME) && (parser.getText()=='screen_name'))
                {
                    parser.nextToken();
                    screenname=parser.getText();
                    system.debug('screenname** '+screenname);
                    success=true;
                }
                
                if((parser.getCurrentToken()==JSONToken.FIELD_NAME) && (parser.getText()=='name')) 
                {
                    parser.nextToken();
                    username=parser.getText();
                    system.debug('username** '+username);
                }
                
                integer i = 0;
                
                if((parser.getCurrentToken()==JSONToken.FIELD_NAME) && (parser.getText()=='location'))
                {
                    parser.nextToken();
                    location=parser.getText();
                    location = '"'+location+'"';
                    system.debug('location** '+location );
                }
                
                if (success)
                {
                    if ((parser.getCurrentToken()==JSONToken.FIELD_NAME) && (parser.getText()=='description'))
                    {
                        parser.nextToken();
                        mobile=parser.getText();
                        success=false;
                        system.debug('mobile** '+mobile);
                        List<Companies> list_com=new List<Companies>();
                        Companies com=new Companies(screenname, username, location, mobile);
                        system.debug('com** '+com);
                        list_com.add(com);
                        system.debug('list_com-1** '+list_com);
                    }
                 }
                 
            }
        }
    }
    }
    catch(System.CalloutException e)
    {
        system.debug('Error_2** '+e.getMessage());
    }
        return null;
    }
    
    public List<Companies> getGenerate()
    {
        system.debug('list_com** '+list_com);
        return list_com;
    }
    
    public class Companies
    {

        String screenname;
        String username;
        String location;
        String mobile;
        
        
        public  Companies(String screename, String username, String location, String mobile)
        {
             this.screenname=screenname;
             this.username=username;
             this.location=location;
             this.mobile=mobile;   
        }
    }
}

Q1 I am getting null in list_com in a method  getGenerate().

Please solve my query?
Hi All,

My issue is: In my code, only 2 SOQL's are processing, but I am getting 6 SOQL is processed as per debug log. Could somebody tell me, why I am getting these many SOQL's are processed.

Below is my code:

Apex Trigger:

Trigger AccountTrigger on Account (after update){
    if (StopRecurssion.OnetimeRun5 && Trigger.isUpdate && Trigger.isAfter){ //after update
        AccountTriggerHandler ATH = new AccountTriggerHandler();
        ATH.BillingEventAccountUpdate(Trigger.oldMap, Trigger.newMap); //Calls method on change of 'Account Owner' 
        StopRecurssion.OnetimeRun5 = false;
    }
}

Class:

 public class AccountTriggerHandler{
    public void BillingEventAccountUpdate(Map<Id, Account> oldMapAcnt, Map<Id, Account> newMapAcnt){
        List<Billing_Event__c> lstBE = new List<Billing_Event__c>(); //List of Billing Events
        Set<Id> setAcntId = new Set<Id>(); //Set of Account Ids
        Map<Id, Id> mapDealId_AcntOwnerId = new Map<Id, Id>(); //Map of 'Deal' Id & 'Account-OwnerId'
        
        for (Account acc : newMapAcnt.values()){ //Get the Set of 'AccountIds'
            if (oldMapAcnt.get(acc.Id).OwnerId != newMapAcnt.get(acc.Id).OwnerId){
                setAcntId.add(acc.Id);
            }
        }
        
        if (setAcntId.size() > 0){ //Get the Map of 'DealId' & 'Account-OwnerId'
            for (Deal__c deal : [select Id, Vendor__r.OwnerId from Deal__c where Deal_Status__c = 'Active' AND Event_Total__c > 0 AND Vendor__c IN :setAcntId]){
                system.debug('dealId** ' + deal.Id);
                mapDealId_AcntOwnerId.put(deal.Id, deal.Vendor__r.OwnerId);
            }
        }   
        
        //Update the 'Account-Owner' to all the corresponding 'Billing Events Owners'
        if (mapDealId_AcntOwnerId.size() > 0){ 
            for (Billing_Event__c be : [select Id, Deal_1__c, OwnerId from Billing_Event__c where Deal_1__c IN :mapDealId_AcntOwnerId.keySet() AND OwnerId != :mapDealId_AcntOwnerId.values()[0] LIMIT 2]){
                system.debug('beId** ' + be.Id);
                be.OwnerId = mapDealId_AcntOwnerId.get(be.Deal_1__c);
                lstBE.add(be);
            }
        }
        if (lstBE.size() > 0){
            system.debug('Size** ' + lstBE.size());
                    update lstBE;
        }
    }
}
Hi all,

Please someone solve my issue:

I have four fields:
'A' = 54321, 'B' = 8888888, 'C' = 201701, 201702,201703,201704 & 'D' = HI 

The Result, I need to store into the field 'E' = 54321_8888888_201701_HI, 54321_8888888_201702_HI, 54321_8888888_201703_HI, 54321_8888888_201704_HI

In field A, there will  always be 1 element. The E field always has the Permulation of four combination of fields A, B, C & D. For the above case: 1 * 1 * 4 * 1 = 4

For the same case, A = 98765, B = 111111, 222222, 333333, 444444, C = 201705,201706, 201707, 201708, D = HI,PR,ML
The Result into E = 
98765_111111_201705_HI,
98765_111111_201706_HI,
98765_111111_201707_HI,
98765_111111_201708_HI,
98765_111111_201705_PR,
98765_111111_201706_PR,
98765_111111_201707_PR,
98765_111111_201708_PR,
98765_111111_201705_ML,
98765_111111_201706_ML,
98765_111111_201707_ML,
98765_111111_201708_ML,
98765_222222_201705_Hi,
98765_222222_201706_HI,
98765_222222_201707_HI,
98765_222222_201708_HI,
98765_222222_201705_PR,
98765_222222_201706_PR,
98765_222222_201707_PR,
98765_222222_201708_PR,
98765_222222_201705_ML,
98765_222222_201706_ML,
98765_222222_201707_ML,
98765_222222_201708_ML,
98765_333333_201705_Hi,
98765_333333_201706_HI,
98765_333333_201707_HI,
98765_333333_201708_HI,
98765_333333_201705_PR,
98765_333333_201706_PR,
98765_333333_201707_PR,
98765_333333_201708_PR,
98765_333333_201705_ML,
98765_333333_201706_ML,
98765_333333_201707_ML,
98765_333333_201708_ML,
98765_444444_201705_HI,
98765_444444_201706_HI,
98765_444444_201707_HI,
98765_444444_201708_HI,
98765_444444_201705_PR,
98765_444444_201706_PR,
98765_444444_201707_PR,
98765_444444_201708_PR,
98765_444444_201705_ML,
98765_444444_201706_ML,
98765_444444_201707_ML,
98765_444444_201708_ML

The E field has 48 combinations separated by comma. I have shown the result into vertical form for understanding.
Hi All,

My formula is Deal_1__r.Parent_Deal__r.Parent_Deal__r.Id. 
I am getting an error 'The formula has no column type'.

Please provide me the solution.
Hi,

How to get the pick list values dynamically using record type- 
Below is the code- 

vf Page-

<apex:selectList id="countries" value="{!Office_Location__c.Country__c}"
         size="1" required="true">
  <apex:selectOptions value="{!countries}"/>
</apex:selectList>


public List<SelectOption> getCountries()
{
  List<SelectOption> options = new List<SelectOption>();
        
   Schema.DescribeFieldResult fieldResult =
 OfficeLocation__c.Country__c.getDescribe();
   List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        
   for( Schema.PicklistEntry f : ple)
   {
      options.add(new SelectOption(f.getLabel(), f.getValue()));
   }       
   return options;
}

I have 2 record types - Scanback & AutoBill & field country having different values as per record Type.
Hi All,

<messaging:emailTemplate subject="Need the access" recipientType="User" relatedToType="X411_Support__c">
<messaging:htmlEmailBody >

        <html>
            <body>

            <p>Dear {!recipient.name},</p>
            
            <apex:outputField value="{!relatedTo.Comment__c}" />
            
            </body>
        </html>
    </messaging:htmlEmailBody>
</messaging:emailTemplate>

Above is the line of code of Visualforce email template. Comment is the Rich Text Area field of object 'X411_Support__c'. On firing an email, the email does not show the image of rich text area field. 

I have used the tag <apex:outputText value =  "{!relatedTo.Comment__c}" escape = "false"/>. But no use.

Could some body help me regarding code, so the image is displayed on email.
Hi,

VF-1:

apex:page controller="TwitterListApi" 
apex:form 
apex:pageBlock 
br/><br/> <h1
Please Press the button to get the List of Twitter Account Users
/h1><br/><br/
apex:commandLink value="Submit" action="{!Submit}" target="_blank" styleClass="btn"/
/apex:pageBlock
/apex:form
/apex:page

VF-2:

apex:page controller="TwitterListApi" showHeader="false" sidebar="false" action="{!generatecsv}" contentType="application/octet-stream#Twitter_Acoount Information.csv"
User Name, Name, Location, Mobile
apex:repeat value="{!Generate}"
{!screenname}, {!username}, {!location}, {!mobile}
/apex:repeat
/apex:page

Apex Code:

public class TwitterListApi
{
    public String oAuthConsumerKey = 'BlsoC839h5czptk6oHyyAgTGq';
    public String oAuthConsumerSecret = 'iAF4rc2AFEOP1h9rNVx4ZM8B86GXo4IGPcl2DN67iiMi6mdxnu';
    public String oAuthUrl = 'https://api.twitter.com/oauth2/token';
    public String oAuthUrl_1 = 'https://api.twitter.com/1.1/users/lookup.json?screen_name=';
    public String username{get;set;}
    public String location{get;set;}
    public String mobile{get;set;}
    public String screenname{get;set;}
    public String stoken;
    public List<Companies> list_com;
               
    public pageReference Submit()
    {
        pageReference pageRef= new pageReference('/apex/GenerateListApi');
        pageRef.setRedirect(false);
        return pageRef;
    }
    
    public pageReference generatecsv()
    {
         String name;
        //List<String> list_name= new List<String>();
        List<username__c> list_user;
        try
        {
            list_user=[select name__c from username__c];
        }
        catch (System.QueryException e)
        {
            system.debug('Error in generatecsv method for list_user query** '+e);
        }
        for (username__c user:list_user)
        {  
           if (name==null)
           {
               String url=EncodingUtil.urlEncode(user.name__c,'UTF-8');
               name=url;               
           }
           else 
           {
               String url=EncodingUtil.urlEncode(user.name__c,'UTF-8');
               name=name+','+url;
           }
        }
        system.debug('name** '+name);
        //Encode them
        String keyencoded = EncodingUtil.urlEncode(oAuthConsumerKey, 'UTF-8');
        String secretkeyencoded = EncodingUtil.urlEncode(oAuthConsumerSecret, 'UTF-8');

        //Create Final Key String
        String sFinal = keyencoded + ':' + secretkeyencoded;
        //Convert to Blob
        Blob headerValue = Blob.valueOf(sFinal);
        system.debug('headerValue** '+headerValue);

        //Build Request
        HttpRequest req = new HttpRequest();
        req.setEndpoint(oAuthUrl);
        req.setMethod('POST');

        //Add Auth Header
        String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);
        req.setHeader('Authorization', authorizationHeader);
        system.debug('authorizationHeader** '+authorizationHeader);

        //You need to add this to the request - proved easy to miss in instructions...
        req.setBody('grant_type=client_credentials');

        //Make request
        Http http = new Http();
        try{
        HTTPResponse res = http.send(req);
        system.debug('Body_1** '+res.getBody());           

        //Parse JSON for Bearer Token
        
        JSONParser parser = JSON.createParser(res.getBody());
        while (parser.nextToken() != null) {
        if (parser.getCurrentToken() == JSONToken.FIELD_NAME && parser.getText() == 'access_token'){
        parser.nextToken();
        stoken = parser.getText();
        }
        }
        }
        catch(System.CalloutException e)
        {
            system.debug('Error_1** '+e.getMessage());
        }
     
    HttpRequest req2 = new HttpRequest();
    //I actually store the endpoint in the same custom setting and build dynamically, but for purposes of demo:
    req2.setEndpoint(oAuthUrl_1 + name);
    req2.setMethod('GET');

    //Call Bearer token Method
    //Note - unless invalidated, I believe you can store this and keep using it indefinitely, but again, to demo concept
    String authorizationHeader_1 = 'Bearer ' + stoken;
    req2.setHeader('Authorization', authorizationHeader_1);
    system.debug('authorizationHeader_1** '+ authorizationHeader_1);

    try{
    HTTPResponse res = http.send(req2);
    String sBody = res.getBody();
    system.debug('Body_2** ' + sBody);
    boolean success=true;
    
    JSONParser parser=JSON.createparser(res.getBody());
    while (parser.nextToken()!=null)
    {
        if(parser.getCurrentToken()== JSONToken.START_OBJECT)
        {    
            while (parser.nextToken()!=null)
            {
                if((parser.getCurrentToken()==JSONToken.FIELD_NAME) && (parser.getText()=='screen_name'))
                {
                    parser.nextToken();
                    screenname=parser.getText();
                    system.debug('screenname** '+screenname);
                    success=true;
                }
                
                if((parser.getCurrentToken()==JSONToken.FIELD_NAME) && (parser.getText()=='name')) 
                {
                    parser.nextToken();
                    username=parser.getText();
                    system.debug('username** '+username);
                }
                
                if((parser.getCurrentToken()==JSONToken.FIELD_NAME) && (parser.getText()=='location'))
                {
                    parser.nextToken();
                    location=parser.getText();
                    location = '"'+location+'"';
                    system.debug('location** '+location );
                }
                
                if (success)
                {
                    if ((parser.getCurrentToken()==JSONToken.FIELD_NAME) && (parser.getText()=='description'))
                    {
                        parser.nextToken();
                        mobile=parser.getText();
                        success=false;
                        system.debug('mobile** '+mobile);
                        List<Companies> list_com=new List<Companies>();
                        Companies com=new Companies(screenname, username, location, mobile);
                        system.debug('com** '+com);
                        list_com.add(com);
                        system.debug('list_com-1** '+list_com);
                    }
                 }
                 
            }
        }
    }
    }
    catch(System.CalloutException e)
    {
        system.debug('Error_2** '+e.getMessage());
    }
        return null;
    }
    
    public List<Companies> getGenerate()
    {
            system.debug('list_com** '+list_com);
            return list_com;
    }
    
    public class Companies
    {
        String screenname;
        String username;
        String location;
        String mobile;
        
        public  Companies(String screename, String username, String location, String mobile)
        {
             this.screenname=screenname;
             this.username=username;
             this.location=location;
             this.mobile=mobile;   
        }
    }
}
VF-1:

apex:page controller="TwitterListApi" 
 apex:form 
apex:pageBlock
<br/><br/> <h1>
Please Press the button to get the List of Twitter Account Users</h1><br/><br/> 
apex:commandLink value="Submit" action="{!Submit}" target="_blank" styleClass="btn"/
/apex:pageBlock
/apex:form
/apex:page

VF-2:

apex:page controller="TwitterListApi" showHeader="false" sidebar="false" action="{!generatecsv}" contentType="application/octet-stream#Twitter_Acoount Information.csv">User Name, Name, Location, Mobile
    apex:repeat value="{!Generate}"
       {!screenname}, {!username}, {!location}, {!mobile}
    /apex:repeat
  /apex:page
Apex Code:

public class TwitterListApi
{
    public String oAuthConsumerKey = 'BlsoC839h5czptk6oHyyAgTGq';
    public String oAuthConsumerSecret = 'iAF4rc2AFEOP1h9rNVx4ZM8B86GXo4IGPcl2DN67iiMi6mdxnu';
    public String oAuthUrl = 'https://api.twitter.com/oauth2/token';
    public String oAuthUrl_1 = 'https://api.twitter.com/1.1/users/lookup.json?screen_name=';
    public String username{get;set;}
    public String location{get;set;}
    public String mobile{get;set;}
    public String screenname{get;set;}
    public String stoken;
    public List<Companies> list_com;
           
    
    public pageReference Submit()
    {
        pageReference pageRef= new pageReference('/apex/GenerateListApi');
        pageRef.setRedirect(true);
        pageRef.setRedirect(false);
        return pageRef;
    }
    
    public pageReference generatecsv()
    {
         String name;
         List<username__c> list_user;
        try
        {
            list_user=[select name__c from username__c];
        }
        catch (System.QueryException e)
        {
            system.debug('Error in generatecsv method for list_user query** '+e);
        }
        for (username__c user:list_user)
        {  
           if (name==null)
           {
              String url=EncodingUtil.urlEncode(user.name__c,'UTF-8');
               name=url;               
           }
           else 
           {
               String url=EncodingUtil.urlEncode(user.name__c,'UTF-8');
               name=name+','+url;
           }
        }
        system.debug('name** '+name);
        //Encode them
        String keyencoded = EncodingUtil.urlEncode(oAuthConsumerKey, 'UTF-8');
        String secretkeyencoded = EncodingUtil.urlEncode(oAuthConsumerSecret, 'UTF-8');

        //Create Final Key String
        String sFinal = keyencoded + ':' + secretkeyencoded;
        //Convert to Blob
        Blob headerValue = Blob.valueOf(sFinal);
        system.debug('headerValue** '+headerValue);

        //Build Request
        HttpRequest req = new HttpRequest();
        req.setEndpoint(oAuthUrl);
        req.setMethod('POST');

        //Add Auth Header
        String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);
        req.setHeader('Authorization', authorizationHeader);
        system.debug('authorizationHeader** '+authorizationHeader);

        //You need to add this to the request - proved easy to miss in instructions...
        req.setBody('grant_type=client_credentials');

        //Make request
        Http http = new Http();
        try{
        HTTPResponse res = http.send(req);
        system.debug('Body_1** '+res.getBody());           
        //String stoken;
        //Parse JSON for Bearer Token
        
        JSONParser parser = JSON.createParser(res.getBody());
        while (parser.nextToken() != null) {
        if (parser.getCurrentToken() == JSONToken.FIELD_NAME && parser.getText() == 'access_token'){
        parser.nextToken();
        stoken = parser.getText();
        }
        }
        }
        catch(System.CalloutException e)
        {
            system.debug('Error_1** '+e.getMessage());
        }
        
     
    HttpRequest req2 = new HttpRequest();
    //I actually store the endpoint in the same custom setting and build dynamically, but for purposes of demo:
        req2.setEndpoint(oAuthUrl_1 + name);
        req2.setMethod('GET');

    //Call Bearer token Method
    //Note - unless invalidated, I believe you can store this and keep using it indefinitely, but again, to demo concept
    String authorizationHeader_1 = 'Bearer ' + stoken;
    req2.setHeader('Authorization', authorizationHeader_1);
    system.debug('authorizationHeader_1** '+ authorizationHeader_1);

    try{
    HTTPResponse res = http.send(req2);
    String sBody = res.getBody();
    system.debug('Body_2** ' + sBody);
    boolean success=true;
    JSONParser parser=JSON.createparser(res.getBody());
    while (parser.nextToken()!=null)
    {
        if(parser.getCurrentToken()== JSONToken.START_OBJECT)
        {    
            while (parser.nextToken()!=null)
            {
                if((parser.getCurrentToken()==JSONToken.FIELD_NAME) && (parser.getText()=='screen_name'))
                {
                    parser.nextToken();
                    screenname=parser.getText();
                    system.debug('screenname** '+screenname);
                    success=true;
                }
                
                if((parser.getCurrentToken()==JSONToken.FIELD_NAME) && (parser.getText()=='name')) 
                {
                    parser.nextToken();
                    username=parser.getText();
                    system.debug('username** '+username);
                }
                
                integer i = 0;
                
                if((parser.getCurrentToken()==JSONToken.FIELD_NAME) && (parser.getText()=='location'))
                {
                    parser.nextToken();
                    location=parser.getText();
                    location = '"'+location+'"';
                    system.debug('location** '+location );
                }
                
                if (success)
                {
                    if ((parser.getCurrentToken()==JSONToken.FIELD_NAME) && (parser.getText()=='description'))
                    {
                        parser.nextToken();
                        mobile=parser.getText();
                        success=false;
                        system.debug('mobile** '+mobile);
                        List<Companies> list_com=new List<Companies>();
                        Companies com=new Companies(screenname, username, location, mobile);
                        system.debug('com** '+com);
                        list_com.add(com);
                        system.debug('list_com-1** '+list_com);
                    }
                 }
                 
            }
        }
    }
    }
    catch(System.CalloutException e)
    {
        system.debug('Error_2** '+e.getMessage());
    }
        return null;
    }
    
    public List<Companies> getGenerate()
    {
        system.debug('list_com** '+list_com);
        return list_com;
    }
    
    public class Companies
    {

        String screenname;
        String username;
        String location;
        String mobile;
        
        
        public  Companies(String screename, String username, String location, String mobile)
        {
             this.screenname=screenname;
             this.username=username;
             this.location=location;
             this.mobile=mobile;   
        }
    }
}

Q1 I am getting null in list_com in a method  getGenerate().

Please solve my query?