• sai harish
  • NEWBIE
  • 35 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 18
    Replies
Hello Everyone,

I have a Lookup field to the product which is from a managed package. The Lookup filters for this field are disabled. I have a requirement to show only the active products. I can create another custom Lookup field, populate data in that field and use it, but I have some visualforce pages which are using this field. If I do this I will have to change the fields in my controller and deploy everything again. Is there any other work around for this without creating another field ?

Thanks in advance.
Hello,

I have noticed that the related Lists are not loading Properly in Classic. They load fine in Lightning. It is not an internet speed issue. I have users from other cities having same issues. Objects with less number of related lists also have the same problem. Related Lists are saying 'Loading' and they don't load. Has anything faced this kind of an issue. Not sure if there is any issue from Salesforce side or if it is internal. Please help. 

Thanks in advance.

User-added image
Hi,
I have a Lightning component which I am using in a action button. I want to use the button only for mobile as I already have a visualforce Page for Lightning. Is it possible to show the action button only for mobile and hide it in Lightning ?

Thanks in advance. 
Sai.
Hello,

I have two Lists of AggregateResults by month and I am using a where condition for Year so that I will get values from Month 1 to Month 12. I have created a Dummy formula field in my First object and made it to Zero. 

Is there a way to map months in both the Lists and get the Amount from second list and put it in the 1st List. The Amount in the first List will always be Zero. 
Thanks in advance!!
Public Class Test{

Public Void Test(){
List<AggregateResult> ar = [SELECT calendar_month(Forecast_Date__c) month, sum(Base_Line__c) Baseline, sum(Forecast__c)Forecast, sum(Actual__c)Actual, sum(Dummy_Amount_For_Chart__c)Amount From Revenue_Forecast__c WHERE calendar_year(Forecast_Date__c) = 2018 Group by calendar_month(Forecast_Date__c) ORDER BY calendar_month(Forecast_Date__c)];

List<AggregateResult> ar1 = [Select calendar_month(Close_Date__c) month, sum(Amount__c)Amount From Bid__c WHERE calendar_year(Close_Date__c) = 2018 GROUP BY calendar_month(Close_Date__c) ORDER BY calendar_month(Close_Date__c)];
}
}

 
Hello,

I am trying to use a wrapper class to show some values in a HTML table. I am trying to use Revenue and Revenue1 in the page. My page saves fine but when I try to preview, I am getting the following error, Invalid field rev for AggregateResult. When I try to use the Name field, it works fine.
Public Class SalesBudgetReport1{

Public List<RevenueForecast> RevenueForecasts {get; set;}

Public SalesBudgetReport1(){
    List<AggregateResult>  arList = new List<AggregateResult>(); 
    
List<AggregateResult> ar = [Select PM__c PM, sum(Revenue__c) rev from Revenue_Forecast__c WHERE PM__c!= null AND calendar_year(Forecast_Date__c ) = 2018 AND calendar_month(Forecast_Date__c ) = 1 Group By  PM__c];
List<AggregateResult> ar1 = [Select PM__c PM, sum(Revenue__c) revenue1 from Revenue_Forecast__c WHERE PM__c!= null AND calendar_year(Forecast_Date__c ) = 2018 AND calendar_month(Forecast_Date__c ) = 2 Group By  PM__c];
List<AggregateResult> ar2 = [Select PM__c PM, sum(Revenue__c) revenue2 from Revenue_Forecast__c WHERE PM__c!= null AND calendar_year(Forecast_Date__c ) = 2018 AND calendar_month(Forecast_Date__c ) = 3 Group By  PM__c];
List<AggregateResult> ar3 = [Select PM__c PM, sum(Revenue__c) revenue3 from Revenue_Forecast__c WHERE PM__c!= null AND calendar_year(Forecast_Date__c ) = 2018 AND calendar_month(Forecast_Date__c ) = 4 Group By PM__c];
List<AggregateResult> ar4 = [Select PM__c PM, sum(Revenue__c) revenue4 from Revenue_Forecast__c WHERE PM__c!= null AND calendar_year(Forecast_Date__c ) = 2018 AND calendar_month(Forecast_Date__c ) = 5 Group By PM__c];
List<AggregateResult> ar5 = [Select PM__c PM, sum(Revenue__c) revenue5 from Revenue_Forecast__c WHERE PM__c!= null AND calendar_year(Forecast_Date__c ) = 2018 AND calendar_month(Forecast_Date__c ) = 6 Group By PM__c];
List<AggregateResult> ar6 = [Select PM__c PM, sum(Revenue__c) revenue6 from Revenue_Forecast__c WHERE PM__c!= null AND calendar_year(Forecast_Date__c ) = 2018 AND calendar_month(Forecast_Date__c ) = 7 Group By PM__c];
List<AggregateResult> ar7 = [Select PM__c PM, sum(Revenue__c) revenue7 from Revenue_Forecast__c WHERE PM__c!= null AND calendar_year(Forecast_Date__c ) = 2018 AND calendar_month(Forecast_Date__c ) = 8 Group By PM__c];
List<AggregateResult> ar8 = [Select PM__c PM, sum(Revenue__c) revenue8 from Revenue_Forecast__c WHERE PM__c!= null AND calendar_year(Forecast_Date__c ) = 2018 AND calendar_month(Forecast_Date__c ) = 9 Group By PM__c];
List<AggregateResult> ar9 = [Select PM__c PM, sum(Revenue__c) revenue9 from Revenue_Forecast__c WHERE PM__c!= null AND calendar_year(Forecast_Date__c ) = 2018 AND calendar_month(Forecast_Date__c ) = 10 Group By PM__c];
List<AggregateResult> ar10 = [Select PM__c PM, sum(Revenue__c) revenue10 from Revenue_Forecast__c WHERE PM__c!= null AND calendar_year(Forecast_Date__c ) = 2018 AND calendar_month(Forecast_Date__c ) = 11 Group By PM__c];
List<AggregateResult> ar11 = [Select PM__c PM, sum(Revenue__c) revenue11 from Revenue_Forecast__c WHERE PM__c!= null AND calendar_year(Forecast_Date__c ) = 2018 AND calendar_month(Forecast_Date__c ) = 12 Group By PM__c];
 
 arList.addAll(ar) ; 
 arList.addAll(ar1) ; 
 arList.addAll(ar2) ; 
 arList.addAll(ar3) ; 
 arList.addAll(ar4) ; 
 arList.addAll(ar5) ; 
 arList.addAll(ar6) ; 
 arList.addAll(ar7) ; 
 arList.addAll(ar8) ; 
 arList.addAll(ar9) ; 
 arList.addAll(ar10) ; 
 arList.addAll(ar11) ; 
  
 
RevenueForecasts = new List<RevenueForecast>();
for(AggregateResult arr : arList){
RevenueForecasts.add(new RevenueForecast(arr));
}
 
}
Public class RevenueForecast{
Public String Name {get; set;}
Public Decimal Revenue{get; set; }
Public Decimal Revenue1{get; set; }

Public RevenueForecast(AggregateResult arr){
Name = (String) arr.get('PM');
Revenue = (Decimal) arr.get('rev');
Revenue1 = (Decimal) arr.get('revenue1');


}
 
}
}

  Here is my class. Any help is appreciated.


 
Hello,

I am trying to use a HTML table and I need to show some values by each month. I am planning to use 12 queries, 1 for each column. I can use only 1 apex:repeat for the table to maintain consistency in the table. I am kind of a beginer in salesforce. I am not understanding how to wrap all these queries with 1 wrapper class. I am attaching a screenshot of what I am looking for. Any help is Appreciated !!  
 
Public Class SalesBudgetReport1{

Public List<RevenueForecast> RevenueForecasts {get; set;}

Public SalesBudgetReport1(){
List<AggregateResult> ar = [Select PM__c, sum(Revenue__c) rev from Revenue_Forecast__c WHERE PM__c!= null AND calendar_year(Forecast_Date__c ) = 2018 AND calendar_month(Forecast_Date__c ) = 1 Group By  PM__c];

List<AggregateResult> ar1 = [Select PM__c, sum(Revenue__c) revenue1 from Revenue_Forecast__c WHERE PM__c!= null AND calendar_year(Forecast_Date__c ) = 2018 AND calendar_month(Forecast_Date__c ) = 2 Group By  PM__c];

List<AggregateResult> ar2 = [Select PM__c, sum(Revenue__c) revenue2 from Revenue_Forecast__c WHERE PM__c!= null AND calendar_year(Forecast_Date__c ) = 2018 AND calendar_month(Forecast_Date__c ) = 3 Group By  PM__c];

RevenueForecasts = new List<RevenueForecast>();
for(AggregateResult arr : ar){
RevenueForecasts.add(new RevenueForecast(arr));
}}

Public class RevenueForecast{
Public String Name {get; set;}
Public Decimal Revenue{get; set; }
Public Decimal Revenue1{get; set; }

Public RevenueForecast(AggregateResult arr){
Name = (String) arr.get('PM__c');
Revenue = (Decimal) arr.get('rev');
}}}
User-added image
 
Hi. I have a wrapper class. I am trying to pass Id from One object to a different object but whn I use a standard Controller my VF page does not show any records. It works fine when I am not using a standard controller and I hardcode the record id's. I need to take some values and insert the records in to a different object. And I would also like someone to critique my code. Please let me know if I am doing ok with my code preactice. I am also sharing my pageReference method. Here is my code. 

public class WO_Proj{

ApexPages.StandardController controller;
Private Work_Order__c wotsk;

Public WO_Proj(ApexPages.StandardController stdController){
   this.wotsk = (Work_Order__c)stdController.getRecord();
    system.debug('id = ' + wotsk.id);
   this.Controller = Controller;
}


Public List<Work_Order__c> workorder;
Public List<WrapProjBudgets> wrapProjBudgetsList {get; set; }
Public List<AcctSeed__Project_Task__c> selectedprojbudgets{get; set; }

Public List<Work_Order__c> getworkOrder(){
workorder = [Select Name,Project__c, Budgeted_Hrs__c from Work_Order__c Limit 10];
system.debug('Work order-------->' + workorder);
return workorder;
}


public WO_Proj(){
if(wrapProjBudgetsList == null){
   wrapProjBudgetsList = new List<WrapProjBudgets>();
   for(AcctSeed__Project_Task__c p : [Select Id, Name, AcctSeed__Budgeted_Hours__c, AcctSeed__Project__c from AcctSeed__Project_Task__c Where AcctSeed__Project__c = :workorder[0].Project__c]){
   wrapProjBudgetsList.add(new WrapProjBudgets(p));
   }
   

}
}
Public Void ProcessSelected(){
selectedprojbudgets = new List<AcctSeed__Project_Task__c>();
for(WrapProjBudgets wrapProjBudgets1 : wrapProjBudgetsList){
   if(wrapProjBudgets1.selected == true){
      selectedprojbudgets.add(wrapProjBudgets1.pb);
   }
}
}
Public class WrapProjBudgets{
   Public AcctSeed__Project_Task__c pb {get; set;}
   Public Boolean selected {get; set; }
   Public WrapProjBudgets(AcctSeed__Project_Task__c p){
    pb = p;
    selected = false;
   }
}
}


This is my method for inserting records. If I am able to pass Id's in above code I can use my Page reference method to insert the selected records. 

public PageReference savee(){

 List<Work_Task__c> wtList = new List<Work_Task__c>();
 for(AcctSeed__Project_Task__c pb : ProjBudgets){
 
Work_Task__c Wt = new Work_Task__c();
wt.Name = pb.Name;
wt.Budgeted_Hrs__c = pb.AcctSeed__Budgeted_Hours__c;
wt.Project_Budget__c = pb.Id;
wt.Project__c = pb.AcctSeed__Project__c;
wt.Work_Order__c = wotsk.id;
wtList.add(wt); 
}
insert wtList;
return null;
}
 
Hi. I need some help with my Trigger. I am trying to create a trigger on the child and get an AggregateResult from child and trying to update a parent field. (AcctSeedERP__Purchase_Order_Line__c), this is my child object which has a look up to AcctSeed__Project_Task__c. It works when I hard code the Id values. Please help me pass the parent Id values dynamically. Thanks in advance.

trigger Update_Commited_Subcontractor on AcctSeedERP__Purchase_Order_Line__c (after insert, after update) {
    if((trigger.isinsert && trigger.isafter) || (trigger.isupdate && trigger.isafter)){
    AcctSeedERP__Purchase_Order_Line__c pol = trigger.new[0];
      
AggregateResult[] ar = [Select sum(AcctSeedERP__Total__c)sum from AcctSeedERP__Purchase_Order_Line__c where AcctSeedERP__Project_Task__r.Id = :pol.Id ];  
        system.debug('AggregatedResult========>>>>>'+ ar);
        Decimal sum = (Decimal) ar[0].get('sum');
        system.debug('Sum======>>>>>>'+sum);
        AcctSeed__Project_Task__c pb = new AcctSeed__Project_Task__c();
        pb.Id = pb.Id;
        pb.Commited_Sub__c = (Decimal) ar[0].get('sum');
        update pb;
    
    }
}
This might be simple but I am unable to figure out what I am missing. I need to get Project Managers from the VF page and pass them in to my Query. Here is my Apex class and my VF page.
Class :
public class ProjectsFilterByDates{
public ProjectsFilterByDates(ApexPages.StandardController stdController) {
  }
  Date StartDate;
  Date EndDate;
  public String DateStringProperty{get;set;}  
  List<AcctSeed__Project__c> results;
  String[] ProjectManagers = new String[]{};
  public Date getstartDate(){
  return StartDate;
  }
  public Date getEndDate(){
  return EndDate;
  }
  Public List<AcctSeed__Project__c> getresults(){
  return results;
  }
  public void setStartDate(Date input){
  StartDate = input;
  }
  public void setEndDate(Date input1){
  EndDate = input1;
  }
  
     public List<SelectOption> getListOfUser(){
     List<User> Users = [select Name from user Where Project_Manager__c = true Order By Name ASC] ;
     List<SelectOption> options = new List<SelectOption>();
        for(User u : Users)
               {
                options.add(new SelectOption(u.Id , u.Name));
               }
                  return options;
                  }
  public String[] getProjectManagers (){
  return ProjectManagers;
  }
  public void setProjectManagers (string[] ProjectManagers){
  this.ProjectManagers = ProjectManagers;
  }   

  public PageReference Search(){
  results = [SELECT Name,UserID__c,AcctSeed__Account__r.Name,Date_Created__c,Construction_Manager__r.Name,AcctSeedERP__Manufactured_Product__r.Name,Project_Manager__c FROM AcctSeed__Project__c WHERE Date_Created__c >= :StartDate AND Date_Created__c <= :EndDate AND Project_Manager__c =:ProjectManagers order by Date_Created__c desc ];
  return null;
  }
}
VF Page:
<apex:page Standardcontroller="AcctSeed__Project__c" extensions="ProjectsFilterByDates" showHeader="false" sidebar="false" docType="html-5.0" language="en_Us" >
<apex:form >
<apex:pageBlock >
 Start Date: <apex:input type="date" value="{!StartDate}"/>
 End Date: <apex:input type="date" value="{!EndDate}"/>
<apex:selectList value="{!ProjectManagers}" size="5" multiselect="true">
<apex:selectOptions value="{!ListOfUser}"/>
</apex:selectList><p/>

<apex:commandButton value="Search For Projects" action="{!search}"/>
<apex:pageBlockTable value="{!results}" var="p">
<apex:column value="{!p.Name}"/>
<apex:column value="{!p.AcctSeed__Account__r.Name}"/>
<apex:column value="{!p.Project_Manager__c}"/>
<apex:column value="{!p.Date_Created__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Please help me write Test class. I am using this class in a Lightning component to update a Record in a detail page. I am new to salesforce and unable to figure out how to write test class and get my class covered. Thanks in advance.

Apex Class:
public class ApproveAP {
    @AuraEnabled
    public static String updatepayable(String payId) {
        String msg = 'Approved';
        try {
            update new AcctSeed__Account_Payable__c(id = payId, AcctSeed__Status__c = 'Approved');
        }
        catch(Exception e) {
            msg = e.getMessage();
        }
        return msg;
    }
}
Test Class : 
@isTest
private class TestApproveAP
   {
 private static Testmethod string updatepayable(){
   string msg = 'Test Message';
      List<AcctSeed__Account_Payable__c> accList = new List<AcctSeed__Account_Payable__c>();
      accList.add(
      new AcctSeed__Account_Payable__c(
       id='tempId',
      AcctSeed__Status__c = 'Waiting for Approval'
      )
      );
      insert accList;
  
  try{
  update new AcctSeed__Account_Payable__c(id = 'tempId', AcctSeed__Status__c = 'Approved');
  }catch(Exception e){msg=e.getMessage();
   ApproveAP app = new ApproveAP();
   }
  return msg;
 }
 }
Hello,

I have noticed that the related Lists are not loading Properly in Classic. They load fine in Lightning. It is not an internet speed issue. I have users from other cities having same issues. Objects with less number of related lists also have the same problem. Related Lists are saying 'Loading' and they don't load. Has anything faced this kind of an issue. Not sure if there is any issue from Salesforce side or if it is internal. Please help. 

Thanks in advance.

User-added image
Hello,

I am trying to use a wrapper class to show some values in a HTML table. I am trying to use Revenue and Revenue1 in the page. My page saves fine but when I try to preview, I am getting the following error, Invalid field rev for AggregateResult. When I try to use the Name field, it works fine.
Public Class SalesBudgetReport1{

Public List<RevenueForecast> RevenueForecasts {get; set;}

Public SalesBudgetReport1(){
    List<AggregateResult>  arList = new List<AggregateResult>(); 
    
List<AggregateResult> ar = [Select PM__c PM, sum(Revenue__c) rev from Revenue_Forecast__c WHERE PM__c!= null AND calendar_year(Forecast_Date__c ) = 2018 AND calendar_month(Forecast_Date__c ) = 1 Group By  PM__c];
List<AggregateResult> ar1 = [Select PM__c PM, sum(Revenue__c) revenue1 from Revenue_Forecast__c WHERE PM__c!= null AND calendar_year(Forecast_Date__c ) = 2018 AND calendar_month(Forecast_Date__c ) = 2 Group By  PM__c];
List<AggregateResult> ar2 = [Select PM__c PM, sum(Revenue__c) revenue2 from Revenue_Forecast__c WHERE PM__c!= null AND calendar_year(Forecast_Date__c ) = 2018 AND calendar_month(Forecast_Date__c ) = 3 Group By  PM__c];
List<AggregateResult> ar3 = [Select PM__c PM, sum(Revenue__c) revenue3 from Revenue_Forecast__c WHERE PM__c!= null AND calendar_year(Forecast_Date__c ) = 2018 AND calendar_month(Forecast_Date__c ) = 4 Group By PM__c];
List<AggregateResult> ar4 = [Select PM__c PM, sum(Revenue__c) revenue4 from Revenue_Forecast__c WHERE PM__c!= null AND calendar_year(Forecast_Date__c ) = 2018 AND calendar_month(Forecast_Date__c ) = 5 Group By PM__c];
List<AggregateResult> ar5 = [Select PM__c PM, sum(Revenue__c) revenue5 from Revenue_Forecast__c WHERE PM__c!= null AND calendar_year(Forecast_Date__c ) = 2018 AND calendar_month(Forecast_Date__c ) = 6 Group By PM__c];
List<AggregateResult> ar6 = [Select PM__c PM, sum(Revenue__c) revenue6 from Revenue_Forecast__c WHERE PM__c!= null AND calendar_year(Forecast_Date__c ) = 2018 AND calendar_month(Forecast_Date__c ) = 7 Group By PM__c];
List<AggregateResult> ar7 = [Select PM__c PM, sum(Revenue__c) revenue7 from Revenue_Forecast__c WHERE PM__c!= null AND calendar_year(Forecast_Date__c ) = 2018 AND calendar_month(Forecast_Date__c ) = 8 Group By PM__c];
List<AggregateResult> ar8 = [Select PM__c PM, sum(Revenue__c) revenue8 from Revenue_Forecast__c WHERE PM__c!= null AND calendar_year(Forecast_Date__c ) = 2018 AND calendar_month(Forecast_Date__c ) = 9 Group By PM__c];
List<AggregateResult> ar9 = [Select PM__c PM, sum(Revenue__c) revenue9 from Revenue_Forecast__c WHERE PM__c!= null AND calendar_year(Forecast_Date__c ) = 2018 AND calendar_month(Forecast_Date__c ) = 10 Group By PM__c];
List<AggregateResult> ar10 = [Select PM__c PM, sum(Revenue__c) revenue10 from Revenue_Forecast__c WHERE PM__c!= null AND calendar_year(Forecast_Date__c ) = 2018 AND calendar_month(Forecast_Date__c ) = 11 Group By PM__c];
List<AggregateResult> ar11 = [Select PM__c PM, sum(Revenue__c) revenue11 from Revenue_Forecast__c WHERE PM__c!= null AND calendar_year(Forecast_Date__c ) = 2018 AND calendar_month(Forecast_Date__c ) = 12 Group By PM__c];
 
 arList.addAll(ar) ; 
 arList.addAll(ar1) ; 
 arList.addAll(ar2) ; 
 arList.addAll(ar3) ; 
 arList.addAll(ar4) ; 
 arList.addAll(ar5) ; 
 arList.addAll(ar6) ; 
 arList.addAll(ar7) ; 
 arList.addAll(ar8) ; 
 arList.addAll(ar9) ; 
 arList.addAll(ar10) ; 
 arList.addAll(ar11) ; 
  
 
RevenueForecasts = new List<RevenueForecast>();
for(AggregateResult arr : arList){
RevenueForecasts.add(new RevenueForecast(arr));
}
 
}
Public class RevenueForecast{
Public String Name {get; set;}
Public Decimal Revenue{get; set; }
Public Decimal Revenue1{get; set; }

Public RevenueForecast(AggregateResult arr){
Name = (String) arr.get('PM');
Revenue = (Decimal) arr.get('rev');
Revenue1 = (Decimal) arr.get('revenue1');


}
 
}
}

  Here is my class. Any help is appreciated.


 
Hello,

I am trying to use a HTML table and I need to show some values by each month. I am planning to use 12 queries, 1 for each column. I can use only 1 apex:repeat for the table to maintain consistency in the table. I am kind of a beginer in salesforce. I am not understanding how to wrap all these queries with 1 wrapper class. I am attaching a screenshot of what I am looking for. Any help is Appreciated !!  
 
Public Class SalesBudgetReport1{

Public List<RevenueForecast> RevenueForecasts {get; set;}

Public SalesBudgetReport1(){
List<AggregateResult> ar = [Select PM__c, sum(Revenue__c) rev from Revenue_Forecast__c WHERE PM__c!= null AND calendar_year(Forecast_Date__c ) = 2018 AND calendar_month(Forecast_Date__c ) = 1 Group By  PM__c];

List<AggregateResult> ar1 = [Select PM__c, sum(Revenue__c) revenue1 from Revenue_Forecast__c WHERE PM__c!= null AND calendar_year(Forecast_Date__c ) = 2018 AND calendar_month(Forecast_Date__c ) = 2 Group By  PM__c];

List<AggregateResult> ar2 = [Select PM__c, sum(Revenue__c) revenue2 from Revenue_Forecast__c WHERE PM__c!= null AND calendar_year(Forecast_Date__c ) = 2018 AND calendar_month(Forecast_Date__c ) = 3 Group By  PM__c];

RevenueForecasts = new List<RevenueForecast>();
for(AggregateResult arr : ar){
RevenueForecasts.add(new RevenueForecast(arr));
}}

Public class RevenueForecast{
Public String Name {get; set;}
Public Decimal Revenue{get; set; }
Public Decimal Revenue1{get; set; }

Public RevenueForecast(AggregateResult arr){
Name = (String) arr.get('PM__c');
Revenue = (Decimal) arr.get('rev');
}}}
User-added image
 
Hi. I have a wrapper class. I am trying to pass Id from One object to a different object but whn I use a standard Controller my VF page does not show any records. It works fine when I am not using a standard controller and I hardcode the record id's. I need to take some values and insert the records in to a different object. And I would also like someone to critique my code. Please let me know if I am doing ok with my code preactice. I am also sharing my pageReference method. Here is my code. 

public class WO_Proj{

ApexPages.StandardController controller;
Private Work_Order__c wotsk;

Public WO_Proj(ApexPages.StandardController stdController){
   this.wotsk = (Work_Order__c)stdController.getRecord();
    system.debug('id = ' + wotsk.id);
   this.Controller = Controller;
}


Public List<Work_Order__c> workorder;
Public List<WrapProjBudgets> wrapProjBudgetsList {get; set; }
Public List<AcctSeed__Project_Task__c> selectedprojbudgets{get; set; }

Public List<Work_Order__c> getworkOrder(){
workorder = [Select Name,Project__c, Budgeted_Hrs__c from Work_Order__c Limit 10];
system.debug('Work order-------->' + workorder);
return workorder;
}


public WO_Proj(){
if(wrapProjBudgetsList == null){
   wrapProjBudgetsList = new List<WrapProjBudgets>();
   for(AcctSeed__Project_Task__c p : [Select Id, Name, AcctSeed__Budgeted_Hours__c, AcctSeed__Project__c from AcctSeed__Project_Task__c Where AcctSeed__Project__c = :workorder[0].Project__c]){
   wrapProjBudgetsList.add(new WrapProjBudgets(p));
   }
   

}
}
Public Void ProcessSelected(){
selectedprojbudgets = new List<AcctSeed__Project_Task__c>();
for(WrapProjBudgets wrapProjBudgets1 : wrapProjBudgetsList){
   if(wrapProjBudgets1.selected == true){
      selectedprojbudgets.add(wrapProjBudgets1.pb);
   }
}
}
Public class WrapProjBudgets{
   Public AcctSeed__Project_Task__c pb {get; set;}
   Public Boolean selected {get; set; }
   Public WrapProjBudgets(AcctSeed__Project_Task__c p){
    pb = p;
    selected = false;
   }
}
}


This is my method for inserting records. If I am able to pass Id's in above code I can use my Page reference method to insert the selected records. 

public PageReference savee(){

 List<Work_Task__c> wtList = new List<Work_Task__c>();
 for(AcctSeed__Project_Task__c pb : ProjBudgets){
 
Work_Task__c Wt = new Work_Task__c();
wt.Name = pb.Name;
wt.Budgeted_Hrs__c = pb.AcctSeed__Budgeted_Hours__c;
wt.Project_Budget__c = pb.Id;
wt.Project__c = pb.AcctSeed__Project__c;
wt.Work_Order__c = wotsk.id;
wtList.add(wt); 
}
insert wtList;
return null;
}
 
Hi. I need some help with my Trigger. I am trying to create a trigger on the child and get an AggregateResult from child and trying to update a parent field. (AcctSeedERP__Purchase_Order_Line__c), this is my child object which has a look up to AcctSeed__Project_Task__c. It works when I hard code the Id values. Please help me pass the parent Id values dynamically. Thanks in advance.

trigger Update_Commited_Subcontractor on AcctSeedERP__Purchase_Order_Line__c (after insert, after update) {
    if((trigger.isinsert && trigger.isafter) || (trigger.isupdate && trigger.isafter)){
    AcctSeedERP__Purchase_Order_Line__c pol = trigger.new[0];
      
AggregateResult[] ar = [Select sum(AcctSeedERP__Total__c)sum from AcctSeedERP__Purchase_Order_Line__c where AcctSeedERP__Project_Task__r.Id = :pol.Id ];  
        system.debug('AggregatedResult========>>>>>'+ ar);
        Decimal sum = (Decimal) ar[0].get('sum');
        system.debug('Sum======>>>>>>'+sum);
        AcctSeed__Project_Task__c pb = new AcctSeed__Project_Task__c();
        pb.Id = pb.Id;
        pb.Commited_Sub__c = (Decimal) ar[0].get('sum');
        update pb;
    
    }
}
This might be simple but I am unable to figure out what I am missing. I need to get Project Managers from the VF page and pass them in to my Query. Here is my Apex class and my VF page.
Class :
public class ProjectsFilterByDates{
public ProjectsFilterByDates(ApexPages.StandardController stdController) {
  }
  Date StartDate;
  Date EndDate;
  public String DateStringProperty{get;set;}  
  List<AcctSeed__Project__c> results;
  String[] ProjectManagers = new String[]{};
  public Date getstartDate(){
  return StartDate;
  }
  public Date getEndDate(){
  return EndDate;
  }
  Public List<AcctSeed__Project__c> getresults(){
  return results;
  }
  public void setStartDate(Date input){
  StartDate = input;
  }
  public void setEndDate(Date input1){
  EndDate = input1;
  }
  
     public List<SelectOption> getListOfUser(){
     List<User> Users = [select Name from user Where Project_Manager__c = true Order By Name ASC] ;
     List<SelectOption> options = new List<SelectOption>();
        for(User u : Users)
               {
                options.add(new SelectOption(u.Id , u.Name));
               }
                  return options;
                  }
  public String[] getProjectManagers (){
  return ProjectManagers;
  }
  public void setProjectManagers (string[] ProjectManagers){
  this.ProjectManagers = ProjectManagers;
  }   

  public PageReference Search(){
  results = [SELECT Name,UserID__c,AcctSeed__Account__r.Name,Date_Created__c,Construction_Manager__r.Name,AcctSeedERP__Manufactured_Product__r.Name,Project_Manager__c FROM AcctSeed__Project__c WHERE Date_Created__c >= :StartDate AND Date_Created__c <= :EndDate AND Project_Manager__c =:ProjectManagers order by Date_Created__c desc ];
  return null;
  }
}
VF Page:
<apex:page Standardcontroller="AcctSeed__Project__c" extensions="ProjectsFilterByDates" showHeader="false" sidebar="false" docType="html-5.0" language="en_Us" >
<apex:form >
<apex:pageBlock >
 Start Date: <apex:input type="date" value="{!StartDate}"/>
 End Date: <apex:input type="date" value="{!EndDate}"/>
<apex:selectList value="{!ProjectManagers}" size="5" multiselect="true">
<apex:selectOptions value="{!ListOfUser}"/>
</apex:selectList><p/>

<apex:commandButton value="Search For Projects" action="{!search}"/>
<apex:pageBlockTable value="{!results}" var="p">
<apex:column value="{!p.Name}"/>
<apex:column value="{!p.AcctSeed__Account__r.Name}"/>
<apex:column value="{!p.Project_Manager__c}"/>
<apex:column value="{!p.Date_Created__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Please help me write Test class. I am using this class in a Lightning component to update a Record in a detail page. I am new to salesforce and unable to figure out how to write test class and get my class covered. Thanks in advance.

Apex Class:
public class ApproveAP {
    @AuraEnabled
    public static String updatepayable(String payId) {
        String msg = 'Approved';
        try {
            update new AcctSeed__Account_Payable__c(id = payId, AcctSeed__Status__c = 'Approved');
        }
        catch(Exception e) {
            msg = e.getMessage();
        }
        return msg;
    }
}
Test Class : 
@isTest
private class TestApproveAP
   {
 private static Testmethod string updatepayable(){
   string msg = 'Test Message';
      List<AcctSeed__Account_Payable__c> accList = new List<AcctSeed__Account_Payable__c>();
      accList.add(
      new AcctSeed__Account_Payable__c(
       id='tempId',
      AcctSeed__Status__c = 'Waiting for Approval'
      )
      );
      insert accList;
  
  try{
  update new AcctSeed__Account_Payable__c(id = 'tempId', AcctSeed__Status__c = 'Approved');
  }catch(Exception e){msg=e.getMessage();
   ApproveAP app = new ApproveAP();
   }
  return msg;
 }
 }