• SFDC IN
  • NEWBIE
  • 30 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 6
    Replies
Below is the code. Can anyone tell how to implement retry logic when the 2 minutes http request get timed out.
 
public static void sendOptyInfo(Set <Id> oppIdSet) {
    try{
        for (Opportunity opp: [SELECT id ,StageName, Account.Name  from Opportunity where id in: oppIdSet]){
            
            String jsonBody = JSON.serialize(new Wrapper(opp));
            HttpRequest request = new HttpRequest();
            HttpResponse response = new HttpResponse();
            
            Http http = new Http();
            
            Api_Request__c apiReq = new Api_Request__c();
            apiReq.Opportunity__c = opp.id;
            apiReq.Stage_Name__c = opp.StageName;
            apiReq.Account_Name__c = opp.Account.Name;
            
            insert apiReq;
            
            request.setEndpoint('');
            request.setHeader('Content-Type','application/json'); 
            request.setMethod('GET');
            request.setBody(jsonBody);
            request.setTimeout(120000);
            system.debug('opp json' +jsonBody);
            
            response = http.send(request);
            if (response.getStatusCode() == 200) {
                System.debug('Response-' + response);
                Object results = (Object) JSON.deserializeUntyped(response.getBody());
                
            }
        }
        
    }
    catch(System.CalloutException e){
        System.debug('Error-' + e.getMessage());   
    }
}

 
Hi folks,

I am displaying the records from the custom object test__c using html table in LWC. 
I am using this below tag to iterate over the list of records.

<tbody>
<template for:each={testList} for:item="test">
<tr key={test.Id}>
<td>
{data}
</td>

I want to access the current item (for:item="test") in js file.

Like, in js, I am giving

@track record = {};
@track field;

I want (for:item="test") record data to populate in the @track record property.

Can anyone help me with this ?


 
Hi folks,

I am stuck with increasing the code coverage for the below Trigger. The Trigger uses the custom metadata for activation.

trigger testTrigger on customObject (after insert) {
    if(!TriggerActivationClass.checkActivationStatus('testTrigger')){
        return;
    }
    
    if(Trigger.isAfter && Trigger.isInsert){
         testTriggerHandler.someMethod(Trigger.New);    
    }
}


Below is the TriggerActivationClass class:

public with sharing class TriggerActivationClass {
    
    public static boolean checkActivationStatus(String str){
        Boolean defaultValue = false;
        Map<String,Boolean> result = new Map<String,Boolean>();
        if(Schema.customMetadata__mdt.getSObjectType().getDescribe().isAccessible()){
            customMetadata__mdt[] triggerActivation = [Select isActive__c, DeveloperName, MasterLabel from customMetadata__mdt];
            
            if(triggerActivation!= null && !triggerActivation.isEmpty()){
                for(customMetadata__mdt ta : triggerActivation){
                    result.put(ta.DeveloperName, ta.isActive__c); 
                }        
                return result.get(str);
            }  
        }                
        return defaultValue;
    }
}


I am stuck with writing the test class for the below code from the above trigger:

if(!TriggerActivationClass.checkActivationStatus('testTrigger')){
        return;


If anyone can help?

Thanks.
Hi folks,

I am creating a list of Accounts vf page and showing related contact list for each Accoount record. Below is the VF code and Controller class that I am using.

VF page -
<apex:page standardController="Account" extensions="C9">
    <apex:form >
        <apex:pageBlock >
            <p align="center">
                <apex:commandButton action="{!step1}" value="Create New"/>
            </p>
            <apex:pageBlockTable value="{!acts}" var="a" title="Account">
              <apex:column headerValue="List of Accounts">
               <apex:commandLink rerender="contactDetails" value="{!a.Name}" action="{!ContactLists}" id="details">
                 <apex:param name="id" value="{!a.id}"/>
               </apex:commandLink>
              </apex:column>
            </apex:pageBlockTable>
            
            <apex:commandButton rendered="{!setCon.hasPrevious}" value="First" action="{!setCon.first}"/>
            <apex:commandButton rendered="{!setCon.hasPrevious}" value="Previous" action="{!setCon.previous}"/>
            <apex:outputText rendered="{!(setCon.pageNumber * setCon.pageSize) < setCon.ResultSize}" value="{!setCon.pageNumber * setCon.pageSize} Of {!setCon.ResultSize}"></apex:outputText>
            <apex:outputText rendered="{!(setCon.pageNumber * setCon.pageSize) >= setCon.ResultSize}" value="{!setCon.ResultSize} Of {!setCon.ResultSize}"></apex:outputText>
           
            <apex:commandButton rendered="{!setCon.hasNext}" value="Next" action="{!setCon.next}"/>
           
            <apex:commandButton rendered="{!setCon.hasNext}" value="Last" action="{!setCon.last}"/>    
        </apex:pageBlock>
        
        
        <apex:pageBlock title="Contact">
            <apex:pageBlockButtons location="top">
                <apex:commandButton value="Delete" action="{!DeleteChecked}" />
            </apex:pageBlockButtons>
           <apex:outputPanel id="contactDetails">
             <apex:pageBlockTable value="{!contactsWrapper}" var="con" id="contactswrapper" title="Contact">
                 <apex:column >
                    <apex:inputCheckbox value="{!con.checked}" />
                 </apex:column>
                 <apex:column value="{!con.contact.Name}" />
                 <apex:column value="{!con.contact.Phone}" />
                 <apex:column value="{!con.contact.Email}" />
             </apex:pageBlockTable>
           </apex:outputPanel>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Controller :-

public class C9 {

    public PageReference Account() {
        return null;
    }


    public C9(ApexPages.StandardController controller) {

    }

    
    public ApexPages.StandardSetController setCon {
        get {
            if(setCon == null) {
                setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
                      [select Name, ID  from Account]));
            }
            return setCon;
        }
        set;
    }

    public List<Account> getacts() {
         setCon.setpagesize(10);
         return (List<Account>) setCon.getRecords();
    }
 
        Account account;
        public Account getAccount() {
          if(account == null) account = new Account();
          return account;
       }
       
       public PageReference step1() {
          return Page.v2;
       }
       
       public PageReference save() {
          insert account;
          PageReference v2Page = new ApexPages.StandardController(account).view();
          v2Page.setRedirect(true);
          return Page.v9;
       }
       
       public List<ContactWrapper> contactsWrapper {get;set;}
       public PageReference ContactLists()
       {
       System.debug('The value is:' + contact.Name);
       if (ApexPages.currentPage().getParameters().get('id') != null)
       for (Contact contact : [Select id,Name,Phone,Email from contact where accountId =: ApexPages.currentPage().getParameters().get('id')]){
       contactsWrapper.add(new ContactWrapper(contact,false));
         }
       return null;
       
       }
       public class ContactWrapper {
       public Contact contact {get; set;}
       public Boolean checked {get; set;}
       public ContactWrapper(Contact contact, Boolean checked){
        this.contact = contact;
        this.checked = checked;
        }
      }
    public list <Contact> dltcontacts {get;set;}
    public PageReference DeleteChecked(){    
    dltcontacts=new list<contact>();
    for(ContactWrapper cc: contactsWrapper){
        if(cc.checked){
            dltcontacts.add(cc.contact);
        }
      }
      delete dltcontacts;
      return null;        
    }
}

When I am clicking on Account record to get the related contact list - it is showing the following error

System.NullPointerException: Attempt to de-reference a null object

Error is in expression '{!ContactLists}' in page v9: Class.C9.ContactLists: line 52, column 1
Class.C9.ContactLists: line 52, column 1

Can anyone help me in solving this?
 
Hi,
Can anyone tell me how we can export feed placed on any account record as PDF. I want to do this via custom Button that will export the feed in tas pdf ?
Hi,

I have created a visualforce page that shows the lists of al the Accounts in my org. Now I have to display the count of hits this page has? I think we can create a custom object for this but since I am new to this I don't know the exact way to do this. Can anyone help me with this ?

Below is how I created the Visualforce page.

<apex:page standardController="Account" recordSetVar="accounts" sidebar="false">
    <apex:pageBlock title="List of Accounts">
        <apex:form >
          <apex:pageBlockTable value="{!accounts}" var="acct" id="list">
            <apex:column value="{!acct.Name}"/>
            <apex:column value="{!acct.type}"/>
            <apex:column value="{!acct.billingCountry}" />
            <apex:column value="{!acct.shippingCountry}"/>
            <apex:column value="{!acct.createdById}"/>
          </apex:pageBlockTable>
        </apex:form>
      </apex:pageBlock>
</apex:page>
 
Hi folks,

I am displaying the records from the custom object test__c using html table in LWC. 
I am using this below tag to iterate over the list of records.

<tbody>
<template for:each={testList} for:item="test">
<tr key={test.Id}>
<td>
{data}
</td>

I want to access the current item (for:item="test") in js file.

Like, in js, I am giving

@track record = {};
@track field;

I want (for:item="test") record data to populate in the @track record property.

Can anyone help me with this ?


 
Hi folks,

I am creating a list of Accounts vf page and showing related contact list for each Accoount record. Below is the VF code and Controller class that I am using.

VF page -
<apex:page standardController="Account" extensions="C9">
    <apex:form >
        <apex:pageBlock >
            <p align="center">
                <apex:commandButton action="{!step1}" value="Create New"/>
            </p>
            <apex:pageBlockTable value="{!acts}" var="a" title="Account">
              <apex:column headerValue="List of Accounts">
               <apex:commandLink rerender="contactDetails" value="{!a.Name}" action="{!ContactLists}" id="details">
                 <apex:param name="id" value="{!a.id}"/>
               </apex:commandLink>
              </apex:column>
            </apex:pageBlockTable>
            
            <apex:commandButton rendered="{!setCon.hasPrevious}" value="First" action="{!setCon.first}"/>
            <apex:commandButton rendered="{!setCon.hasPrevious}" value="Previous" action="{!setCon.previous}"/>
            <apex:outputText rendered="{!(setCon.pageNumber * setCon.pageSize) < setCon.ResultSize}" value="{!setCon.pageNumber * setCon.pageSize} Of {!setCon.ResultSize}"></apex:outputText>
            <apex:outputText rendered="{!(setCon.pageNumber * setCon.pageSize) >= setCon.ResultSize}" value="{!setCon.ResultSize} Of {!setCon.ResultSize}"></apex:outputText>
           
            <apex:commandButton rendered="{!setCon.hasNext}" value="Next" action="{!setCon.next}"/>
           
            <apex:commandButton rendered="{!setCon.hasNext}" value="Last" action="{!setCon.last}"/>    
        </apex:pageBlock>
        
        
        <apex:pageBlock title="Contact">
            <apex:pageBlockButtons location="top">
                <apex:commandButton value="Delete" action="{!DeleteChecked}" />
            </apex:pageBlockButtons>
           <apex:outputPanel id="contactDetails">
             <apex:pageBlockTable value="{!contactsWrapper}" var="con" id="contactswrapper" title="Contact">
                 <apex:column >
                    <apex:inputCheckbox value="{!con.checked}" />
                 </apex:column>
                 <apex:column value="{!con.contact.Name}" />
                 <apex:column value="{!con.contact.Phone}" />
                 <apex:column value="{!con.contact.Email}" />
             </apex:pageBlockTable>
           </apex:outputPanel>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Controller :-

public class C9 {

    public PageReference Account() {
        return null;
    }


    public C9(ApexPages.StandardController controller) {

    }

    
    public ApexPages.StandardSetController setCon {
        get {
            if(setCon == null) {
                setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
                      [select Name, ID  from Account]));
            }
            return setCon;
        }
        set;
    }

    public List<Account> getacts() {
         setCon.setpagesize(10);
         return (List<Account>) setCon.getRecords();
    }
 
        Account account;
        public Account getAccount() {
          if(account == null) account = new Account();
          return account;
       }
       
       public PageReference step1() {
          return Page.v2;
       }
       
       public PageReference save() {
          insert account;
          PageReference v2Page = new ApexPages.StandardController(account).view();
          v2Page.setRedirect(true);
          return Page.v9;
       }
       
       public List<ContactWrapper> contactsWrapper {get;set;}
       public PageReference ContactLists()
       {
       System.debug('The value is:' + contact.Name);
       if (ApexPages.currentPage().getParameters().get('id') != null)
       for (Contact contact : [Select id,Name,Phone,Email from contact where accountId =: ApexPages.currentPage().getParameters().get('id')]){
       contactsWrapper.add(new ContactWrapper(contact,false));
         }
       return null;
       
       }
       public class ContactWrapper {
       public Contact contact {get; set;}
       public Boolean checked {get; set;}
       public ContactWrapper(Contact contact, Boolean checked){
        this.contact = contact;
        this.checked = checked;
        }
      }
    public list <Contact> dltcontacts {get;set;}
    public PageReference DeleteChecked(){    
    dltcontacts=new list<contact>();
    for(ContactWrapper cc: contactsWrapper){
        if(cc.checked){
            dltcontacts.add(cc.contact);
        }
      }
      delete dltcontacts;
      return null;        
    }
}

When I am clicking on Account record to get the related contact list - it is showing the following error

System.NullPointerException: Attempt to de-reference a null object

Error is in expression '{!ContactLists}' in page v9: Class.C9.ContactLists: line 52, column 1
Class.C9.ContactLists: line 52, column 1

Can anyone help me in solving this?
 
Hi,
Can anyone tell me how we can export feed placed on any account record as PDF. I want to do this via custom Button that will export the feed in tas pdf ?