-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
8Questions
-
4Replies
Using field set from related object to display field values on visualforce page
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]; } }
- Donald Hursey
- May 18, 2020
- Like
- 0
- Continue reading or reply
Get Instance for an org in apex class.
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?
- Donald Hursey
- November 13, 2019
- Like
- 0
- Continue reading or reply
Trigger to rollup (count) number of child records, grouped by picklist value and add to parent
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; } }
- Donald Hursey
- August 15, 2019
- Like
- 0
- Continue reading or reply
Trigger to update lookup field if parent exists, or create parent if one isn't found, and then update lookup on child with new id
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 } }
- Donald Hursey
- August 13, 2019
- Like
- 0
- Continue reading or reply
Trigger to relate a record to another when a matching field is found
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) { } }
- Donald Hursey
- August 12, 2019
- Like
- 0
- Continue reading or reply
Javascript equivalent to url += '&CF00NG0000008ODGm_lkid=' + '{!account.Id}';
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}';
- Donald Hursey
- July 30, 2019
- Like
- 0
- Continue reading or reply
Lightning sharing caching the previous record
https://github.com/mshanemc/LightningSharing
- Donald Hursey
- May 24, 2019
- Like
- 0
- Continue reading or reply
Custom Object Records Missing Organization Feature: CustomObject.Sharing
Custom Object Records Missing Organization Feature: CustomObject.Sharing
- Donald Hursey
- May 01, 2019
- Like
- 0
- Continue reading or reply
Using field set from related object to display field values on visualforce page
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]; } }
- Donald Hursey
- May 18, 2020
- Like
- 0
- Continue reading or reply
Get Instance for an org in apex class.
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?
- Donald Hursey
- November 13, 2019
- Like
- 0
- Continue reading or reply
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.
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.
<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,
- Eric Kendi Shiraishi
- June 06, 2016
- Like
- 4
- Continue reading or reply