• Chuck Burton
  • 0 Points
  • Member since 2020

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 3
I have a lightning app which has the remote site settings dynamic.
So, is it a good practice to use metadataService.class (http://technome2.blogspot.com/2017/05/creating-remote-site-settings.html) in post-installation script to add remote site settings for the org?
I'm looking for a REMOTE Salesforce Developer who has some consulting experience, can work full-time, and is open to travel. Email me at Ashley@tech2resources.com if you're interested! US Citizenship required. 

Still learning the ropes here and probably have some very ill formed code - so, any help/advice is greatly appreciated.


Here is the scenario of what I am trying to accomplish:


We have two custom objects (related via lookup field on Essay object):  Applications & Essays.  I have created a custom field on the Applications object called XEssays_On_File.  When an Essay record is added/updated, I would like the XEssays_On_File field to get updated with the number of related Essay Records. (Can't use rollup fields as this is not a master-detail relationship)


I have drafted the following code - which works for single situations - but fails mercilessly in bulk update:


trigger CountRelatedEssays on TargetX_SRMb__Essay__c (after insert, after update) {

        TargetX_SRMb__Essay__c [] ess = Trigger.new;
        String appid = null;
        appid = ess[0].TargetX_SRMb__Application__c;
        Integer i = [select count() from TargetX_SRMb__Essay__c where TargetX_SRMb__Application__c =     :appid];
        TargetX_SRMb__Application__c [] app =[select id, XEssays_On_File__c from TargetX_SRMb__Application__c where id = :appid];

        app[0].XEssays_On_File__c = i;   
        update app[0];



I would also like this to fire and update on Delete as well.


Thanks in advance for any help you can provide!