• VishnuY
  • NEWBIE
  • 25 Points
  • Member since 2016

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 17
    Replies
Display all Child Records on Parent Object
I want to display all child records on parent object  here is my code 
But it displaying only contact records, I want to display all records which related to the parent object (it means all child objects records should display in parent Account object) please help me how to use triggers here.

Apex Code:
public class ContactsRecordsToAccounts{
  
    Public Id accID;
    public List<Contact> contactList{get;set;}
    public ContactsRecordsToAccounts(){
   contactList = new List<Contact>();
   accID=  ApexPages.currentPage().getParameters().get('acId');
   contactList =  [SELECT FirstName,LastName,Email,Phone FROM Contact WHERE AccountID = : accID];
 }
}

Visualforce Page Code:

<apex:page controller="ContactsRecordsToAccounts" sidebar="false" showHeader="false">
     <apex:pageBlock >
           <apex:pageBlockTable value="{!contactList}" var="con">
                      <apex:column value="{!con.FirstName}"/>
                       <apex:column value="{!con.LastName}"/>
                       <apex:column value="{!con.Phone}"/>
                       <apex:column value="{!con.Email}"/>
           </apex:pageBlockTable>
        </apex:pageBlock>
</apex:page>
Display all Child Records on Parent Object
I want to display all child records on parent object  here is my code 
But it displaying only contact records, I want to display all records which related to the parent object (it means all child objects records should display in parent Account object) please help me how to use triggers here.

Apex Code:
public class ContactsRecordsToAccounts{
  
    Public Id accID;
    public List<Contact> contactList{get;set;}
    public ContactsRecordsToAccounts(){
   contactList = new List<Contact>();
   accID=  ApexPages.currentPage().getParameters().get('acId');
   contactList =  [SELECT FirstName,LastName,Email,Phone FROM Contact WHERE AccountID = : accID];
 }
}

Visualforce Page Code:

<apex:page controller="ContactsRecordsToAccounts" sidebar="false" showHeader="false">
     <apex:pageBlock >
           <apex:pageBlockTable value="{!contactList}" var="con">
                      <apex:column value="{!con.FirstName}"/>
                       <apex:column value="{!con.LastName}"/>
                       <apex:column value="{!con.Phone}"/>
                       <apex:column value="{!con.Email}"/>
           </apex:pageBlockTable>
        </apex:pageBlock>
</apex:page>
Need some help, i'm in over my head.  I've got a custom field on a custom object and have the following apex running on a trigger.  I don't know how or what would be the best way to execute this field update automatically.  On one hand it would be great to exeute the trigger every night at midnight, as i will be duplicatingt he field and query for each month.  Any help or a point in the right direction would be great.
trigger WonNov on Course__c (before update) {

    Set<Id> setRecordId = new Set<Id>();
    
    for (Course__c obj : Trigger.new)
    {
        setRecordId.add(obj.id) ;
    }
    
    AggregateResult[] groupedResults = [ Select SUM (Amount) sum, Course_Lookup__c from Opportunity WHERE Courseid__c in :setRecordId AND Opportunity_Type__c ='Outing' AND Probability >94.00 AND Event_Date__c = THIS_YEAR AND Event_Month__c = '11_November' GROUP BY Course_Lookup__c ];
    
    Map<String , AggregateResult > mapAG = new Map<String , AggregateResult >();
    for(AggregateResult ar : groupedResults)
    {
        mapAG.put(String.valueOf(ar.get('Course_Lookup__c')) , ar );
    }
    
    for (Course__c obj : Trigger.new)
    {
    
        if( mapAG.containsKey(obj.id) )
        {
            AggregateResult ar = mapAG.get(obj.id);
            double sum =double.valueOf(ar.get('sum'));
            obj.Won_Nov_Outings__c = decimal.valueOf(sum);
            
        }
    }
}

 
Hello

I have a VF page making use of a controller. I have an inputcheckbox which has associated action support and calls willcallRMA function.
The function is defined in the apex class as follows.
This code is supposed to render the section opOSGN if the chkbox is checked and not render if chkbox is unchecked.
i created tihs code in a separate vf page and it works. it doesnt work here where i added it to existing vf page.

does anyone see any issue here. please let me know.

<apex:pageblockSectionItem helpText="Select will call chkbox for will call rma's">
              
                  <apex:outputlabel value="Will Call Chkbox"></apex:outputlabel>
                  <apex:inputcheckbox label="will call" value="{!willcall}"  >
                    <apex:actionSupport event="onclick" rerender="opOSGN,req,reqan,reqan1,op1"  action="{!willcallRMA}"/>
                  </apex:inputcheckbox> 
               
              </apex:pageblockSectionItem>
              <apex:pageblockSectionItem >
              
                  <apex:outputlabel value=" "></apex:outputlabel>
                  <apex:outputlabel value=" "></apex:outputlabel>
               
              </apex:pageblockSectionItem> 
              
              <apex:pageblockSectionItem >
                    <apex:outputpanel id="opOSGN">
                        <apex:outputlabel value="Defer Until Date OSGN"  rendered="{!willcallValue}"/>
                    </apex:outputpanel>
              </apex:pageblockSectionItem>
              =================
                public PageReference willcallRMA(){
       
        if(willcall)
        {
            
            willcallValue = true;
            system.debug('Here willcallvalue is true');
        }
        else
        {
            willcallValue = false;
            rma.Defer_Until__c=null;
            rma.Local_Time_for_Deferral__c='--None--';
            system.debug('here willcallvalue is false');
        } 
        return null;
    }
    
              
  • July 24, 2017
  • Like
  • 0
I have the following Apex Class and Trigger. I'm struggling to come up with a Test Class to test. Can someone please point me in the right direction. 
public class WebServiceCallout {

    @future (callout=true)
    public static void sendNotification(String name, String planId) {

        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
        System.debug('String Name'+name);
        System.debug('String Id'+planId);
        req.setEndpoint('https://devl-armadahealthdss.armadahealth.com/api/armadahealthdss/token/single');
        req.setMethod('GET');
        req.setBody('name='+EncodingUtil.urlEncode(name, 'UTF-8')+'&planId='+EncodingUtil.urlEncode(planId, 'UTF-8'));
        req.setCompressed(true); // otherwise we hit a limit of 32000

        try {
            res = http.send(req);
            System.debug(res.toString());
            System.debug('Response'+res);
            Map<string,Object> mapbody=(Map<string,Object>)JSON.deserializeUntyped(res.getbody());
            System.debug('Token'+(Integer)mapbody.get('token'));
            Integer Token = (Integer)mapbody.get('token');
            plan__c plan = [Select Id from Plan__c where Id =: planId];
            plan.registration_code__c = string.valueof(Token);
            System.debug('Reg Code'+plan.registration_code__c);
            update plan;            
        } catch(System.CalloutException e) {
            System.debug('Callout error: '+ e);
            System.debug(res.toString());
        }

    }

    // run WebServiceCallout.testMe(); from Execute Anonymous to test
    //public static testMethod void testMe() {
      // WebServiceCallout.sendNotification('My Test Customer','My City');
    }
 
trigger PlanCallToken on Plan__c (after insert) {

    for (Plan__c a : Trigger.new) {           
         // make the asynchronous web service callout 
         if(!system.isFuture() ){             
         WebServiceCallout.sendNotification(a.Name, a.Id);                
         }
    }


Hi 
Can anyone help me on this issue.

IF ({ISPICKVAL(Concert__c.Concert_Type__c , "Regular")},"https://c.ap4.visual.force.com/apex/concertbooking?sfdc.tabName=01r6F000000rqTQ")

error coming as enter url is invalid , i tried the same with google.com but showing same error .