• Jay Weerappulige
  • NEWBIE
  • 14 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 14
    Questions
  • 11
    Replies
I want to populate aggregate results in Funding_Cycles_TA__c Which is a child object of Training_Agreement__c. The trigger is on Training_Plan__c which is another child object of Training_Agreement__c. I have written a trigger which get aggregate results from Training_Plan__c objects and its child objects successfully when updating a Training_Plan__c record. Actually now I have two issues
1.The aggregate values respect to Reporting_Year__c should be populated in respective Reporting_Year__c in destination object (Funding_Cycles_TA__c ).
2. achievedCredits should be incremented and populated in Achieved_Credits_to_Rpting_Yr_End__c (the value in achievedCredits should be added to the next achievedCredits and so on. My trigger is as below

trigger PopulateFCTAFromTP on Training_Plan__c (After Update, after insert, after delete) {
   
    Set<Id> TAIds = new Set<Id>();
    List< Training_Agreement__c> tasForUpdate = new List<Training_Agreement__c>();
    Training_Plan__c[] TPs = null;
    
    if(Trigger.isInsert||Trigger.isUpdate){
        TPs = Trigger.new;
    }else if(Trigger.isDelete){
        TPs = Trigger.old;
    }
    //select the Training plans
    for (Training_Plan__c TP : TPs) {
        if((TP.Training_Agreement__c != null) 
           ||(TP.TEC_Status__c=='Active') 
           ||(TP.TEC_Status__c=='Grace')
           ||(TP.TEC_Status__c=='Complete')
           ||(TP.TEC_Status__c=='On Hold') 
           ||(TP.TEC_Status__c=='Withdrawn')
           ||(TP.TEC_Status__c=='Pending Transfer')){
               TAIds.add(TP.Training_Agreement__c);
           }
    }
    //Aggregate SOQL from Funding_Cycles_TPS__c
    List<AggregateResult> agrResults =
        [SELECT 
         Reporting_Year__c reportingYear,
         sum(Achieved_Credits_Total__c) achievedCredits, 
         sum(Funded_Achieved_Credits__c) fundedCredits, 
         Training_Plan_Standard__r.Training_Plan__r.Training_Agreement__c ita
         FROM Funding_Cycles_TPS__c
         WHERE Training_Plan_Standard__r.Training_Plan__r.Training_Agreement__c in :TAIds 
         //where  Training_Plan_Standard__r.Training_Plan__r.Training_Agreement__c = 'a0w0M00000VpgtI' 
         GROUP BY Reporting_Year__c, Training_Plan_Standard__r.Training_Plan__r.Training_Agreement__c];
    
    //Corrosponding Funding_Cycles_TA__c(Child records)need to be updated from Training Agreement
    List<Funding_Cycles_TA__c>  fctasToUpdate = [Select Reporting_Year__c,
                                                Achieved_Credits_in_Rpting_Yr_Funded__c,
                                                Achieved_Credits_in_Rpting_Yr_Total__c,
                                                Achieved_Credits_to_Rpting_Yr_End__c
                                                From Funding_Cycles_TA__c
                                                where Training_Agreement__c in: TAIds order by Reporting_Year__c ];
  
    
    for (AggregateResult ar: agrResults) {
        fctasToUpdate.add(new Funding_Cycles_TA__c(Achieved_Credits_in_Rpting_Yr_Funded__c = (Decimal)ar.get('fundedCredits'), 
                                                   Achieved_Credits_in_Rpting_Yr_Total__c = (Decimal)ar.get('achievedCredits')));
                                                
    }  
    if(!tasForUpdate.isEmpty()){
        update tasForUpdate;
    }
}
I want to build a Lightning component to use communities. The component to display the users photo which display as a VF component in User object 
 
We want to test the new community we built for our external users. when internal users other than administrators login to the community they can't see their data. pages are displayed but no data.
They are using Salesforce license
I have built a community via Napili Winter 16 and I un-checked the tick box to hide header. But I now want to display it. With the Spring 17 the setting have been changed and can't enable the header now 

How can I make the standards Napili template header to be visible
Thanks in advance for any help
I have written a trigger to delete records on two objects after updating on parent object.
This is how relationship
Training_Plan__c (Parent) to STM_Computation__c (Child)
Monthly_Totals__c (Parent) to STM_Computation__c (child)
After updating on Training_Plan__c records on STM_Computation__c needs to be deleted. Any Monthly_Totals__c records associated with deleted STM_Computation__c records need to be deleted as well. But my trigger delete only STM_Computation__c. It doesn't delet associated Monthly_Totals__c records.
My trigger:

trigger STMdeleteFromWithdrawal on Training_Plan__c (After update) { Set<Id> ids = Trigger.newMap.keySet(); List<Training_Plan__c> updatedTAs = [Select Id, TEC_Status__c, (select ID, STM_Date__c, Training_Plan_Withdrawal_Date__c, Monthly_Totals_Name__c from STM_Computations__r) From Training_Plan__c where Id IN :ids]; //get collection of STM computaion records to delete List<STM_Computation__c> stmToDelete = new List<STM_Computation__c>(); for (Training_Plan__c tps : updatedTAs){ String oldValue = Trigger.oldMap.get(tps.Id).TEC_Status__c; String newValue = tps.TEC_Status__c; if(oldValue != newValue){ for (STM_Computation__c stm: tps.STM_Computations__r){ if(stm.STM_Date__c>stm.Training_Plan_Withdrawal_Date__c){ stmToDelete.add(stm); } } } } //get collection of Monthly Total ids to delete set<id> mtsIds = new set<id>(); for (STM_Computation__c stms : stmToDelete){ mtsIds.add(stms.Monthly_Totals_Name__c); } List<Monthly_Totals__c> monthlyTotalsToDelete = [Select Id From Monthly_Totals__c where Id IN :mtsIds]; //Delete STM Computation records if(!stmToDelete.isEmpty()) { delete stmToDelete; } //Delete Monthly Totals records if(!monthlyTotalsToDelete.isEmpty()) { delete monthlyTotalsToDelete; } }
Can anyone know that google docs can be open from Salesforce1 app. All attachments are listed, but google docs cannot be open but nots.

Thanks
Jay
I have built a community for our external clients. I also replaced Napili template header with Head Markup and now the nav bar is working as I wanted to. The problemI have is, as a result of new header I do not see User Profile drod down menu. I used a component wihich dispaly the running user ID. How do i get the running user Id into URL from component.

ex. <a href="https://preprod-skillsactiveaotearoa.cs52.force.com/s/settings/:userId">My Settings</a>

Thanks in advance for any help
I want to create our own header for communities using Head Markup. I have built HTML for pages as below. But I want to add My Profile and My settings, logout URLs. How do I get the dynamic User ProfileId etc onto the HTML URL?

<html>

    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1">
    </head>

    <div class="slds-context-bar">
        <nav class="slds-context-bar__secondary" role="navigation">
            <ul class="slds-grid">
                <li class="slds-context-bar__item">

                    <a href="javascript:void(0);" class="slds-context-bar__label-action" title="Home">
                        <a href="https://preprod-skillsactiveaotearoa.cs52.force.com/s/">Home</a>

                    </a>
                </li>

                <li class="slds-context-bar__item">
                    <a href="javascript:void(0);" class="slds-context-bar__label-action" title="Active Enrolments">
                        <a href="https://preprod-skillsactiveaotearoa.cs52.force.com/s/active-enrolments">Active Enrolments</a>

                    </a>
                </li>
                <li class="slds-context-bar__item">
                    <a href="javascript:void(0);" class="slds-context-bar__label-action" title="Outstanding Credit">
                        <a href="https://preprod-skillsactiveaotearoa.cs52.force.com/s/outstanding-credit">Outstanding Credit</a>

                    </a>
                </li>
                <li class="slds-context-bar__item">
                    <a href="javascript:void(0);" class="slds-context-bar__label-action" title="Menu Item 2">
                        <a href="https://preprod-skillsactiveaotearoa.cs52.force.com/s/completed-enrolments">Completed Enrolments</a>
                    </a>
                </li>
                <li class="slds-context-bar__item">
                    <a href="javascript:void(0);" class="slds-context-bar__label-action" title="Enrolments Per Year">
                        <a href="https://preprod-skillsactiveaotearoa.cs52.force.com/s/enrolments-per-year">Enrolments Per Year</a>

                    </a>
                </li>

            </ul>
            <li class="slds-context-bar__item slds-context-bar__dropdown-trigger slds-dropdown-trigger slds-dropdown-trigger--hover" aria-haspopup="true">
                <a href="javascript:void(0);" class="slds-context-bar__label-action" title="My Profile">
                     <a href="https://preprod-skillsactiveaotearoa.cs52.force.com/s/enrolments-per-year">Profile Menu</a>
                  <!--  <span class="slds-truncate">Menu Item</span> -->
                </a>
                <div class="slds-context-bar__icon-action slds-p-left--none" tabindex="0">
                    <button class="slds-button slds-button--icon slds-context-bar__button" tabindex="-1" title="Open menu item submenu">
                        <svg aria-hidden="true" class="slds-button__icon">
                            <use xlink:href="/assets/icons/utility-sprite/svg/symbols.svg#chevrondown"></use>
                        </svg>
                        <span class="slds-assistive-text">Open menu item submenu</span>
                    </button>
                </div>
                <div class="slds-dropdown slds-dropdown--right">
                    <ul class="slds-dropdown__list" role="menu">


                        <li class="slds-dropdown__item" role="presentation">
                            <a href="javascript:void(0);" role="menuitem" tabindex="-1">
                                <a href="https://preprod-skillsactiveaotearoa.cs52.force.com/s/profile/0053000000Bix3i">My Profile</a>
                                <!--<span class="slds-truncate">My Profile</span> -->
                            </a>
                        </li>
                        <li class="slds-dropdown__item" role="presentation">
                            <a href="javascript:void(0);" role="menuitem" tabindex="-1">
                                <a href="https://preprod-skillsactiveaotearoa.cs52.force.com/s/settings/0053000000Bix3i">My Settings</a>
                               <!-- <span class="slds-truncate">My Settings</span> -->
                            </a>
                        </li>
                        <li class="slds-dropdown__item" role="presentation">
                            <a href="javascript:void(0);" role="menuitem" tabindex="-1">
                                <span class="slds-truncate">My Company</span>
                            </a>
                        </li>
                        <li class="slds-dropdown__item" role="presentation">
                            <a href="javascript:void(0);" role="menuitem" tabindex="-1">
                                <a href="https://preprod-skillsactiveaotearoa.cs52.force.com/secure/logout.jsp">Logout</a>
                                <!--<span class="slds-truncate">Logout</span> -->
                            </a>
                        </li>
                    </ul>
                </div>
            </li>
        </nav>
    </div>
    <html>
I have a customer community component built with data fething from a child custom object with data from parent object as well. I want to display only none value from parent object for multiple rows from child object. I want to hide value 'A' from 2nd and 3rd rows
Column 1 Column 2
A              X
A              Y
A              Z

Can anyone helpme.
Thanks in advance
I want to use Report Chart on Community Builder to external Communities. I have created a report with chart and added to the communit page. It display all data. How do I filter data to show only for the person who loginto the Community. 

Thanks in advance for any help
I am trying to use App Exchange 'Docmation' for setting a bar chart for my communities. I get thie error when I try to entr the Apex class on the lightning setup page.
My apex class for the extract of data


global class EnrolmentsPerYearAuraController {
    @AuraEnabled
    global static List<EnrolmentQueryResults> getEnrolmentsPerYear(){
        
        //Get looged in user details
        User loggedInUser = [SELECT Id,
                             ContactId,
                             Contact.AccountId,
                             Contact.Company_Contact__c
                             FROM User
                             WHERE ID=: UserInfo.getUserId() LIMIT 1];
        System.debug('=loggedInUser===='+loggedInUser);
        
        List<AggregateResult> agrResults = [SELECT CALENDAR_YEAR(Start_date__c) startYear,
                                            Count(Id) total
                                            FROM Training_Agreement__c
                                            WHERE CALENDAR_YEAR(Start_date__c) >2011 AND
                                            (Status__c != NULL OR Non_TEC_Funded_Status__c != NULL) AND
                                            //(Company__c = 'CityFitness HO'OR parent_Company_for_community__c ='CityFitness HO')
                                            (Company_Id__c = :loggedInUser.contact.AccountId OR 
                                             Parent_Company_ID_for_Community__c = :loggedInUser.contact.AccountId)
                                            GROUP BY CALENDAR_YEAR(Start_date__c)
                                            ORDER By CALENDAR_YEAR(Start_date__c)];
        
        List<EnrolmentQueryResults> aqResults = new List<EnrolmentQueryResults>(); 
        for (AggregateResult ar: agrResults){
            aqResults.add(new EnrolmentQueryResults(ar));  
        }
        if (loggedInUser.Contact.Company_Contact__c == TRUE)   {
        return aqResults;
        }  else return NULL;
                
    }
}

global class EnrolmentQueryResults {
    @AuraEnabled
    public Integer Year {get; set;}
    @AuraEnabled
    public Integer Total {get; set;}

    //constructor
    global EnrolmentQueryResults(AggregateResult ar){
        Year = (Integer)ar.get('StartYear');
        Total = (Integer)ar.get('total');
    }
}

Thanks in advance for any help

Jay
I have setup a Apex controller to get aggregate values from a custom object. I want to display those data on a lightning bar graph (Total vs Year)

My Apex Aura controller
public class EnrolmentsPerYearAuraController {
    @AuraEnabled
    public static List<EnrolmentQueryResults> getEnrolmentsPerYear(){
        List<AggregateResult> agrResults = [SELECT CALENDAR_YEAR(Start_date__c) startYear,
                                            Count(Id) total
                                            FROM Training_Agreement__c
                                            WHERE CALENDAR_YEAR(Start_date__c) >2011 AND
                                            (Status__c != NULL OR Non_TEC_Funded_Status__c != NULL) AND
                                            (Company__c = 'CityFitness HO'OR parent_Company_for_community__c ='CityFitness HO')
                                             GROUP BY CALENDAR_YEAR(Start_date__c)
                                             ORDER By CALENDAR_YEAR(Start_date__c)];
     
         List<EnrolmentQueryResults> aqResults = new List<EnrolmentQueryResults>(); 
        for (AggregateResult ar: agrResults){
                aqResults.add(new EnrolmentQueryResults(ar));  
            }
        return aqResults;
    }
}

ublic class EnrolmentQueryResults {
    @AuraEnabled
    public String Year {get; set;}
    @AuraEnabled
    public Decimal Total {get; set;}

    //constructor
    public EnrolmentQueryResults(AggregateResult ar){
        Year = (String)ar.get('StartYear');
        Total = (Decimal)ar.get('total');
    }
}

I want Total values and Year as a bar graph according to this link
https://appexchange.salesforce.com/listingdetail?listingid=a0N30000000pvQzEAI

Thanks in advance 
jay
I have built a lightning page where I want to display summarized data from an aggregate apex method. my method has some return value problem. this is my method and I want to return Ass and Credits 
my code is below
public class OutstandingCreditAuraController {
@AuraEnabled public static List<Assessment_Schedule__c> getOutstandingCredits(){
List<AggregateResult> agrResults = [SELECT Assessor_name__c ass,
Sum(Credits__c) credits
FROM Assessment_Schedule__c
WHERE (TEC_Status__c = 'Active' OR TEC_Status__c = 'On Hold') and (Company__c = 'CityFitness HO')
Group By Assessor_name__c];

for (AggregateResult ar: agrResults){
return((decimal)ar.get('credits'));
}
}
}
I am quite new to Apex. I have a object with formula number filed I want to fet SUM of that filed group by Lookup filed. It doesn't work with SOQL query. I need to write a class and return tha data and display on a community lightnning page if the login user is the contact person of the record. I have develped the community page. The problem i have to writing the Apex controller. 
I have written a trigger to delete records on two objects after updating on parent object.
This is how relationship
Training_Plan__c (Parent) to STM_Computation__c (Child)
Monthly_Totals__c (Parent) to STM_Computation__c (child)
After updating on Training_Plan__c records on STM_Computation__c needs to be deleted. Any Monthly_Totals__c records associated with deleted STM_Computation__c records need to be deleted as well. But my trigger delete only STM_Computation__c. It doesn't delet associated Monthly_Totals__c records.
My trigger:

trigger STMdeleteFromWithdrawal on Training_Plan__c (After update) { Set<Id> ids = Trigger.newMap.keySet(); List<Training_Plan__c> updatedTAs = [Select Id, TEC_Status__c, (select ID, STM_Date__c, Training_Plan_Withdrawal_Date__c, Monthly_Totals_Name__c from STM_Computations__r) From Training_Plan__c where Id IN :ids]; //get collection of STM computaion records to delete List<STM_Computation__c> stmToDelete = new List<STM_Computation__c>(); for (Training_Plan__c tps : updatedTAs){ String oldValue = Trigger.oldMap.get(tps.Id).TEC_Status__c; String newValue = tps.TEC_Status__c; if(oldValue != newValue){ for (STM_Computation__c stm: tps.STM_Computations__r){ if(stm.STM_Date__c>stm.Training_Plan_Withdrawal_Date__c){ stmToDelete.add(stm); } } } } //get collection of Monthly Total ids to delete set<id> mtsIds = new set<id>(); for (STM_Computation__c stms : stmToDelete){ mtsIds.add(stms.Monthly_Totals_Name__c); } List<Monthly_Totals__c> monthlyTotalsToDelete = [Select Id From Monthly_Totals__c where Id IN :mtsIds]; //Delete STM Computation records if(!stmToDelete.isEmpty()) { delete stmToDelete; } //Delete Monthly Totals records if(!monthlyTotalsToDelete.isEmpty()) { delete monthlyTotalsToDelete; } }
I have a customer community component built with data fething from a child custom object with data from parent object as well. I want to display only none value from parent object for multiple rows from child object. I want to hide value 'A' from 2nd and 3rd rows
Column 1 Column 2
A              X
A              Y
A              Z

Can anyone helpme.
Thanks in advance
I want to use Report Chart on Community Builder to external Communities. I have created a report with chart and added to the communit page. It display all data. How do I filter data to show only for the person who loginto the Community. 

Thanks in advance for any help
I have built a lightning page where I want to display summarized data from an aggregate apex method. my method has some return value problem. this is my method and I want to return Ass and Credits 
my code is below
public class OutstandingCreditAuraController {
@AuraEnabled public static List<Assessment_Schedule__c> getOutstandingCredits(){
List<AggregateResult> agrResults = [SELECT Assessor_name__c ass,
Sum(Credits__c) credits
FROM Assessment_Schedule__c
WHERE (TEC_Status__c = 'Active' OR TEC_Status__c = 'On Hold') and (Company__c = 'CityFitness HO')
Group By Assessor_name__c];

for (AggregateResult ar: agrResults){
return((decimal)ar.get('credits'));
}
}
}
I am quite new to Apex. I have a object with formula number filed I want to fet SUM of that filed group by Lookup filed. It doesn't work with SOQL query. I need to write a class and return tha data and display on a community lightnning page if the login user is the contact person of the record. I have develped the community page. The problem i have to writing the Apex controller.