• Akash jena 3
  • NEWBIE
  • 20 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 13
    Replies
i have 3 fields 
field 1- mr
field 2- bean
in the field 3 i have to show 'mr bean '
basically i have to show the 2 fields value in the 3rd field
I have created a package , when I am trying to install the package I am getting this error

Missing Organization Feature: ContactsToMultipleAccounts
i have written this test class but I am getting error like this
@istest
public class SplitTriggerTest {
    @testsetup
    Public static void split(){
        Account acc = new Account();
        acc.Name = 'Test Account1';
           insert acc;
        
        Equipment__c eqp = new Equipment__c();
        eqp.Name = 'E1';
        eqp.Category__c = 'B';
        insert eqp;
        
        Opportunity__c opp = new Opportunity__c();
        opp.Opportunity_Name__c = 'Test A';
        opp.Stage__c = 'Prospect';
        opp.CommercialFrom__c = 'Rent Alpha Private Limited';
        opp.Account__c = acc.id;
        insert opp;
        
        Opportunity_Product__c op = new Opportunity_Product__c();
        op.Equipment__c = eqp.id; 
        op.Opportunity__c = opp.id;
        op.Tenure_in_months__c = 1234;
        insert op;
        
        Split__c sp = new Split__c();
        sp.Amount__c = 1234;
        sp.Reason_for_Loss__c = 'Competition';
        sp.Competitor__c = 'Hewlett Packard';
        sp.Offer_Equipment__c = op.id;
        insert sp;       
    }
    @isTest
    Private static void splitamount(){
        Split__c spl = [Select id, Name from Split__c Limit 1];
        apexpages.StandardController sc = new apexpages.StandardController(sp);
        SplitTrigger c = new SplitTrigger(sc);
        
    }

}
User-added image
public class CapsaveFacilityLetterEXT {
    
    public static Opportunity__c currentRecord {get;set;}
    public static Id opportunityId {get;set;}
    
    public CapsaveFacilityLetterEXT(ApexPages.StandardController controller) {
        opportunityId = ApexPages.CurrentPage().getparameters().get('Id');
        currentRecord = (Opportunity__c)controller.getRecord();
        
    }

    @AuraEnabled
    public static List<OpportunityProductWrapper> getOpportunityProducts(){
        OpportunityProductWrapper category;
        List<OpportunityProductWrapper.EquipmentType> equipmentTypes;

        List<Opportunity_Product__c> opptyProducts = [SELECT Id, Equipment__r.Name, Equipment__r.Category__c, Tenure_in_months__c, Rental_Sheet__c FROM Opportunity_Product__c WHERE Opportunity__c =: opportunityId Order By Equipment__r.Category__c];
        List<OpportunityProductWrapper> categories = new List<OpportunityProductWrapper>();

        String categoryName = '';
        for(Integer i = 0; i < opptyProducts.size(); i++){
            if(categoryName != opptyProducts[i].Equipment__r.Category__c){
                if(categoryName != ''){
                    category.EquipmentType = equipmentTypes;
                    categories.add(category);
                }
                categoryName = opptyProducts[i].Equipment__r.Category__c;
                category = new OpportunityProductWrapper();
                category.Name = categoryName;
                equipmentTypes = new List<OpportunityProductWrapper.EquipmentType>();
            }
            OpportunityProductWrapper.EquipmentType equipmentType = new OpportunityProductWrapper.EquipmentType();
            equipmentType.Name = opptyProducts[i].Equipment__r.Name;
            equipmentType.Tenor = String.valueOf(opptyProducts[i].Tenure_in_months__c);

            List<OpportunityProductWrapper.PTPP> ptpps = new List<OpportunityProductWrapper.PTPP>();
            if(String.isNotBlank(opptyProducts[i].Rental_Sheet__c))
            for(String str : opptyProducts[i].Rental_Sheet__c.split(';')){
                OpportunityProductWrapper.PTPP ptpp = new OpportunityProductWrapper.PTPP();
                ptpp.Range = str.split(':')[0];
                ptpp.Rental = str.split(':')[1];
                ptpps.add(ptpp);
            }
            equipmentType.PTPP = ptpps;
            equipmentTypes.add(equipmentType);
            if(i == opptyProducts.size()-1){
                category.EquipmentType = equipmentTypes;
                categories.add(category);
            }
        }

        return categories;
    }

    Public static String getVendorNames(){
        String ven = '';
        for(Opportunity_Product__c prod : [SELECT Id,Vendor_Name__c FROM Opportunity_Product__c WHERE Opportunity__c =: opportunityId]){
            if(String.isNotBlank(ven)){
                ven = ven +',' +prod.Vendor_Name__c ;
            }else{
                ven = prod.Vendor_Name__c;
            } 
        }
        return ven;
    }

    Public static String getEquipements(){
        String eType = '';
        for(AggregateResult ar : [SELECT Equipment__r.Name eqName, Equipment__r.Category__c eqCat FROM Opportunity_Product__c WHERE Opportunity__c =: opportunityId GROUP BY Equipment__r.Name, Equipment__r.Category__c ]){
            if(eType == '') eType = (String) ar.get('eqCat');
            else eType = eType + ',' + ar.get('eqCat');
        }
        return eType;
    }

    Public static list<Opportunity_Product__c> getOpportunityLineItems(){
        return [SELECT Equipment__r.Category__c ,Equipment__r.Name, Facility_Amount__c,Deposit_Type__c,
        Facility_Type__c, Facility_Amount_Million__c, Rental_Type__c, Rental_Frequency__c, Other__c, 
        Tenure_No_of_Payments__c, Tenure_Years__c, Vendor_Name__c, Tenure_in_months__c, Processing_Fee__c, 
        Rental_Sheet__c, Security_Deposit__c,Standard_Asset__c,Useful_Life_Obtained_From__c,Decommissioning_Efforts__c,
        Nature_of_Usage_of_the_Equipment__c,Equipment_Embedded_to_the_Ground__c,Responsible_for_Maintenance__c,
        Equipment_Adequately_Insured__c,Responsible_for_the_Insurance__c,Customers_Building_Leases_Term__c,
        Warranty_Maintenance__c,Asset_Maintenance_Services__c ,PNI__c,GRV__c,XIRR__c,Recovery_Statergy__c
        FROM Opportunity_Product__c WHERE Opportunity__c =: opportunityId ];
    }

    Public static List<Contact> getContacts(){
        return [SELECT Name, Designation__c, Phone, Email FROM Contact WHERE AccountId =:  currentRecord.Account__c  ];
    }


}




& this test class I have written ,
@istest
public class CapsaveFacilityLetterEXTTest {
    @testsetup
    Public static void Caps(){
        Account acc = new Account();
        acc.Name = 'Test Account1';
           insert acc;
        
        Contact con = new Contact();
        con.Lastname = 'TestD';
        con.Designation__c = 'xyz';
        con.Phone = '12345';
        con.Email = 'abc@ghghd.com';
        con.AccountId = acc.id;
        insert con;
        
        Equipment__c eqp = new Equipment__c();
        eqp.Name = 'E1';
        eqp.Category__c = 'B';
        insert eqp;
        
        Opportunity__c opp = new Opportunity__c();
        opp.Opportunity_Name__c = 'Test A';
        opp.Stage__c = 'Prospect';
        opp.CommercialFrom__c = 'Rent Alpha Private Limited';
        opp.Account__c = acc.id;
        insert opp;
        
        Opportunity_Product__c Op = new Opportunity_Product__c();
        Op.Equipment__c = eqp.id; 
        Op.Opportunity__c = opp.id;
        Op.Tenure_in_months__c = 1234;
        insert Op;
                  
    }
    @isTest
    Private static void CapSave(){
        Test.startTest();
        List<Contact> con = [SELECT  id,Name, Designation__c, Phone, Email,AccountId FROM Contact LIMIT 1];
        //system.debug('con---->'+con);
        List<Opportunity_Product__c> Op = [SELECT id,Equipment__c,Tenure_in_months__c,Opportunity__c  from Opportunity_Product__c LIMIT 1];
        Op[0].Vendor_Name__c = 'TestC';
        update Op;
        //system.debug('Op---->'+Op);
        CapsaveFacilityLetterEXT.getOpportunityProducts();
        CapsaveFacilityLetterEXT.getVendorNames();
        CapsaveFacilityLetterEXT.getOpportunityLineItems();
        CapsaveFacilityLetterEXT.getOpportunityLineItems();
        CapsaveFacilityLetterEXT.getEquipements();
        //CapsaveFacilityLetterEXT.getContacts();  
        Test.stopTest();
    }
    @isTest
    Private static void opportunity(){
        Opportunity__c op = [Select id, Name from Opportunity__c Limit 1];
        //Opportunity__c o1 = new Opportunity__c(Name='Test 2');
        apexpages.StandardController sc = new apexpages.StandardController(op);
        CapsaveFacilityLetterEXT c = new CapsaveFacilityLetterEXT(sc);
        
    }    

}
public class CapsaveFacilityLetterEXT {
    
    public static Opportunity__c currentRecord {get;set;}
    public static Id opportunityId {get;set;}
    
    public CapsaveFacilityLetterEXT(ApexPages.StandardController controller) {
        opportunityId = ApexPages.CurrentPage().getparameters().get('Id');
        currentRecord = (Opportunity__c)controller.getRecord();
        
    }

    @AuraEnabled
    public static List<OpportunityProductWrapper> getOpportunityProducts(){
        OpportunityProductWrapper category;
        List<OpportunityProductWrapper.EquipmentType> equipmentTypes;

        List<Opportunity_Product__c> opptyProducts = [SELECT Id, Equipment__r.Name, Equipment__r.Category__c, Tenure_in_months__c, Rental_Sheet__c FROM Opportunity_Product__c WHERE Opportunity__c =: opportunityId Order By Equipment__r.Category__c];
        List<OpportunityProductWrapper> categories = new List<OpportunityProductWrapper>();

        String categoryName = '';
        for(Integer i = 0; i < opptyProducts.size(); i++){
            if(categoryName != opptyProducts[i].Equipment__r.Category__c){
                if(categoryName != ''){
                    category.EquipmentType = equipmentTypes;
                    categories.add(category);
                }
                categoryName = opptyProducts[i].Equipment__r.Category__c;
                category = new OpportunityProductWrapper();
                category.Name = categoryName;
                equipmentTypes = new List<OpportunityProductWrapper.EquipmentType>();
            }
            OpportunityProductWrapper.EquipmentType equipmentType = new OpportunityProductWrapper.EquipmentType();
            equipmentType.Name = opptyProducts[i].Equipment__r.Name;
            equipmentType.Tenor = String.valueOf(opptyProducts[i].Tenure_in_months__c);

            List<OpportunityProductWrapper.PTPP> ptpps = new List<OpportunityProductWrapper.PTPP>();
            if(String.isNotBlank(opptyProducts[i].Rental_Sheet__c))
            for(String str : opptyProducts[i].Rental_Sheet__c.split(';')){
                OpportunityProductWrapper.PTPP ptpp = new OpportunityProductWrapper.PTPP();
                ptpp.Range = str.split(':')[0];
                ptpp.Rental = str.split(':')[1];
                ptpps.add(ptpp);
            }
            equipmentType.PTPP = ptpps;
            equipmentTypes.add(equipmentType);
            if(i == opptyProducts.size()-1){
                category.EquipmentType = equipmentTypes;
                categories.add(category);
            }
        }
        return categories;
    }

    Public static String getVendorNames(){
        String ven = '';
        for(Opportunity_Product__c prod : [SELECT Id,Vendor_Name__c FROM Opportunity_Product__c WHERE Opportunity__c =: opportunityId]){
            if(String.isNotBlank(ven)){
                ven = ven +',' +prod.Vendor_Name__c ;
            }else{
                ven = prod.Vendor_Name__c;
            } 
        }
        return ven;
    }

    Public static String getEquipements(){
        String eType = '';
        for(AggregateResult ar : [SELECT Equipment__r.Name eqName, Equipment__r.Category__c eqCat FROM Opportunity_Product__c WHERE Opportunity__c =: opportunityId GROUP BY Equipment__r.Name, Equipment__r.Category__c ]){
            if(eType == '') eType = (String) ar.get('eqCat');
            else eType = eType + ',' + ar.get('eqCat');
        }
        return eType;
    }

    Public static list<Opportunity_Product__c> getOpportunityLineItems(){
        return [SELECT Equipment__r.Category__c ,Equipment__r.Name, Facility_Amount__c,Deposit_Type__c,
        Facility_Type__c, Facility_Amount_Million__c, Rental_Type__c, Rental_Frequency__c, Other__c, 
        Tenure_No_of_Payments__c, Tenure_Years__c, Vendor_Name__c, Tenure_in_months__c, Processing_Fee__c, 
        Rental_Sheet__c, Security_Deposit__c,Standard_Asset__c,Useful_Life_Obtained_From__c,Decommissioning_Efforts__c,
        Nature_of_Usage_of_the_Equipment__c,Equipment_Embedded_to_the_Ground__c,Responsible_for_Maintenance__c,
        Equipment_Adequately_Insured__c,Responsible_for_the_Insurance__c,Customers_Building_Leases_Term__c,
        Warranty_Maintenance__c,Asset_Maintenance_Services__c ,PNI__c,GRV__c,XIRR__c,Recovery_Statergy__c
        FROM Opportunity_Product__c WHERE Opportunity__c =: opportunityId ];
    }

    Public static List<Contact> getContacts(){
        return [SELECT Name, Designation__c, Phone, Email FROM Contact WHERE AccountId =:  currentRecord.Account__c  ];
    }


}
public with sharing class LeadConvertService {
    Private Final List<Lead__c> LEADS;
    
    LeadConvertService(List<Lead__c> leads){
        this.LEADS = leads;
    }
}
my requirement is to send email if no task is created in that particular lead for 2 hour 
trigger TaskCount on Task (after delete, after insert, after undelete, after update) {

Set<ID> Lead__cIds = new Set<ID>();

//We only care about tasks linked to Leads.

String leadPrefix = Lead__c.SObjectType.getDescribe().getKeyPrefix();

//Add any Lead ids coming from the new data

if(trigger.new!=null){
    for (Task t : Trigger.new) {
     if (t.WhoId!= null && string.valueof(t.WhoId).startsWith(leadPrefix) ) {

if(!Lead__cIds.contains(t.WhoId)){
//adding unique lead ids since there can be many tasks with single lead
Lead__cIds.add(t.WhoId);
}
}
      }
}
 
//Also add any Lead ids coming from the old data (deletes, moving an activity from one Lead to another)

if(trigger.old!=null){
    for (Task t2 : Trigger.old) {
     if (t2.WhoId!= null && string.valueof(t2.WhoId).startsWith(leadPrefix) )
         {
if(!Lead__cIds.contains(t2.WhoId)){
//adding unique lead ids since there can be many tasks with single lead
Lead__cIds.add(t2.WhoId);
}
}
      }
}

     if (Lead__cIds.size() > 0){



List<Lead__c> leadsWithTasks = [select id,Task_Count__c,(select id from Tasks) from Lead__c where Id IN : Lead__cids];

List<Lead__c> leadsUpdatable = new List<Lead__c>();

for(Lead__c L : leadsWithTasks){

L.Task_Count__c = Lead__cids.size();
leadsUpdatable.add(L);

}

if(leadsUpdatable.size()>0){

update leadsUpdatable;
//update all the leads with activity count

}

    }
}
trigger TaskCount on Task (after delete, after insert, after undelete, after update) {

Set<ID> Lead__c_Ids = new Set<ID>();

//We only care about tasks linked to Leads.

String leadPrefix = Lead__c.SObjectType.getDescribe().getKeyPrefix();

//Add any Lead ids coming from the new data

if(trigger.new!=null){
    for (Task t : Trigger.new) {
     if (t.WhoId!= null && string.valueof(t.WhoId).startsWith(leadPrefix) ) {

if(!Lead__c_Ids.contains(t.WhoId)){
//adding unique lead ids since there can be many tasks with single lead
Lead__c_Ids.add(t.WhoId);
}
}
      }
}
 
//Also add any Lead ids coming from the old data (deletes, moving an activity from one Lead to another)

if(trigger.old!=null){
    for (Task t2 : Trigger.old) {
     if (t2.WhoId!= null && string.valueof(t2.WhoId).startsWith(leadPrefix) )
         {
if(!Lead__c_Ids.contains(t2.WhoId)){
//adding unique lead ids since there can be many tasks with single lead
Lead__c_Ids.add(t2.WhoId);
}
}
      }
}

     if (Lead__c_Ids.size() > 0){



List<Lead__c> leadsWithTasks = [select id,Task_count__c,(select id from Tasks) from Lead__c where Id IN : Lead__c_Ids];

List<Lead__c> leadsUpdatable = new List<Lead__c>();

for(Lead__c L : leadsWithTasks){

L.Task_count__c = L.Tasks.size();
leadsUpdatable.add(L);

}

if(leadsUpdatable.size()>0){

update leadsUpdatable;
//update all the leads with activity count

}

    }
}
trigger TaskCount on Task (after delete, after insert, after undelete, after update) {

Set<ID> Lead__c_Ids = new Set<ID>();

//We only care about tasks linked to Leads.

String leadPrefix = Lead__c.SObjectType.getDescribe().getKeyPrefix();

//Add any Lead ids coming from the new data

if(trigger.new!=null){
    for (Task t : Trigger.new) {
     if (t.WhoId!= null && string.valueof(t.WhoId).startsWith(leadPrefix) ) {

if(!Lead__c_Ids.contains(t.WhoId)){
//adding unique lead ids since there can be many tasks with single lead
Lead__c_Ids.add(t.WhoId);
}
}
      }
}
 
//Also add any Lead ids coming from the old data (deletes, moving an activity from one Lead to another)

if(trigger.old!=null){
    for (Task t2 : Trigger.old) {
     if (t2.WhoId!= null && string.valueof(t2.WhoId).startsWith(leadPrefix) )
         {
if(!Lead__c_Ids.contains(t2.WhoId)){
//adding unique lead ids since there can be many tasks with single lead
Lead__c_Ids.add(t2.WhoId);
}
}
      }
}

     if (Lead__c_Ids.size() > 0){



List<Lead_c> leadsWithTasks = [select id,Task_countc,(select id from Tasks) from Leadc where Id IN : Lead_c_Ids];

List<Lead_c> leadsUpdatable = new List<Lead_c>();

for(Lead__c L : leadsWithTasks){

L.Task_count__c = L.Tasks.size();
leadsUpdatable.add(L);

}

if(leadsUpdatable.size()>0){

update leadsUpdatable;
//update all the leads with activity count

}

    }
}User-added image
i have 3 fields 
field 1- mr
field 2- bean
in the field 3 i have to show 'mr bean '
basically i have to show the 2 fields value in the 3rd field
i have 3 fields 
field 1- mr
field 2- bean
in the field 3 i have to show 'mr bean '
basically i have to show the 2 fields value in the 3rd field
i have written this test class but I am getting error like this
@istest
public class SplitTriggerTest {
    @testsetup
    Public static void split(){
        Account acc = new Account();
        acc.Name = 'Test Account1';
           insert acc;
        
        Equipment__c eqp = new Equipment__c();
        eqp.Name = 'E1';
        eqp.Category__c = 'B';
        insert eqp;
        
        Opportunity__c opp = new Opportunity__c();
        opp.Opportunity_Name__c = 'Test A';
        opp.Stage__c = 'Prospect';
        opp.CommercialFrom__c = 'Rent Alpha Private Limited';
        opp.Account__c = acc.id;
        insert opp;
        
        Opportunity_Product__c op = new Opportunity_Product__c();
        op.Equipment__c = eqp.id; 
        op.Opportunity__c = opp.id;
        op.Tenure_in_months__c = 1234;
        insert op;
        
        Split__c sp = new Split__c();
        sp.Amount__c = 1234;
        sp.Reason_for_Loss__c = 'Competition';
        sp.Competitor__c = 'Hewlett Packard';
        sp.Offer_Equipment__c = op.id;
        insert sp;       
    }
    @isTest
    Private static void splitamount(){
        Split__c spl = [Select id, Name from Split__c Limit 1];
        apexpages.StandardController sc = new apexpages.StandardController(sp);
        SplitTrigger c = new SplitTrigger(sc);
        
    }

}
User-added image
public with sharing class LeadConvertService {
    Private Final List<Lead__c> LEADS;
    
    LeadConvertService(List<Lead__c> leads){
        this.LEADS = leads;
    }
}
my requirement is to send email if no task is created in that particular lead for 2 hour 
trigger TaskCount on Task (after delete, after insert, after undelete, after update) {

Set<ID> Lead__cIds = new Set<ID>();

//We only care about tasks linked to Leads.

String leadPrefix = Lead__c.SObjectType.getDescribe().getKeyPrefix();

//Add any Lead ids coming from the new data

if(trigger.new!=null){
    for (Task t : Trigger.new) {
     if (t.WhoId!= null && string.valueof(t.WhoId).startsWith(leadPrefix) ) {

if(!Lead__cIds.contains(t.WhoId)){
//adding unique lead ids since there can be many tasks with single lead
Lead__cIds.add(t.WhoId);
}
}
      }
}
 
//Also add any Lead ids coming from the old data (deletes, moving an activity from one Lead to another)

if(trigger.old!=null){
    for (Task t2 : Trigger.old) {
     if (t2.WhoId!= null && string.valueof(t2.WhoId).startsWith(leadPrefix) )
         {
if(!Lead__cIds.contains(t2.WhoId)){
//adding unique lead ids since there can be many tasks with single lead
Lead__cIds.add(t2.WhoId);
}
}
      }
}

     if (Lead__cIds.size() > 0){



List<Lead__c> leadsWithTasks = [select id,Task_Count__c,(select id from Tasks) from Lead__c where Id IN : Lead__cids];

List<Lead__c> leadsUpdatable = new List<Lead__c>();

for(Lead__c L : leadsWithTasks){

L.Task_Count__c = Lead__cids.size();
leadsUpdatable.add(L);

}

if(leadsUpdatable.size()>0){

update leadsUpdatable;
//update all the leads with activity count

}

    }
}
Hey there,

I am building a custom 'Customizable Forecast' tab from scratch using Visualforce and a custom controller to add some new features. One of my requirements is to forecast off of the 'forecast heirarchy' defined in the Setup->Build->Customize->Forecasts (Customizable)->Forecasts Hierarchy. Until now, I've used the UserRoleId Field to find direct reports and subordinate roles/users. How can I use SOQL to query the Forecast Heirarchy for Direct Reports and  subordinate users instead? I can not find any info on an object that contains this information.



 
I am trying to create a trigger that will count activities (tasks) on leads.
My code is below....

When saving I am getting the following error....

Error: Compile Error: unexpected token: '}' at line 30 column 1

But if I remove the curly bracket I get a different error

Error: Compile Error: unexpected token: '<EOF>' at line 30 column 0


trigger TaskUpdateLead on Task (after delete, after insert, after undelete, after update)
{
Set<ID> LeadIds = new Set<ID>();

//We only care about tasks linked to Leads.

String leadPrefix = Lead.SObjectType.getDescribe().getKeyPrefix();

//Add any Lead ids coming from the new data

if (Trigger.new != null) {
    for (Task t : Trigger.new) {
     if (t.WhatId != null && string.valueOf(t.whatId).startsWith(leadprefix) )
         {LeadIds.add(t.whatId);
      }
   }
}
//Also add any Lead ids coming from the old data (deletes, moving an activity from one Lead to another)

if (Trigger.old != null) {
    for (Task t : Trigger.old) {
     if (t.WhatId != null && String.valueOf(t.whatId).startsWith(leadprefix) )
         { LeadIds.add(t.whatId);
      }
   }
}
if (LeadIds.size() > 0)

Lead.Activity_Count__c.updateLeadCount<LeadIds>
}


Any guidance is very much appreciated.