• Salesforce2015
  • NEWBIE
  • 105 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 44
    Questions
  • 80
    Replies
Hi Experts,

in our global actions we are using visualforce page.
But in global action it is showing Visulaforce Id not Name.

Please find below image.

User-added image

Someone help me out
Hi Experts,
 
Below are our objects and relation between them.

Objects and Relations

Trigger Requirement:
When a “partner group member” is inserted or deleted, the following logic needs to occur in the trigger.
   1. Query for related Partner Group Requirements related to the Partner Group, associated to the added/removed Partner Group Member.
   2. If there are Partner Group Requirements,
         - If a partner group member was deleted, then existing "Request" associated to "Partner Group Requirement" should be delete (i.e. Request record delete).
         - If there are no Partner Group Requirements, then do nothing.
Hi Experts,

below is my Apex Class, i need test class for my below class.
I tried see my test class, but it showing 0% Code coverage


public class SendPartnerGroupRequirementsExt {
    public String RequirementID{get;set;}
    public SendPartnerGroupRequirementsExt(ApexPages.StandardController controller) {

    }    
    public PageReference SendRequest(){
        RequirementID=ApexPages.currentPage().getParameters().get('id');
        list<Partner_Group_Requirement__c> PartgroupRequrement=[select id,Name,Partner_Group__c,Request_Type__c,Document_Type__c,Due_Date__c from Partner_Group_Requirement__c where id=:RequirementID];
        list<Request__c> ReqList=new list<Request__c>();
       for(Partner_Group_Requirement__c PGR : PartgroupRequrement){
            Request__c Req=new Request__c();
            //Req.Partner_Group__c=PGR.Partner_Group__c;
            Req.Request_Type__c=PGR.Request_Type__c;
            Req.Container_Template__c=PGR.Document_Type__c;
            Req.Due_Date__c =PGR.Due_Date__c;
            ReqList.add(Req);
            
        }
        
        if(ReqList.size()>0){
          system.debug('&&&&&sample&&&&&'+ReqList);
           insert ReqList;
           for(Request__c Req : ReqList){
               Recipient__c Recp=new Recipient__c();
               //Recp.Partner_Group__c=Req.Partner_Group__c;
               Recp.Request__c=Req.id;
               insert Recp;
               system.debug('******sampletest******'+Recp);
           } 
        }
        PageReference orderPage = new PageReference('/'+RequirementID);
        orderPage.setRedirect(true);
        return orderPage;
    }
 
}




I used below page & Class
VF Page:  SendPartnerGroupRequirements
Apex Class:  SendPartnerGroupRequirementsExt

I tried below code, it showing 0% Code Coverage. Please anyone help me for creating Test Class.


@isTest
Private class SendPartnerGroupRequirementsExtTest
{

static testMethod void SendRequest() {
Partner_Group_Requirement__c TempObj1 = new Partner_Group_Requirement__c();
TempObj1.name = 'Test record';
TempObj1.Request_Type__c = 'Form';
TempObj1.Requirement__c = 'Approved';
TempObj1.Document_Type__c = 'California Transparency of Supply Chain Act';
TempObj1.Partner_Group__c = 'testsample1';
insert TempObj1;

PageReference pageRef = Page.SendPartnerGroupRequirements;
Test.setCurrentPage(pageRef);
ApexPages.Standardcontroller sc = new ApexPages.Standardcontroller(TempObj1);
ApexPages.currentPage().getParameters().put('Id',TempObj1.id);
SendPartnerGroupRequirementsExt ec = new SendPartnerGroupRequirementsExt(sc);

}

}
Hi Experts,

below is my Apex Class, i need test class for my below class.


public class SendPartnerGroupRequirementsExt {
    public String RequirementID{get;set;}
    public SendPartnerGroupRequirementsExt(ApexPages.StandardController controller) {

    }    
    public PageReference SendRequest(){
        RequirementID=ApexPages.currentPage().getParameters().get('id');
        list<Partner_Group_Requirement__c> PartgroupRequrement=[select id,Name,Partner_Group__c,Request_Type__c,Document_Type__c,Due_Date__c from Partner_Group_Requirement__c where id=:RequirementID];
        list<Request__c> ReqList=new list<Request__c>();
       for(Partner_Group_Requirement__c PGR : PartgroupRequrement){
            Request__c Req=new Request__c();
            //Req.Partner_Group__c=PGR.Partner_Group__c;
            Req.Request_Type__c=PGR.Request_Type__c;
            Req.Container_Template__c=PGR.Document_Type__c;
            Req.Due_Date__c =PGR.Due_Date__c;
            ReqList.add(Req);
            
        }
        
        if(ReqList.size()>0){
          system.debug('&&&&&sample&&&&&'+ReqList);
           insert ReqList;
           for(Request__c Req : ReqList){
               Recipient__c Recp=new Recipient__c();
               //Recp.Partner_Group__c=Req.Partner_Group__c;
               Recp.Request__c=Req.id;
               insert Recp;
               system.debug('******sampletest******'+Recp);
           } 
        }
        PageReference orderPage = new PageReference('/'+RequirementID);
        orderPage.setRedirect(true);
        return orderPage;
    }
 
}



Thanks,
Manu
Hi Experts,

below is my Apex Class, i need test class for my below class.


public class SendPartnerGroupRequirementsExt {
    public String RequirementID{get;set;}
    public SendPartnerGroupRequirementsExt(ApexPages.StandardController controller) {

    }    
    public PageReference SendRequest(){
        RequirementID=ApexPages.currentPage().getParameters().get('id');
        list<Partner_Group_Requirement__c> PartgroupRequrement=[select id,Name,Partner_Group__c,Request_Type__c,Document_Type__c,Due_Date__c from Partner_Group_Requirement__c where id=:RequirementID];
        list<Request__c> ReqList=new list<Request__c>();
       for(Partner_Group_Requirement__c PGR : PartgroupRequrement){
            Request__c Req=new Request__c();
            //Req.Partner_Group__c=PGR.Partner_Group__c;
            Req.Request_Type__c=PGR.Request_Type__c;
            Req.Container_Template__c=PGR.Document_Type__c;
            Req.Due_Date__c =PGR.Due_Date__c;
            ReqList.add(Req);
            
        }
        
        if(ReqList.size()>0){
          system.debug('&&&&&sample&&&&&'+ReqList);
           insert ReqList;
           for(Request__c Req : ReqList){
               Recipient__c Recp=new Recipient__c();
               //Recp.Partner_Group__c=Req.Partner_Group__c;
               Recp.Request__c=Req.id;
               insert Recp;
               system.debug('******sampletest******'+Recp);
           } 
        }
        PageReference orderPage = new PageReference('/'+RequirementID);
        orderPage.setRedirect(true);
        return orderPage;
    }
 
}


Thanks in advance.

Thanks,
Manu
If user clicks on custom button VF page will create object2 and object3 records using apex class.

Object1 Fields:
X1, x2, x3, and x4

Object2 Fields:
X1, x2, and x3

Object3 fields:
X2, x3 and x4

Thanks in advance.

Thanks,
Manu
Hi experts,

I'm created VF Page with Apex class, and it fetch correct information in VF Page. But i need to diplay those values in a table.

Below is my expected Output.

User-added image
as of now i achieved like below.

User-added image

Please find my below peace of VF Page code.

<apex:outputLabel style="font-size:6pt;color:#939598;padding-top:50px" >Test Result</apex:outputLabel>
   <apex:dataTable id="table" var="v" value="{!ls_var}"    width="90%" style="height:25px;font-size:9pt;font-family: Helvetica;border-bottom:1px inset black;order-column=0.1;" cellspacing="5"><br/>&nbsp;
      <apex:column headerValue="Characteristic"  style="height:25px;font-size:9pt;font-family: Helvetica;">
         <B>
            <apex:outputLabel value="{!v.Name}" />
         </B>
      </apex:column>

   <apex:repeat value="{!ls_spec}" var="f" >

      <apex:column headerValue="{!f.name}" style="height:25px;font-size:9pt;font-family: Helvetica;border-right:1px solid #c3c3c3">
         <apex:repeat var="a" value="{!ls_wrap_spec_var}" >
            <apex:outputText value="{!a.ab}"  rendered="{!IF(AND(a.coa_temp_vab ==v,a.coa_temp_spec == f),true,false )}"/>
         </apex:repeat>
      </apex:column>
   </apex:repeat>

Anyone please sortout my issue.
Help will be appriciated.

Thanks,
Manu
Hi Experts,

I have total 3 quaries...

On Delete:
1. Query for related Recipient__c records.  If count > 0, return error (sobject.addError())
  "Please Cancel Request, or Remove Recipients before deleting"
2. Query for related Workflow_Instance__c records where Request_Status__c != 'Cancelled'.  If count > 0, return error:
  "Please Cancel Request before deleting"
On Update:
3. Query for related Workflow_Instance__c records where Request_Status__c != 'Cancelled',  If count > 0, return error:
  "You cannot edit a submitted Request"

Please modify below code.....

Trigger PreventDeletion1 on Request__c (before delete, before update)
{

 if( Trigger.isDelete ) {

   for (Request__c Pa : Trigger.Old)
   {

        list<Recipient__c> ChList1 = [select id, Request__c from Recipient__c where Request__c =: pa.id];
   
        if(ChList1.size() > 0){
            pa.adderror('Please Cancel Request, or Remove Recipients before deleting');
        }
        

        list<Workflow_Instance__c> ChList2 = [select id, Request__c from Workflow_Instance__c where Request_Status__c != 'Cancelled'];  
        
        if(ChList2.size() > 0)
        {
            pa.adderror('Please Cancel Request before deleting');
        }
   }
   
   
   elseif ( Trigger.isUpdate )       

   for (Request__c Pa : Trigger.Old)
   {

        list<Workflow_Instance__c> ChList3 = [select id, Request__c from Workflow_Instance__c where Request_Status__c != 'Cancelled'];  
        
        if(ChList3.size() > 0)
        {
            pa.adderror('You cannot edit a submitted Request');
        }       

   }
       
  }
}


Thanks,
Manu
 
Hi Experts,
 
I've one trigger to work for Before actions for Delete & Update.
 
Below is my requirement.
 
Object: Request__c
Before Trigger.....
 
On Delete:
1. Query for related Recipient__c records.  If count > 0, return error (sobject.addError())
  "Please Cancel Request, or Remove Recipients before deleting"
2. Query for related Workflow_Instance__c records where Request_Status__c != 'Cancelled'.  If count > 0, return error:
  "Please Cancel Request before deleting"
 
On Update
3. Query for related Workflow_Instance__c records where Request_Status__c != 'Cancelled',  If count > 0, return error:
  "You cannot edit a submitted Request"
 
I written two triggers for delete action (i.e. for first two points) both triggers working fine. Now combine these two triggers as one trigger and add one more action for update (i.e. 3rd query)
 
Trigger1:
 
Trigger PreventDeletion on Request__c (before delete) {
   for (Request__c Pa : Trigger.Old){
        list<Recipient__c> ChList = [select id, Request__c from Recipient__c where Request__c =: pa.id];  //list to hold child matches the parent
        if(ChList.size() > 0){
            pa.adderror('Please Cancel Request, or Remove Recipients before deleting');
        }
   }
}
 
 
 
Trigger2:
 
Trigger PreventDel on Request__c (before delete) {
   for(Request__c Pa : Trigger.Old){
        list<Workflow_Instance__c> ChList = [select id, Request__c from Workflow_Instance__c where Request_Status__c != 'Cancelled'];  //list to hold child matches the parent
        if(ChList.size() > 0){
            pa.adderror('Please Cancel Request before deleting');
        }
   }
}
 
Help will be appreciated. Thanks in advance.

Thanks,
Manu
 
Hi Experts,

I have custom Object Saving__c.
This object contains custom fields Status__c and Final_Amt__c.
Scenario:
We need to calculate All “Final_Amt__c” field values based on Status__c value “In-Progress” and display that value in custom field.
Note: All fields are in one custom object.

Please find below Image.

User-added image

Help will be appreciated, thanks in advance.

Thanks,
Manu
Hi Experts,

I need in below image yellow color line meaning.

User-added image
Hi Experts,

I need a help to understand WSDL, Webservice, and Batch Apex with Webservice. Please anyone help me.

Thanks,
Manu
Hi Experts,

In our Sandbox Organization Apex Classes are written in year 2011. Please find below images and Apex Classes information and let me know about what is exactly they do in our organization with apex code.

Below is Batch Apex Class “SubmitChecksBatch” Code:


global class SubmitChecksBatch implements Database.batchable<sObject>,Database.AllowsCallouts, Database.Stateful{

global Case cs;
global List<Fulfillment_History__c> toUpdateFulfillment = new List<Fulfillment_History__c>();
global List<Webservice_Call_Result__c> callLogs = new List<Webservice_Call_Result__c>();
global List<Task> failedCalls = new List<Task>();

global Boolean exceptionOccurred = false;
global String exceptionMessage;
global String exceptionTypeName;
 
global Database.QueryLocator start(Database.BatchableContext info){
  String query = 'Select Name, Case__c, Fulfillment_Type__c, Fulfillment_Workflow__c from Fulfillment_History__c';
  query += ' where Fulfillment_Status__c = \'Pending Request\' and Fulfillment_Type__c in (\'Check\')';
  if(UtilityClass.isBatchTestMethodExecution)
   query += ' order by createddate desc limit 1';
  return Database.getQueryLocator(query);
}

global void execute(Database.BatchableContext info, List<Fulfillment_History__c> toSubmitChecks){
  try {
   schemasDatacontractOrg200407Telerx.ClientCredentials clientCred = UtilityClass.getClientCredentials();
   tempuriOrg.BasicHttpBinding_ITlxCheckAndLetterProcessor processVar = new tempuriOrg.BasicHttpBinding_ITlxCheckAndLetterProcessor();
   schemasDatacontractOrg200407Telerx.SubmitCheckResponse submitCheckResponse = new schemasDatacontractOrg200407Telerx.SubmitCheckResponse();
  
   //Create the array of check requests
   schemasDatacontractOrg200407Telerx.ArrayOfCheckRequest chqReqArray = new schemasDatacontractOrg200407Telerx.ArrayOfCheckRequest();
   chqReqArray.CheckRequest = new List<schemasDatacontractOrg200407Telerx.CheckRequest>();
  
   Fulfillment_History__c fh = toSubmitChecks[0];
  
   // Get the Case information from the Fulfillment History record
   Case[] cases = [Select CaseNumber, RecordTypeId, Job__c, Product__c, Current_Fulfillment_Status__c, Fulfillment_Date__c, Claim_Status__c, Disposition__c, OwnerId, Calculated_Rebate__c, MEC_Transaction__c, Tax_ID__c,
    Account.Name, Practice_Address__c, Practice_Address_2__c, Practice_City__c, Practice_State__c, Practice_Zip__c,
    Patient_First_Name__c, Patient_Last_Name__c, Patient_Claim_Address_1__c, Patient_Claim_Address_2__c, Patient_Claim_City__c, State_of_Residence__c, Patient_Claim_Zip__c,
    Primary_Insured_First_Name__c, Primary_Insured_Last_Name__c, Primary_Insured_Address_1__c, Primary_Insured_Address_2__c, Primary_Insured_City__c, Primary_Insured_State__c, Primary_Insured_Zip__c from Case
    where Id = :fh.Case__c];
      
   cs = cases[0];
   String programCode;
   String caseTypeName;
   
   // Get the corresponding Job information for the Check and Letter Service Codes
         Jobs__c[] clsCodes = [Select Check_And_Letter_Service_Program_Code__c, Check_Type_Code__c from Jobs__c
              where Id = :cs.Job__c];
 
   Jobs__c clsCode = clsCodes[0];
   programCode = clsCode.Check_And_Letter_Service_Program_Code__c;
   
    // Create the Check Request to submit
   schemasDatacontractOrg200407Telerx.CheckRequest chqReqTemp = new schemasDatacontractOrg200407Telerx.CheckRequest();
  
   chqReqTemp.CheckRequestID = fh.Name;
   chqReqTemp.CheckType = clsCode.Check_Type_Code__c;
   chqReqTemp.CheckAmount = String.valueOf(cs.Calculated_Rebate__c);
  
   // Set the address of the correct Fulfillment Workflow type
   if(fh.Fulfillment_Workflow__c == 'Provider'){
    chqReqTemp.MailingAddressLine1 = cs.Practice_Address__c;
    chqReqTemp.MailingAddressLine2 = cs.Practice_Address_2__c;
    chqReqTemp.MailingAddressCity = cs.Practice_City__c;
    chqReqTemp.MailingAddressState = cs.Practice_State__c;
    chqReqTemp.MailingAddressPostalCode = cs.Practice_Zip__c;
    chqReqTemp.MailingName = cs.Account.Name;
    chqReqTemp.PayeeName = cs.Account.Name;
   
    // Create the array of custom fields
    schemasDatacontractOrg200407Telerx.ArrayOfCustomField customFieldArray = new schemasDatacontractOrg200407Telerx.ArrayOfCustomField();
    customFieldArray.CustomField = new List<schemasDatacontractOrg200407Telerx.CustomField>();
   
    // Pass the MEC Transaction ID. If there is no MEC Transaction ID on the Case then pass the Case Number.
    if(cs.MEC_Transaction__c != null)
     customFieldArray.CustomField.add(UtilityClass.createCustomWebServiceField('MEC_Transaction__c', cs.MEC_Transaction__c));
    else
     customFieldArray.CustomField.add(UtilityClass.createCustomWebServiceField('MEC_Transaction__c', cs.CaseNumber));
   
    // Pass the Tax ID if provided
    if(cs.Tax_ID__c != null)
     customFieldArray.CustomField.add(UtilityClass.createCustomWebServiceField('Tax_ID__c', cs.Tax_ID__c));

    chqReqTemp.CustomFields = customFieldArray;
   
   }
   else if(fh.Fulfillment_Workflow__c == 'Primary Insured'){
    chqReqTemp.MailingAddressLine1 = cs.Primary_Insured_Address_1__c;
    chqReqTemp.MailingAddressLine2 = cs.Primary_Insured_Address_2__c;
    chqReqTemp.MailingAddressCity = cs.Primary_Insured_City__c;
    chqReqTemp.MailingAddressState = cs.Primary_Insured_State__c;
    chqReqTemp.MailingAddressPostalCode = cs.Primary_Insured_Zip__c;
    chqReqTemp.MailingName = cs.Primary_Insured_First_Name__c + ' ' + cs.Primary_Insured_Last_Name__c;
    chqReqTemp.PayeeName = cs.Primary_Insured_First_Name__c + ' ' + cs.Primary_Insured_Last_Name__c;
   }
   else if(fh.Fulfillment_Workflow__c == 'Patient'){
    chqReqTemp.MailingAddressLine1 = cs.Patient_Claim_Address_1__c;
    chqReqTemp.MailingAddressLine2 = cs.Patient_Claim_Address_2__c;
    chqReqTemp.MailingAddressCity = cs.Patient_Claim_City__c;
    chqReqTemp.MailingAddressState = cs.State_of_Residence__c;
    chqReqTemp.MailingAddressPostalCode = cs.Patient_Claim_Zip__c;
    chqReqTemp.MailingName = cs.Patient_First_Name__c + ' ' + cs.Patient_Last_Name__c;
    chqReqTemp.PayeeName = cs.Patient_First_Name__c + ' ' + cs.Patient_Last_Name__c;
   }  
  
   // Add the check request to the array of check requests
   chqReqArray.CheckRequest.add(chqReqTemp);
  
   // This is used for the test classes since the test classes should not call out to the web service
   if(UtilityClass.isBatchTestMethodExecution) {
    submitCheckResponse.ResponseText = 'Successful Call';
    submitCheckResponse.ResponseCode = '000';
    submitCheckResponse.TransactionID = '123456789';
   }
   else {
    submitCheckResponse = processVar.submitChecks(clientCred, programCode, chqReqArray);
   }
  
   if(submitCheckResponse.ResponseCode == '000') {   
    cs.Current_Fulfillment_Status__c = 'Requested';
    cs.Fulfillment_Date__c = null;
    fh.Fulfillment_Status__c = 'Requested';
    fh.Date_Requested__c = datetime.now();
    update cs;
    toUpdateFulfillment.add(fh);
   }
  
   Webservice_Call_Result__c callLog = new Webservice_Call_Result__c();
   callLog.Case__c = cs.Id;
   callLog.Name = 'Submit Check';
   callLog.Response_Text__c = submitCheckResponse.ResponseText;
   callLog.Response_Code__c = submitCheckResponse.ResponseCode;
   callLog.Transaction_Id__c = submitCheckResponse.TransactionID;
   callLogs.add(callLog);
  
   // This is used for the test classes so we can test response codes other than '000' for creating a Task
   if(UtilityClass.isBatchTestMethodExecution) {
    submitCheckResponse.ResponseText = 'Failed Call';
    submitCheckResponse.ResponseCode = '300';
    submitCheckResponse.TransactionID = '123456789';
   }
  
   if(submitCheckResponse.ResponseCode != '000') {
    String taskDescription;
    if(submitCheckResponse.ResponseText != null)
        taskDescription += 'Response Text: ' + submitCheckResponse.ResponseText + '; ';
       if(submitCheckResponse.ResponseCode != null)
        taskDescription += 'Response Code: ' + submitCheckResponse.ResponseCode + '; ';
       if(submitCheckResponse.TransactionID != null)
        taskDescription += 'Transaction Id: ' + submitCheckResponse.TransactionID + '; ';
      
       UtilityClass.sendExceptionEmail('SubmitChecksBatch', 'Error while submitting checks for CaseNumber ' + cs.CaseNumber + '. ' + taskDescription, 'Failed Web Service Call');
    //Task tsk = UtilityClass.createTask(cs, 'Error while submitting check for the case. Please open a help desk ticket.', taskDescription, 'In Progress', 'High', 1, true);
       //failedCalls.add(tsk);
      }
  }
  catch(Exception ex) {
   exceptionOccurred = true;
   exceptionMessage = 'CaseNumber: ' + cs.CaseNumber + ' - ' + ex.getMessage();
   exceptionTypeName = ex.getTypeName();
  }
}

global void finish(Database.BatchableContext info){
  if(toUpdateFulfillment.size() > 0)
   update toUpdateFulfillment;
  if(callLogs.size() > 0)
   insert callLogs;
  if(failedCalls.size() > 0)
   insert failedCalls;
  if(exceptionOccurred)
   UtilityClass.sendExceptionEmail('Submit Check', exceptionMessage, exceptionTypeName);
}
}


Below is Schedule class “SubmitCheckSchedulableClass” Information:


User-added image


Please let me know information about above Batch and Schedule Classes.

Thanks,
Manu
Hi Experts,

I need to create a report using coding.
Data from 4 different objects with lookup relationship, group by user depending on created date in last week (Sunday to Saturday).

Please find the below image for reference.

User-added image

If need any further information, please let me know.

Thanks,
Manu
Hi Experts,

Below is my peace of VF Page Code (Pageblock Table).


<!-- table of data -->

<apex:pageBlockTable title="Time Sheets" value="{!tRecords}" var="c" id="pbt">
 <apex:column >
  <apex:facet name="header">
    <apex:facet name="header">
      <apex:inputCheckbox onclick="checkAll(this)"/>
    </apex:facet>
  </apex:facet>
  <apex:inputCheckbox value="{!c.isSelected}" rendered="{!!c.isCheckboxVisible}"/>
 </apex:column>

 <apex:column >
  <apex:facet Name="header">
    Time Card Number
  </apex:facet>
    <apex:outputLink value="/apex/ProjectWeekTimeCardNew?ptcid={!c.tTime.id}" target="_blank" >{!c.tTime.Name}</apex:outputLink>
 </apex:column>
 
 <apex:column >
   <apex:facet Name="header">
     Project Name
   </apex:facet>
     <apex:outputLink value="/{!c.tTime.Project_id__r.id}" target="_blank" >{!c.tTime.Project_id__r.Name}</apex:outputLink>
 </apex:column>                

 <apex:column value="{!c.tTime.Employee__c}"/>
 <apex:column value="{!c.tTime.Start_Date__c}"/>
 <apex:column value="{!c.tTime.End_Date__c}"/>
 <apex:column value="{!c.tTime.Total_Hours__c}"/>
 <apex:column value="{!c.tTime.Status__c}"/>
                
</apex:pageBlockTable>



Output:

User-added image


Requirement:

I need to show all green coloured checkboxes are first in table then all empty places (i.e No Checkboxes) are next.

Thanks,
Manu
 
Hi Experts,

below is my trigger, i need test class for my trigger.


trigger CreateChargeCodeAutomatically on MPM4_BASE__Milestone1_Project__c (after insert) {
    
    Set<Id> projectidWherechageCodeExist= new Set<Id>();
    Set<Id> prjIdSet= new Set<Id>();
    for(MPM4_BASE__Milestone1_Project__c prj :trigger.new){
       prjIdSet.add(prj.Id);
    }

    List<Charge_Code__c> chargeCodeList=[SELECT Id,Project__r.Id FROM Charge_Code__c WHERE ID IN :prjIdSet];
    if(chargeCodeList.size() > 0){
       for(Charge_Code__c chr :chargeCodeList){
         projectidWherechageCodeExist.add(chr.Project__c);
       }
    }

    prjIdSet.removeAll(projectidWherechageCodeExist);
    
    List<Charge_Code__c> listToCreate=new List<Charge_Code__c>();
    
    for(MPM4_BASE__Milestone1_Project__c prj :[SELECT Id FROM MPM4_BASE__Milestone1_Project__c WHERE ID IN : prjIdSet]){
       
       for(Project_Charge_Code__c chrge : [SELECT Id,Name FROM Project_Charge_Code__c ]){
            
            Charge_Code__c chrgg=new Charge_Code__c();
            chrgg.Charge_Code__c = chrge.Id;
            chrgg.Project__c = prj.Id;
            listToCreate.add(chrgg);
                   
       }
    }
    
    try{
        insert listToCreate;
    }
    catch(DmlException de){
       System.debug('@@@@SFDC::'+de);
    }

}


Thanks,
Manu
Hi Experts,

My Scenario:
1. User with system administrator profile should see an option to 'Reject' Button and “Reject Comments” the time sheet that is already in "approved" status.
2. When the system administrator rejects the timesheet, it should be changed to 'new' status and the consultant should be able to edit the hours and resubmit it.

See below image:
Approval Complete (as of now Max is 2 approvals – You can see approvers in Project record as “Level 1” and “Level 2” approvers).

User-added image
 
See below Image:
This is our requirement to enable one “Reject” button and “Reject - comment text” and cancel button is common when “Status = Approved” only.

User-added image
 
Below image: TimeCards in Approval View

User-added image
 
Below are Object and Fields data:

User-added image


First Action Item completed.
I successed to display reject button and comments on record page after "status = Approved" only for Admin user.
But when i'm click on reject, reject button function showing error.

Image: successed to display reject button and comments

User-added image
 
Below is Reject button code in class (ProjectWeekTimeCardNewController : 1566 to 1598 lines).

 
    public pageReference doReject() {
        if (ApproveRejectComments == null || ApproveRejectComments == '') {
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, 'Please enter reject comments and resubmit!! '));
            return null;
        }    
        try {    
            Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
            req1.setObjectId(pt.id);  
            Approval.ProcessWorkItemRequest pwr = new Approval.ProcessWorkItemRequest();
            List<ProcessInstance> procins;
            procins = new List<ProcessInstance>([select Id from ProcessInstance where Status = 'Pending' and TargetObjectId = :pt.id]);
 
            if(procins == null || procins.size() == 0)
                procins = new List<ProcessInstance>([select Id from ProcessInstance where Status = 'Rejected' and TargetObjectId = :pt.id]);
             
            if(procins == null || procins.size() == 0)
                procins = new List<ProcessInstance>([select Id from ProcessInstance where Status = 'Approved' and TargetObjectId = :pt.id]);
             
            system.debug('procins:: '+procins);    
            List<ProcessInstanceWorkitem>  workitem = new List<ProcessInstanceWorkitem>([select Id from ProcessInstanceWorkitem where ProcessInstanceId = :procins[0].id]);
            
            if ((workitem != null) && (workitem.size() > 0)) {
                if (ApproveRejectComments == null || ApproveRejectComments == '') {
                    pwr.SetComments('Rejected');
                } else {
                    pwr.SetComments(ApproveRejectComments);
                }    
                pwr.setWorkItemId(workitem[0].id);
                pwr.setAction('Reject');
            }
            Approval.ProcessResult pr = Approval.process(pwr); 
            System.assert(pr.isSuccess(), 'Reject Result Status:'+pr.isSuccess());
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, 'Your TimeSheet has been Rejected! '));   


If need further information, please let me know.

Thanks,
Manu
Hi Experts,

My Scenario:
1. User with system administrator profile should see an option to 'Reject' the time sheet that is already in "approved" status.
2. When the system administrator rejects the timesheet, it should be changed to 'new' status and the consultant should be able to edit the hours and resubmit it.

See below image:

Final Approval Completed

Thanks,
Manu
 
Hi Experts,

In our SFDC Application we use Weekly TimeCards and Weekly ExpenseCards for our consultants.

Requirement: If user submit Weekly TimeCard (or) Weekly ExpenseCard Attached document mandatory.
If user not select attachment, it through validation error message.

Please find below images for Weekly TimeCard, Weekly ExpenseCard and Submit Button (i.e. this button shows both timecard and expensecard before submit).

Weekly TimeCard:

Weekly TimeCard

Weekly ExpenseCard:

Weekly ExpenseCard

Submit Button:

Submit Button
 
Object and Fields:

Object and Fields

Thanks,
Manu
Hi Experts,
 
We are using "Project" and "Charge Code" Custom objects.
We create projects and for each project 10 charge codes common.
Our end user after creation of project, he manually adds 10 charge codes to project.

Scenario: After creation of project automatically those ten charge code records added to project record.

Please find below is Project record with charge code records.

Project Record
 
Thanks,
Manu
Hi Experts,

below is my trigger, i need test class for my trigger.


trigger CreateChargeCodeAutomatically on MPM4_BASE__Milestone1_Project__c (after insert) {
    
    Set<Id> projectidWherechageCodeExist= new Set<Id>();
    Set<Id> prjIdSet= new Set<Id>();
    for(MPM4_BASE__Milestone1_Project__c prj :trigger.new){
       prjIdSet.add(prj.Id);
    }

    List<Charge_Code__c> chargeCodeList=[SELECT Id,Project__r.Id FROM Charge_Code__c WHERE ID IN :prjIdSet];
    if(chargeCodeList.size() > 0){
       for(Charge_Code__c chr :chargeCodeList){
         projectidWherechageCodeExist.add(chr.Project__c);
       }
    }

    prjIdSet.removeAll(projectidWherechageCodeExist);
    
    List<Charge_Code__c> listToCreate=new List<Charge_Code__c>();
    
    for(MPM4_BASE__Milestone1_Project__c prj :[SELECT Id FROM MPM4_BASE__Milestone1_Project__c WHERE ID IN : prjIdSet]){
       
       for(Project_Charge_Code__c chrge : [SELECT Id,Name FROM Project_Charge_Code__c ]){
            
            Charge_Code__c chrgg=new Charge_Code__c();
            chrgg.Charge_Code__c = chrge.Id;
            chrgg.Project__c = prj.Id;
            listToCreate.add(chrgg);
                   
       }
    }
    
    try{
        insert listToCreate;
    }
    catch(DmlException de){
       System.debug('@@@@SFDC::'+de);
    }

}


Thanks,
Manu
Hi Experts,
 
In our salesforce application, we are using below objects.

Objects and Fields

Below are case records.

Case Records

Perfect – If project having single case record, Total_Recurred_Hours__c showing correct value like 110 (i.e. 40+20+50).
Wrong – If project having two or more than two records, Total_Recurred_Hours__c showing wrong value like 160 (i.e. previous case record 110 value + 20 + 30). But it should be showing 20+30= 50 for second case record.

Below are my case record images

Case Record_1 for Rest Projet:

Case Record_1

Case Record_2 for Rest Projet:

Case Record_2

Anyone sort out my issue, Thanks in advance.
 
Thanks,
Manu
Hi Experts,
 
Below are our objects and relation between them.

Objects and Relations

Trigger Requirement:
When a “partner group member” is inserted or deleted, the following logic needs to occur in the trigger.
   1. Query for related Partner Group Requirements related to the Partner Group, associated to the added/removed Partner Group Member.
   2. If there are Partner Group Requirements,
         - If a partner group member was deleted, then existing "Request" associated to "Partner Group Requirement" should be delete (i.e. Request record delete).
         - If there are no Partner Group Requirements, then do nothing.
Hi Experts,

below is my Apex Class, i need test class for my below class.
I tried see my test class, but it showing 0% Code coverage


public class SendPartnerGroupRequirementsExt {
    public String RequirementID{get;set;}
    public SendPartnerGroupRequirementsExt(ApexPages.StandardController controller) {

    }    
    public PageReference SendRequest(){
        RequirementID=ApexPages.currentPage().getParameters().get('id');
        list<Partner_Group_Requirement__c> PartgroupRequrement=[select id,Name,Partner_Group__c,Request_Type__c,Document_Type__c,Due_Date__c from Partner_Group_Requirement__c where id=:RequirementID];
        list<Request__c> ReqList=new list<Request__c>();
       for(Partner_Group_Requirement__c PGR : PartgroupRequrement){
            Request__c Req=new Request__c();
            //Req.Partner_Group__c=PGR.Partner_Group__c;
            Req.Request_Type__c=PGR.Request_Type__c;
            Req.Container_Template__c=PGR.Document_Type__c;
            Req.Due_Date__c =PGR.Due_Date__c;
            ReqList.add(Req);
            
        }
        
        if(ReqList.size()>0){
          system.debug('&&&&&sample&&&&&'+ReqList);
           insert ReqList;
           for(Request__c Req : ReqList){
               Recipient__c Recp=new Recipient__c();
               //Recp.Partner_Group__c=Req.Partner_Group__c;
               Recp.Request__c=Req.id;
               insert Recp;
               system.debug('******sampletest******'+Recp);
           } 
        }
        PageReference orderPage = new PageReference('/'+RequirementID);
        orderPage.setRedirect(true);
        return orderPage;
    }
 
}




I used below page & Class
VF Page:  SendPartnerGroupRequirements
Apex Class:  SendPartnerGroupRequirementsExt

I tried below code, it showing 0% Code Coverage. Please anyone help me for creating Test Class.


@isTest
Private class SendPartnerGroupRequirementsExtTest
{

static testMethod void SendRequest() {
Partner_Group_Requirement__c TempObj1 = new Partner_Group_Requirement__c();
TempObj1.name = 'Test record';
TempObj1.Request_Type__c = 'Form';
TempObj1.Requirement__c = 'Approved';
TempObj1.Document_Type__c = 'California Transparency of Supply Chain Act';
TempObj1.Partner_Group__c = 'testsample1';
insert TempObj1;

PageReference pageRef = Page.SendPartnerGroupRequirements;
Test.setCurrentPage(pageRef);
ApexPages.Standardcontroller sc = new ApexPages.Standardcontroller(TempObj1);
ApexPages.currentPage().getParameters().put('Id',TempObj1.id);
SendPartnerGroupRequirementsExt ec = new SendPartnerGroupRequirementsExt(sc);

}

}
Hi Experts,

below is my Apex Class, i need test class for my below class.


public class SendPartnerGroupRequirementsExt {
    public String RequirementID{get;set;}
    public SendPartnerGroupRequirementsExt(ApexPages.StandardController controller) {

    }    
    public PageReference SendRequest(){
        RequirementID=ApexPages.currentPage().getParameters().get('id');
        list<Partner_Group_Requirement__c> PartgroupRequrement=[select id,Name,Partner_Group__c,Request_Type__c,Document_Type__c,Due_Date__c from Partner_Group_Requirement__c where id=:RequirementID];
        list<Request__c> ReqList=new list<Request__c>();
       for(Partner_Group_Requirement__c PGR : PartgroupRequrement){
            Request__c Req=new Request__c();
            //Req.Partner_Group__c=PGR.Partner_Group__c;
            Req.Request_Type__c=PGR.Request_Type__c;
            Req.Container_Template__c=PGR.Document_Type__c;
            Req.Due_Date__c =PGR.Due_Date__c;
            ReqList.add(Req);
            
        }
        
        if(ReqList.size()>0){
          system.debug('&&&&&sample&&&&&'+ReqList);
           insert ReqList;
           for(Request__c Req : ReqList){
               Recipient__c Recp=new Recipient__c();
               //Recp.Partner_Group__c=Req.Partner_Group__c;
               Recp.Request__c=Req.id;
               insert Recp;
               system.debug('******sampletest******'+Recp);
           } 
        }
        PageReference orderPage = new PageReference('/'+RequirementID);
        orderPage.setRedirect(true);
        return orderPage;
    }
 
}



Thanks,
Manu
Hi Experts,

below is my Apex Class, i need test class for my below class.


public class SendPartnerGroupRequirementsExt {
    public String RequirementID{get;set;}
    public SendPartnerGroupRequirementsExt(ApexPages.StandardController controller) {

    }    
    public PageReference SendRequest(){
        RequirementID=ApexPages.currentPage().getParameters().get('id');
        list<Partner_Group_Requirement__c> PartgroupRequrement=[select id,Name,Partner_Group__c,Request_Type__c,Document_Type__c,Due_Date__c from Partner_Group_Requirement__c where id=:RequirementID];
        list<Request__c> ReqList=new list<Request__c>();
       for(Partner_Group_Requirement__c PGR : PartgroupRequrement){
            Request__c Req=new Request__c();
            //Req.Partner_Group__c=PGR.Partner_Group__c;
            Req.Request_Type__c=PGR.Request_Type__c;
            Req.Container_Template__c=PGR.Document_Type__c;
            Req.Due_Date__c =PGR.Due_Date__c;
            ReqList.add(Req);
            
        }
        
        if(ReqList.size()>0){
          system.debug('&&&&&sample&&&&&'+ReqList);
           insert ReqList;
           for(Request__c Req : ReqList){
               Recipient__c Recp=new Recipient__c();
               //Recp.Partner_Group__c=Req.Partner_Group__c;
               Recp.Request__c=Req.id;
               insert Recp;
               system.debug('******sampletest******'+Recp);
           } 
        }
        PageReference orderPage = new PageReference('/'+RequirementID);
        orderPage.setRedirect(true);
        return orderPage;
    }
 
}


Thanks in advance.

Thanks,
Manu
If user clicks on custom button VF page will create object2 and object3 records using apex class.

Object1 Fields:
X1, x2, x3, and x4

Object2 Fields:
X1, x2, and x3

Object3 fields:
X2, x3 and x4

Thanks in advance.

Thanks,
Manu
Hi Experts,

I have total 3 quaries...

On Delete:
1. Query for related Recipient__c records.  If count > 0, return error (sobject.addError())
  "Please Cancel Request, or Remove Recipients before deleting"
2. Query for related Workflow_Instance__c records where Request_Status__c != 'Cancelled'.  If count > 0, return error:
  "Please Cancel Request before deleting"
On Update:
3. Query for related Workflow_Instance__c records where Request_Status__c != 'Cancelled',  If count > 0, return error:
  "You cannot edit a submitted Request"

Please modify below code.....

Trigger PreventDeletion1 on Request__c (before delete, before update)
{

 if( Trigger.isDelete ) {

   for (Request__c Pa : Trigger.Old)
   {

        list<Recipient__c> ChList1 = [select id, Request__c from Recipient__c where Request__c =: pa.id];
   
        if(ChList1.size() > 0){
            pa.adderror('Please Cancel Request, or Remove Recipients before deleting');
        }
        

        list<Workflow_Instance__c> ChList2 = [select id, Request__c from Workflow_Instance__c where Request_Status__c != 'Cancelled'];  
        
        if(ChList2.size() > 0)
        {
            pa.adderror('Please Cancel Request before deleting');
        }
   }
   
   
   elseif ( Trigger.isUpdate )       

   for (Request__c Pa : Trigger.Old)
   {

        list<Workflow_Instance__c> ChList3 = [select id, Request__c from Workflow_Instance__c where Request_Status__c != 'Cancelled'];  
        
        if(ChList3.size() > 0)
        {
            pa.adderror('You cannot edit a submitted Request');
        }       

   }
       
  }
}


Thanks,
Manu
 
Hi Experts,
 
I've one trigger to work for Before actions for Delete & Update.
 
Below is my requirement.
 
Object: Request__c
Before Trigger.....
 
On Delete:
1. Query for related Recipient__c records.  If count > 0, return error (sobject.addError())
  "Please Cancel Request, or Remove Recipients before deleting"
2. Query for related Workflow_Instance__c records where Request_Status__c != 'Cancelled'.  If count > 0, return error:
  "Please Cancel Request before deleting"
 
On Update
3. Query for related Workflow_Instance__c records where Request_Status__c != 'Cancelled',  If count > 0, return error:
  "You cannot edit a submitted Request"
 
I written two triggers for delete action (i.e. for first two points) both triggers working fine. Now combine these two triggers as one trigger and add one more action for update (i.e. 3rd query)
 
Trigger1:
 
Trigger PreventDeletion on Request__c (before delete) {
   for (Request__c Pa : Trigger.Old){
        list<Recipient__c> ChList = [select id, Request__c from Recipient__c where Request__c =: pa.id];  //list to hold child matches the parent
        if(ChList.size() > 0){
            pa.adderror('Please Cancel Request, or Remove Recipients before deleting');
        }
   }
}
 
 
 
Trigger2:
 
Trigger PreventDel on Request__c (before delete) {
   for(Request__c Pa : Trigger.Old){
        list<Workflow_Instance__c> ChList = [select id, Request__c from Workflow_Instance__c where Request_Status__c != 'Cancelled'];  //list to hold child matches the parent
        if(ChList.size() > 0){
            pa.adderror('Please Cancel Request before deleting');
        }
   }
}
 
Help will be appreciated. Thanks in advance.

Thanks,
Manu
 
Hi Experts,

I have custom Object Saving__c.
This object contains custom fields Status__c and Final_Amt__c.
Scenario:
We need to calculate All “Final_Amt__c” field values based on Status__c value “In-Progress” and display that value in custom field.
Note: All fields are in one custom object.

Please find below Image.

User-added image

Help will be appreciated, thanks in advance.

Thanks,
Manu
Hi Experts,

I need in below image yellow color line meaning.

User-added image
Hi Experts,

I need a help to understand WSDL, Webservice, and Batch Apex with Webservice. Please anyone help me.

Thanks,
Manu