• Donald Hursey
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 4
    Replies
I have a request to create a visualforce page to be used as a sub tab to display field values from a related object. I am using the code below but received the error "System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Equipment__c.Leasing_Company__c"

What am I missing in my extension or vf page? I'm not sure if this is the best way to accomplish what I'm trying to do so any suggestions would be helpful.
 
<apex:page standardController="Equipment__c" extensions="AgreementExtV2" lightningStylesheets="true"> 
       
 <apex:pageBlock id="agrDetails" title="Agreement Details">
     
      <apex:repeat value="{!$ObjectType.Agreements__c.FieldSets.Lease_Agreement}" var="f">
      <option value="{!$ObjectType.Agreements__c.Fields[f].localname}">{!$ObjectType.Agreements__c.Fields[f].label}</option>     
      <apex:outputField value="{!Equipment__c[f]}"/>      
     </apex:repeat>
     
  
  </apex:pageBlock>                
</apex:page>


public class AgreementExtV2 { 
public List<Agreements__c> agreement{get; set;} 
public List<Equipment__c> currentRecord{get; set;}

    public AgreementExtV2(ApexPages.StandardController controller) {
     currentRecord = [SELECT Id FROM Equipment__c WHERE Id = :ApexPages.currentPage().getParameters().get('id')];  
	 agreement = [SELECT Id, Leasing_Company__c, Lease_ID__c, Lease_Exp_Date__c, Lease_Type__c, Leased_Amount__c, Lease_Rate__c, Lease_Term__c, Lease_Payment__c, Equipment__c FROM Agreements__c Where Equipment__c = :currentRecord]; 
	} 
}



 
I have an visualforce page controller that stopped working because the code snippet below is looking for the instance name in the the url. I have another instance tha is working, and has the instance number available in the url for the visualforce page. I've checked over domains, sites, remote site settings to see if that was the issue, but didn't see anything that sttod out as the problem. Is there another way to get the instance number to be used in the tooling API url?
 
HttpRequest req = new HttpRequest();
            req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
            req.setHeader('Content-Type', 'application/json');
            
String host = System.URL.getSalesforceBaseUrl().getHost();
            Integer firstDot = host.indexOf('.')+1;
            String sUrlRewrite = 'https://'+ host.substring(firstDot,host.indexOf('.',firstDot)) + '.salesforce.com';
            req.setEndpoint(sUrlRewrite+'/services/data/v33.0/tooling/query?

 

I wanted to find out if there is a way to rollup the number of records based on the "type" picklist and then add those totals to the parent record related through a look up field. 


I have the code below which works fine to update the field "Opens" on the parent. (just included the "isInsert" part to keep the example simple)

Is there a way to do this so I wouldn't need a  seperate query for eachrecord type? These records usually come in batches from a 3rd party app.

I'm not sure how connect a query such as [select count(Id) count, activiyType__c from childObject__c group by activiyType__c] with the parent id in a map that can be used in the dml. 

any help is greatly appreciated.
 

trigger pickListCount on wbsendit__Campaign_Activity__c (after insert, after update,after delete) {

    if(trigger.isInsert){

            // list to collect query for all history records
            
            List<CMRules__Email_Tracking_Summary__c> summaryList = new List<CMRules__Email_Tracking_Summary__c>();

            for(AggregateResult agr : [SELECT count(id) ct,CMRules__Email_Tracking_Summary__c c FROM  wbsendit__Campaign_Activity__c where wbsendit__Activity__c = 'Opened' GROUP BY CMRules__Email_Tracking_Summary__c LIMIT 50000]){
                if((ID)agr.get('c')!=null){
                    CMRules__Email_Tracking_Summary__c sum = new CMRules__Email_Tracking_Summary__c(id = (ID)agr.get('c'),CMRules__Opened__c = (Integer)agr.get('ct') );
                    summaryList.add(sum);
                    }
                }
                update summaryList;
            }
}
 



 

I have a trigger (before insert, after insert) on the child of a lookup relationship. When a child is created the trigger looks to see if there is a parent record that has the same campaign name. If a parent record exists the id is added to the loopup field on the child. If a parent record doesn't exists then a new parent record is created. 

The issue is that when a new parent is created the lookup field isn't updated with the new record id.

I'm hoping someone could help point me in the right direction for handling this.

I've tried to break the update of the child record and the creation of the new record into two sections. 
if(trigger.isBefore){
             if(trigger.IsInsert || trigger.isUpdate){
                         //do update loop
            }
}else{
             //do insert loop for parent record
   }
}


 
I'm trying to write my first trigger and not having much success. I have two objects email history (wbsendit__Campaign_Activity__c) and email summary (CMRules__Email_Tracking_Summary__c). email history looks up to email summary. The trigger should look to see if the email summary exists based on a field on both objects that is a combination of the campaign name, and the contact id (green0031U00000I0R12), or create the summary record.
I haven't been able to figure out how to relate the history to an existing summary, and then update the lookup field on the email history record with the ID of the found email summary record. I am able to create a summary record with the trigger below, but it isn't adding the lookup relationship from the email history that kicked off the trigger to the new summary.
Any help with this would be much appreciated!
 
trigger EmailSummaryCreate on wbsendit__Campaign_Activity__c (after insert, after update) {

//List of summary records that needs to be created 
List<CMRules__Email_Tracking_Summary__c> SummaryToInsert = new 
List<CMRules__Email_Tracking_Summary__c>();

//    set for only the campaign names in the current context
set<string> uKeyHistory = new set<string>();
for(wbsendit__Campaign_Activity__c hKey : trigger.new){
   if(hKey.CMRules__Unique_Key__c != null){
       uKeyHistory.add(hKey.CMRules__Unique_Key__c);
   }
}

Map<id,String> matchingHistMap= new Map<id,String>();
for(CMRules__Email_Tracking_Summary__c sum : [SELECT Id, 
CMRules__Unique_Key__c 
FROM CMRules__Email_Tracking_Summary__c 
where CMRules__Unique_Key__c IN :uKeyHistory]){
matchingHistMap.put(sum.Id, sum.CMRules__Unique_Key__c);
}  

List<wbsendit__Campaign_Activity__c> historyFieldtoUpdate = new 
List<wbsendit__Campaign_Activity__c>();



 // map of existing summaries records
 Map<string, Id> uKey = new Map<string, Id>();
 for(CMRules__Email_Tracking_Summary__c u : [SELECT Id, 
 CMRules__Unique_Key__c 
 FROM CMRules__Email_Tracking_Summary__c 
 where CMRules__Unique_Key__c IN :uKeyHistory]){
   uKey.put(u.CMRules__Unique_Key__c, u.Id); 
 } 

  for(wbsendit__Campaign_Activity__c h : trigger.new){

   boolean      key1 = uKey.containsKey(h.CMRules__Unique_Key__c);
   list<string> key2 = uKey.values();
   list<string> key4 = matchingHistMap.values();
   string[]     key3 = h.CMRules__Unique_Key__c.split(':', 0);       

   if(uKey.containsKey(h.CMRules__Unique_Key__c)){   

     //update CMRules__Email_Tracking_Summary__c lookup field with Id
        for(wbsendit__Campaign_Activity__c u : trigger.new){
            if(matchingHistMap.get(u.CMRules__Unique_Key__c) != null){
                  key3 = matchingHistMap.values();

 historyFieldtoUpdate.add(matchingHistMap.get(u.CMRules__Unique_Key__c));
                }
          }

       }else {             
           //create new summary record if one doesn't exist using the campaign name and contact Id as reference
           CMRules__Email_Tracking_Summary__c s = new CMRules__Email_Tracking_Summary__c();              
           s.CMRules__Campaign_Name__c = h.name;
           s.CMRules__Contact__c = h.wbsendit__Contact__c;

          SummaryToInsert.add(s);                        
       }
   }

  try {
   insert SummaryToInsert;
   //update historyFieldUpdate;

    } catch (system.DMLexception ex) {    
  }
 }

 

I have the following button that was being used for classic. I have a script that can replace it. I'm missing how to reference the id for the masterdetail of the record where the button is located.

How do I pass the Id for the related account similar to the way it was done in the url?

classic:
url += '&CF00NG0000008ODGm=' + '{!account.Name}'.replace(regex2, "");
url += '&CF00NG0000008ODGm_lkid=' + '{!account.Id}';
url += '&00NG0000008ODGn=' + '{!account.BillingStreet}'.replace(regex, "");

Javascript

var leaseLoc = {};
            leaseLoc ['Agreement__c'] = '{!Related_Agreement__c.Id}'; 
            if('{!account}' != ''){
                
                leaseLoc ['Account__c'] = '{!account.Id}';
                leaseLoc ['Address__c'] = '{!account.BillingStreet}';

Has anyone had issues with the lightning sharing component caching the previous record? Ex. when on account record 1, clicking on sharing, then go to account record 2, click on sharing, and the information for record 1 is displayed. Using crtl + F5 prevents this, but thats not helpful to the end user. This is also production, so turning off cache settings is not an option. Below is the component we are using.


https://github.com/mshanemc/LightningSharing
I'm getting the error below trying to install an upgraded package. I turned off "Allow Sharing" option on the object, but still got the error.

Custom Object Records Missing Organization Feature: CustomObject.Sharing

 
I have a request to create a visualforce page to be used as a sub tab to display field values from a related object. I am using the code below but received the error "System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Equipment__c.Leasing_Company__c"

What am I missing in my extension or vf page? I'm not sure if this is the best way to accomplish what I'm trying to do so any suggestions would be helpful.
 
<apex:page standardController="Equipment__c" extensions="AgreementExtV2" lightningStylesheets="true"> 
       
 <apex:pageBlock id="agrDetails" title="Agreement Details">
     
      <apex:repeat value="{!$ObjectType.Agreements__c.FieldSets.Lease_Agreement}" var="f">
      <option value="{!$ObjectType.Agreements__c.Fields[f].localname}">{!$ObjectType.Agreements__c.Fields[f].label}</option>     
      <apex:outputField value="{!Equipment__c[f]}"/>      
     </apex:repeat>
     
  
  </apex:pageBlock>                
</apex:page>


public class AgreementExtV2 { 
public List<Agreements__c> agreement{get; set;} 
public List<Equipment__c> currentRecord{get; set;}

    public AgreementExtV2(ApexPages.StandardController controller) {
     currentRecord = [SELECT Id FROM Equipment__c WHERE Id = :ApexPages.currentPage().getParameters().get('id')];  
	 agreement = [SELECT Id, Leasing_Company__c, Lease_ID__c, Lease_Exp_Date__c, Lease_Type__c, Leased_Amount__c, Lease_Rate__c, Lease_Term__c, Lease_Payment__c, Equipment__c FROM Agreements__c Where Equipment__c = :currentRecord]; 
	} 
}



 
I have an visualforce page controller that stopped working because the code snippet below is looking for the instance name in the the url. I have another instance tha is working, and has the instance number available in the url for the visualforce page. I've checked over domains, sites, remote site settings to see if that was the issue, but didn't see anything that sttod out as the problem. Is there another way to get the instance number to be used in the tooling API url?
 
HttpRequest req = new HttpRequest();
            req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
            req.setHeader('Content-Type', 'application/json');
            
String host = System.URL.getSalesforceBaseUrl().getHost();
            Integer firstDot = host.indexOf('.')+1;
            String sUrlRewrite = 'https://'+ host.substring(firstDot,host.indexOf('.',firstDot)) + '.salesforce.com';
            req.setEndpoint(sUrlRewrite+'/services/data/v33.0/tooling/query?

 
Hi, I am having trouble with the "Attributes and Expressions" module from trailhead.

Here is the challenge:
Create a Lightning Component to display a single item for your packing list.
  • Create a component called campingListItem that displays the name (ui:outputText) and the three custom fields using the appropriate output components.
  • Add an attribute named 'item' for type Camping_Item__c.
I created an component named campingListItem and this is the code:
<aura:component >
    <aura:attribute name="item" type="<my_domain>__Camping_Item__c"/>
    
    <ui:outputText value="{!v.item.Name}"/>
    <ui:outputCheckbox value="{!v.item.<my_domain>__Packed__c}"/>
    <ui:outputCurrency  value="{!v.item.<my_domain>__Price__c}"/>
    <ui:outputNumber value="{!v.item.<my_domain>__Quantity__c}"/>
</aura:component>

The error that I am getting is: "Challenge Not yet complete... here's what's wrong: 
The packingListItem Lightning Component's attribute tag doesn't exist or its attributes are not set correctly."

With this, I tried to create another component, with the name "packingListItem", but It didn't work.

Can anyone help me?

Thanks,