• Karthikeyan Rajendran 14
  • NEWBIE
  • 149 Points
  • Member since 2019

  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 34
    Replies
Hallo,

i have 20 records in quotes object(in production).
But i am not getting these 20 records in sandbox.

likewise i could not find records for many objects in sandbox
eventhough  they are present in production.

can some one help me out with this?
thanks in advance!
I'm trying to create a validation rule that makes fields specific required for certain users based on their roles. If a user's role is: Account Manager, Sales Rep, or International Sales, AND they are marking an opportunity stage (picklist) as "Closed - Won" we want to make a few fields required.

The fields we want to be required if the above is true are: 
ARR 
Total Opportunity Value (TCV)
Reason for Win 
Win Notes
Growth
Products Sold

In addition to the above, we also need the minimum characters for "Win Notes" and "Growth" to be 500 characters.

Any help is greatly appreciated.
Hi, 

I am trying to build a map that will contain the Account OwnerId as the key and the sum value of the field Amount grouped by Month and Year as the value and receiving the error:

"Loop variable must be a generic SObject or LIst or a concrete SObject or List of: AggregateResult"

Here is my code, can anyone help me fix what I am doing wrong?


Map<Id,Decimal> invoices = new Map<Id,Decimal>();
for(Invoice__c obj:[Select Account__r.OwnerId, sum(Amount__c) FROM Invoice__c group by Account__r.OwnerId, Calendar_Year(InvoiceDate__c), Calendar_Month(InvoiceDate__c)]){
    invoices.put(obj.Account__r.OwnerId,obj.Amount__c);
}
How do I assign a permission set on  newly created partner user?
 
public class AssignPermissionSet {
    
    public static void assignperm(List<user> userlist){
        Set<ID> usersId = new Set<Id>();
        Set<Id> contactIdsSet = new Set<Id>();
        List<PermissionSetAssignment> permissionSetList = new List<PermissionSetAssignment>();
        
        
        for (User u : [Select Id, Name, ProfileId FROM User Where Id IN : userlist]){ // Add fields as per your requirement...
            if(u.ProfileId == '00e360003429432'){
            PermissionSetAssignment psa = new PermissionSetAssignment (PermissionSetId = '0PS33609skjojsae', AssigneeId = u.Id);
            permissionSetList.add(psa);
                }
        }
        insert permissionSetList;
    }
}

 
Hi

I am getting this issue to many soql, is there something wrong with my code when try to save a record this error appers that too many soql
public class AccountTask {
    
    
    
    public static void accountTaskCopy(List<Account> acclist){
        Id EmailRT = SObjectType.Task.getRecordTypeInfosByDeveloperName().get('Email').getRecordTypeId();
        Id CallRT = SObjectType.Task.getRecordTypeInfosByDeveloperName().get('Call').getRecordTypeId(); 
        
        Set<Id> forWhatID = new Set<Id>();
        Set<Id> accID = new Set<Id>();
        Set<Id> coverageIds = new Set<Id>();
        Map<ID, List<CM__c>> accountIdToListCMOMap = new Map<Id, List<CM__c>>(); 
        Map<ID, List<CM__c>> coverageIdToListCVMMap = new Map<Id, List<CM__c>>();
        Map<ID, List<Task>> accountIdToListTaskCompletedMap = new Map<Id, List<Task>>();
        Map<ID, List<Task>> accountIdToListTaskNotCompletedMap = new Map<Id, List<Task>>();
        Map<Id, Account> accountsToUpdate = new Map<Id, Account>();
       
        for(Account acc: acclist){
            {
            accID.add(acc.ID);
            }
       }

        
        for(Task tsk : [SELECT ID,whatid FROM TASK where WHATID IN : accID]){
            if(tsk.WhatID != Null && tsk.WhatID.getSObjectType() == Account.SobjectType){
                forWhatID.add(tsk.WhatId);
                System.debug('forWhatID' + forWhatID);
            }
        }
         
        List<CM__c> existingCMs = [SELECT Id, Account__c, Account__r.Name, CVR__c, Coverage__r.Good__c,rel__c, status__c, BusinessType__c, Age_Today__c 
                                                            FROM CM__c 
                                                            WHERE (CVR__c != null AND Account__c IN: forWhatID AND Account__c != null) AND status__c ='ACTIVE' AND BusinessType__c = 'Medical'];
        
        for(CM__c cMo : existingCMs){
            if(accountIdToListCMOMap.containsKey(cMo.Account__c)){
                accountIdToListCMOMap.get(cMo.Account__c).add(cMo);
            }
            else{
                accountIdToListCMOMap.put(cMo.Account__c, new List<CM__c>{cMo});
            }
            
            if(coverageIdToListCVMMap.containsKey(cMo.CVR__c)){
                coverageIdToListCVMMap.get(cMo.CVR__c).add(cMo);
            }
            else{
                coverageIdToListCVMMap.put(cMo.CVR__c, new List<CM__c>{cMo});
            }
            
            coverageIds.add(cMo.CVR__c);
        }
        
        List<CM__c> existingCMFromCov = [SELECT Id, Account__c, Account__r.Name, CVR__c, Coverage__r.Good__c,rel__c, status__c, BusinessType__c, Age_Today__c 
                                                                   FROM CM__c 
                                                                   WHERE (CVR__c != null AND CVR__c IN: coverageIds AND Account__c != null) AND status__c ='ACTIVE' AND BusinessType__c = 'Medical'];
        for(CM__c cMo : existingCMFromCov){
            if(coverageIdToListCVMMap.containsKey(cMo.CVR__c)){
                coverageIdToListCVMMap.get(cMo.CVR__c).add(cMo);
            }
            else{
                coverageIdToListCVMMap.put(cMo.CVR__c, new List<CM__c>{cMo});
            }
        }
        System.debug('accountIdToListCMOMap ' + accountIdToListCMOMap);
        System.debug('coverageIdToListCVMMap ' + coverageIdToListCVMMap);
        
        
        List<Task> taskCompletedOrInvalidPhone = [SELECT Id, whatid, CallCustom__c, RecordtypeId 
                                                  FROM Task 
                                                  WHERE Whatid IN :forWhatID 
                                                  AND (CallCustom__c = 'Completed Campaign Requirements' OR CallCustom__c = 'Invalid Phone') AND WhatID != null];
        for(Task tsk : taskCompletedOrInvalidPhone){
            if(accountIdToListTaskCompletedMap.containsKey(tsk.WhatId)){
                accountIdToListTaskCompletedMap.get(tsk.WhatId).add(tsk);
            }
            else{
                accountIdToListTaskCompletedMap.put(tsk.WhatId, new List<Task>{tsk});
            }
        }
        
        List<Task> taskNotCompleteCampaign = [SELECT Id, whatid,CallCustom__c, RecordtypeId  FROM Task WHERE Whatid IN :forWhatID AND RecordTypeID =: CallRT AND (CallCustom__c = 'Left Message' OR  CallCustom__c = 'Unable to Reach') AND WhatID != null ];
        for(Task tsk : taskNotCompleteCampaign){
            if(accountIdToListTaskNotCompletedMap.containsKey(tsk.WhatId)){
                accountIdToListTaskNotCompletedMap.get(tsk.WhatId).add(tsk);
            }
            else{
                accountIdToListTaskNotCompletedMap.put(tsk.WhatId, new List<Task>{tsk});
            }
        }
        
        System.debug('accountIdToListTaskCompletedMap ' + accountIdToListTaskCompletedMap);
        System.debug('accountIdToListTaskNotCompletedMap ' + accountIdToListTaskNotCompletedMap);
        
        for(Id acctId : forWhatID){
            System.debug('acctId ' + acctId);
            if(accountIdToListTaskCompletedMap.containsKey(acctId)){
            system.debug('acctIdlist' + accountIdToListTaskCompletedMap);
                if(accountIdToListCMOMap.containsKey(acctId)){
                    for(CM__c cMo : accountIdToListCMOMap.get(acctId)){
                        System.debug('cMo ' + cMo);
                        if(coverageIdToListCVMMap.containsKey(cMo.CVR__c)){
                            for(CM__c covMem2 : coverageIdToListCVMMap.get(cMo.CVR__c)){
                                System.debug('covMem2 ' + covMem2);
                                accountsToUpdate.put(covMem2.Account__c, new Account(Id=covMem2.Account__c, PDC__c=true));
                            }
                        }
                        
                    } 
                } 
            }
        
        }
        
        System.debug('accountsToUpdate ' + accountsToUpdate);
        update accountsToUpdate.values();
        
    }
}

 
We are trying to bring in Pega to SF, the Pega Community gave us the how to, but now it says on Step 4 to create an APEX Tab, i'm not sure what that is. Any help?

Pega Community
Screen shot of directions
Hi there,

I have Picklist field Membership_Level__c which have some values like Child Free and another picklist field Membership_Type__c which also have some value like GP and Dental.

Add a validation rule not to allow to add Free Child to GP and Dental.
I did this:
IF(AND(ISPICKVAL(Membership_Type__c,'MHC GP'), 
NOT(ISBLANK(Membership_Level__c,'Child Free'))), true, false)

Please assist
LN
I have the task where I need to make all of the data export dynamic and automated I have the automation part all handled the issue Im running into is on the line
<entry key="sfdc.extractionSOQL" value="Select Id, name FROM Account"/>
I need this to cover all of the fields on the object and if a new field was added that day it will need to be added to the query and included..

basically I just need a way to change all my extraction queries to select * from account etc for each object and it will be done and working any ideas? does sfdc support the select * syntax or a variation?
Hi,

As we know, Case and case comments have a parent child relatioshiop.

For one case, there can be multiple entries of case comments ?

Howevr, I want to update Cases field ( Description ) only with the latest case comment that has been created ?

How can I achieve this ?
I'm getting the following error while deploying the case page layout to another org vi Copado.
Deployment Error:

[QuickAction Case.Custom_Email] Send Email is disabled or activities are not allowed. Enable Send Email and allow activities, then try again.[Layout Case-Billing Line Item Adjustment] In field: QuickAction - no QuickAction named Case.Custom_Email found

In target org I did the "No Access" for Deliverability under the Email Administration and tried to deploy the page layout still getting the same error.
Kindly please help me out.
Hi. I want to code for a trigger in Apex but I want the logic to reside in a handler class and have only one statement in the trigger itself which references a static method in the handler class. Basically something like this:

trigger myTrigger on sObject (after update, after insert, after delete, after undelete){
HandlerClass.executeTriggerLogic(args[]);
}

public class HandlerClass{
public static void executeTriggerLogic (args[])
{
//trigger logic
{

//other methods...
}

Is this possible and what would I need to pass from the trigger to the Handler as the args[] to make this work? Any help would be much appreciated. Thanks.
Hallo,

i have 20 records in quotes object(in production).
But i am not getting these 20 records in sandbox.

likewise i could not find records for many objects in sandbox
eventhough  they are present in production.

can some one help me out with this?
thanks in advance!
I have a custom object (titled "Workfront") we are using to track customer onboarding projects. Data from this is being synced over from an outside program and the field we are using to record the name of the trainer ("Implementation Specialist") is coming across as text.

I would like to create a contact lookup field on the object and somehow populate that field with what is in the text field. i.e. if the text field says "John Doe" and we have a contact named "John Doe", I would like to somehow grab the text value, perform a search, and populate the lookup field with a matching contact (if one is found). Any insight on achieving this would be greatly appreciated!
I am trying to create an Apex class that will run every night and update a field on Contact based on specidic criteria.

Basically what I need to happen is for the system to query all assignemnts (pse__assignment__c) in the system with an end date (pse__End_Date__c) greater than TODAY (today__c) 

I then need to add that assignemnt to a custom field I have created on Contact if the assignment passes the criteria. If there are no assignments for the specific contact then I need the assignment field to be NULL. 

There is a lookup relationship between Assignemtn and Contact. In my code I think I am querying the assignments correctly but I am strugling with figuring out how to then associate that specific assignment with the correct contact. I am also struggling with how to make this Class a schedulable class that I am able to schedule to run every night. 

Here is my code so far. 

Any help would be GREATLY APPRECIATED   
 
public class AssignmentToContact implements Database.Batchable<sObject> {
        
   global Database.queryLocator start(Database.BatchableContext ctx )
   {
       
        list<pse__Assignment__c> aid=New list<pse__Assignment__c>(); 
    	list<Contact> updatecontact = new list<Contact>();
       
    	for(pse__Assignment__c ass: Trigger.new){ 
        if(ass.pse__End_Date__c >= today__c && ass.pse__Is_Billable__c = TRUE){
            aid.add(ass.id);
        } 

        list<Contact> contactlist=[SELECT Id,Assignment__c FROM Contact WHERE id = :aid]; 
        for(Contact con: contactlist){ 
            con.Assignment__c=ass.Id; 
            updatecontact.add(con);
        }
    }
    update updatecontact; 
	}
}

//IF THE list is empty then the field on CONTACT should be NULL

 
Hello everyone,

Can anyone help me out in writing a trigger on lead object.

On lead I have following fields
1)LastName
2)FirstName
3)Parent__c (Checkbox)
4)ParentFirstName__c
5)ParentSecondName__c
6)ParentEmail__c

Once lead is created then I want to create one record in contact if Parent__c = 'False'.
If Parent__c is true then I want to create two records in contact where one is for parent and other is for student(standard lead field belongs to student details).
If Parent__c is true then I need to catch the newly created contact Id's then I need to create a record in Relationship__c object where Contact1__c = ParentContactId and Contact__2=StudentContactId

Can anyone helps me out in writing trigge that is bulkified for multiple insertions lead please
Hello everyone,

I wrote a trigger that will create records in multiple objects and then converts it but when I insert multiple records then its showing below error.

"ContactCreationFromLead: execution of BeforeUpdate
caused by: System.ListException: List index out of bounds: 3"

My trigger is below.

 
trigger ContactCreationFromLead on Lead (After insert, before Update) {
    //trigger to create contact, relationship, affiliation records from lead.
    List<Lead> em = new List<Lead>();
    List<Contact> conInsertList = new List<Contact>();
    List<hed__Affiliation__c> affiliation = new List <hed__Affiliation__c>();
    List<hed__Relationship__c> relation = new List<hed__Relationship__c>();
    List<hed__Affiliation__c> affiliationListToBeInserted = new List<hed__Affiliation__c>();
    List<String> listEmail = new List<String>();
    List<String> listname = new List<String>();
    Set<String> otherProgramsValueSet = new Set<String>();
    if(trigger.isInsert || trigger.isUpdate){
    for (Lead em : Trigger.new) {
        if(em.Email != null){
            listEmail.add(em.Email);
        }
        if(em.What_is_your_primary_program_of_interest__c != null ){
            listname.add(em.What_is_your_primary_program_of_interest__c);
        }
        if(em.Other_Programs_of_Interest__c != null){
            otherProgramsValueSet.addAll(em.Other_Programs_of_Interest__c.split(';'));
        }
    }
    }
    //to catch the account Id that matches the lead primary program of interest
    //account name should match with primary program of interest picklist values
    List<Account> account = [SELECT Id,Name,Pardot_Program_Name__c from Account WHERE Pardot_Program_Name__c = :listname];
    string record;
    for(Account acc : account){
        record = acc.Id; 
    }
    List<Contact> cem = [SELECT Id, Email FROM Contact WHERE Email = :listEmail];
    String cemail;
    for(Contact ce : cem){
        cemail = ce.Email;
    }
    Id recordtype1 = [select Id From RecordType WHERE DeveloperName='Lead'].Id;
    Id recordtype2 = [select Id From RecordType WHERE DeveloperName='Parent'].Id;
    //code to create contact for student if form is filled by student
    for(Lead ld : Trigger.new) {
        if (ld.Email != cemail && ld.Parent_or_guardian__c == false) {
            
            Contact cnt = new Contact();           
                cnt.FirstName = ld.FirstName;
                cnt.LastName = ld.LastName;
                cnt.Email = ld.Email;
            conInsertList.add(cnt);
        }
        //code to create contacts for parent and student if form is filled by parent
        else{
            if(ld.Email != cemail && ld.Parent_or_guardian__c == true ){
                Contact cnt1 = new Contact();
                cnt1.RecordTypeId = recordtype2;
                cnt1.FirstName = ld.Parent_First_Name__c;
                cnt1.LastName = ld.Parent_Last_Name__c;
                cnt1.Email = ld.Parent_Email__c;
            conInsertList.add(cnt1);
                Contact cnt2 = new Contact();
                cnt2.RecordTypeId = recordtype1;
                cnt2.FirstName = ld.FirstName;
                cnt2.LastName = ld.LastName;
                cnt2.Email = ld.Email;
            conInsertList.add(cnt2);
            }
        }
    }
    if(conInsertList.size()>0){
        INSERT conInsertList;
        List<Id> conInsert = new List<Id>();
        //catch the inserted contact ids to create relationship record
        if(conInsertList.size()>1){
        for(Integer i = 0, s = conInsertList.size(); i < s; i += 2){
            //creates relation record by catching current student and parent record id's
            hed__Relationship__c hedrel = new hed__Relationship__c();
            hedrel.hed__Contact__c = conInsertList[i + 1].Id;
            hedrel.hed__RelatedContact__c = conInsertList[i].Id;
            hedrel.hed__Type__c = 'Parent';
            relation.add(hedrel);
            //creates affiliation record if filled by parent
            if( listname.isEmpty()==false && record != null){
            hed__Affiliation__c hedaff = new hed__Affiliation__c();
            hedaff.hed__Account__c = record;
            hedaff.hed__Contact__c = conInsertList[i + 1].Id;
            hedaff.hed__Primary__c = true;
            affiliation.add(hedaff);
            }
            //creates affiliation records for other programs multi select picklist field
            if(otherProgramsValueSet != null){
            Map<String,Id> accNamesToIdsMap = new Map<String,Id>();
            for(Account acc : [select id,Pardot_Program_Name__c from account where Pardot_Program_Name__c in : otherProgramsValueSet]){
                accNamesToIdsMap.put(acc.Pardot_Program_Name__c,acc.Id);
            }
                for(Id accId : accNamesToIdsMap.values()){
                  affiliationListToBeInserted.add(new hed__Affiliation__c(hed__Account__c= accId,
                                                           hed__Contact__c=conInsertList[i + 1].Id));
                }
            }
        }
        }
        else{
            //creates Affiliation record if filled by student only
            if(conInsertList.size()==1){
            for(Integer i = 0, s = conInsertList.size(); i < s; i += 2){
                if( listname.isEmpty()==false && record != null){
            hed__Affiliation__c hedaff = new hed__Affiliation__c();
            hedaff.hed__Account__c = record ;
            hedaff.hed__Contact__c = conInsertList[i].Id;
            hedaff.hed__Primary__c = true;
            affiliation.add(hedaff);
                }
                if(otherProgramsValueSet != null){
                Map<String,Id> accNamesToIdsMap = new Map<String,Id>();
                for(Account acc : [select id,Pardot_Program_Name__c from account where Pardot_Program_Name__c in : otherProgramsValueSet]){
                    accNamesToIdsMap.put(acc.Pardot_Program_Name__c,acc.Id);
                }
                for(Id accId : accNamesToIdsMap.values()){
        affiliationListToBeInserted.add(new hed__Affiliation__c(hed__Account__c=accId,hed__Contact__c=conInsertList[i].Id));
    }
                }
        }
        }
        }
        insert relation;
        insert affiliation;
        insert affiliationListToBeInserted;
    }
    LeadStatus convertStatus = [Select MasterLabel from LeadStatus where IsConverted = true limit 1];
 
List<Database.LeadConvert> leadConverts = new List<Database.LeadConvert>();
    map<Id,Contact> conMap = new map<Id,Contact>();
for (Lead lead: Trigger.new) {
if (!lead.isConverted && lead.Status == 'New' ) {
Database.LeadConvert lc = new Database.LeadConvert();
String opportunityName = lead.Name;
 
            lc.setLeadId(lead.Id);
            lc.setSendNotificationEmail(false);
            lc.setDoNotCreateOpportunity(true); 
            String currentemail = lead.Email;
            List<Contact> id1 = [SELECT Id, Email,AccountId FROM Contact WHERE Email = :currentemail AND recordtype.name = 'Lead'];
                String Idcon;
                string accname123;
                 for(Contact ce1 : id1){
                          Idcon = ce1.Id;
                          accname123 = ce1.AccountId;
              }
                  lc.setContactId(Idcon);
                  lc.setAccountId(accname123);
                  lc.setConvertedStatus(convertStatus.MasterLabel);
                  leadConverts.add(lc);
            }
            }
                if (!leadConverts.isEmpty()) {
                List<Database.LeadConvertResult> lcr = Database.convertLead(leadConverts);
}
}


 
I'm trying to create a validation rule that makes fields specific required for certain users based on their roles. If a user's role is: Account Manager, Sales Rep, or International Sales, AND they are marking an opportunity stage (picklist) as "Closed - Won" we want to make a few fields required.

The fields we want to be required if the above is true are: 
ARR 
Total Opportunity Value (TCV)
Reason for Win 
Win Notes
Growth
Products Sold

In addition to the above, we also need the minimum characters for "Win Notes" and "Growth" to be 500 characters.

Any help is greatly appreciated.