• shailesh_rawte
  • NEWBIE
  • 45 Points
  • Member since 2018

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 2
    Likes Given
  • 0
    Questions
  • 17
    Replies
Hi all, i am new to this so thanks in advance for help. I am struggling to create a test class for my Invocable Method. I just cant get it to work - i keep getting the error Method Does not exist Or incorrect Signature. I know i am doing something wrong. Below is the two classes - 
 
public class PrevetActive4 {

    
@InvocableMethod(label='Get Prevett and update MATT' description='Returns the list of Prevett names corresponding to the specified account IDs.')
  
    public static void getPrevett2(List<Id> Ids) {

       
        List<Prevet_Checklist__c> mt = [Select Name, id,Active_Prevett__c, Open_Closed__c FROM Prevet_Checklist__c WHERE Id in :Ids AND Open_Closed__c = 'Queue' AND OwnerId = '00528000000kb5s' Order by CreatedDate ASC Limit 1];
       
        for (Prevet_Checklist__c one1 : mt) {
            one1.Open_Closed__c = 'Ready';
            one1.Active_Prevett__c = true;
            
            
        }
        update mt ;

}
}
 
@IsTest
private class TEST_Prevett2

{
    private static testMethod void myPrevettTest2() 
    {

     
       Prevet_Checklist__c PV = new Prevet_Checklist__c(Open_Closed__c = 'Queue', Active_Prevett__c = False, OwnerId = '00528000000kb5s');

       Insert PV;
        
       
       PrevetActive4.getPrevett2(PV);

    
       Prevet_Checklist__c result = [Select ID, OwnerId, Open_Closed__c, Name, Active_Prevett__c, Client_Name__c, Name_of_Adviser__c From Prevet_Checklist__c WHERE Open_Closed__c = 'Ready' AND OwnerId = '00528000000kb5s' Order by CreatedDate ASC Limit 1];
       System.assertEquals('Ready', result.Open_Closed__c);
       System.assertEquals(True, result.Active_Prevett__c);



    }
}



Thanks
 
hi i am a beginner in salesforce.i have a requirement . there are 2 sections in a vf page .in first section there is only one input textbox which takes values for a country field . and a button called "add" once this button is clicked in the backend it has to add the value in country textbox to a selectlist. so how many times we click on add button those many values must be added to select list.there is another button submit. once submit button is clicked the country list must be displayed in 2nd pageblock section . how can i achieve this

vf page code is :
<apex:page Controller="selectlistoption">
    <apex:form >
    <apex:pageBlock >
        <apex:pageBlockSection >
        
            <apex:outputlabel value="Enter Country"/>
            <apex:inputText value="{!str}"/>
            <apex:commandButton value="Add" action="{!setCountry}"/> 
            <apex:commandButton value="submit" rerender="showdetails"/>
        </apex:pageBlockSection>    
        
    <apex:pageBlockSection id="showdetails">
        
            <apex:selectlist size="1" value="{!str}">
           
                <apex:selectoptions value="{!country}"/>
                 </apex:selectlist>
        
 
        
        </apex:pageBlockSection>
                    </apex:pageBlock>
    </apex:form>
 
</apex:page>

------------------------------------------------------------------------apex code -------------------------------------------------------------
public class selectlistoption {
    
    
      public   string str{get;set;}
    

   public  list<selectoption> country{get;set;}
    
    public void setCountry()
    {
         
        country.add(new selectoption(str,str));
       
    }
    
   

}
 
apex class :
public with sharing class EnrollmentFormClass {
public Contact con {get;set;}
public Contact conc {get;set;}
public Contact conct {get;set;}
public List<Contact> concAddList{get;set;}
public Account acc {get;set;}
    
public EnrollmentFormClass() {
     con  = new Contact();
     conc = new Contact();
     conct = new Contact();
     acc  = new Account();
     concAddList  = new List<Contact>();  
     //concAddList.add(con);
     }
    public void AddRow(){
        conct = new Contact();
        concAddList.add(conct);
        //concAddList.add(new Contact());
    }
public void save(){
    insert con;    
    acc.name = con.lastName;
    insert acc;
    con.AccountId = acc.Id;
    conc.AccountId = acc.Id;
    conct.AccountId = acc.Id;
    
    insert conc;
    insert conct;
    insert concAddList;
    update con;
   
    }
     
}
visualforcepage :

<apex:page controller="EnrollmentFormClass">
    <apex:form >
    <apex:pageBlock title="Opportunitiy Zone Enrollment Form">
              <apex:pageBlockSection columns="3">
              <apex:inputField value="{!con.Student_Name__c}"/>
              <apex:inputField value="{!con.School__c}"/> 
              <apex:inputField value="{!con.Date__c}"/> 
            </apex:pageBlockSection>
            <br/> 
            <br/>
                    SPARC programs are funded by United Way of Greater Atlanta. As such, we are required to report demographic, income, educational and health access information on every individual/family we serve. With the United Way belief that serving one family member serves them all, we collect general information on each member of your household. We appreciate your willingness to complete this form in its entirety so that we can continue providing free programs to the community. Thank you!
            <br/>  
            <br/> 
            <apex:pageBlockSection title="Head of Household Information:">
                <apex:inputField value="{!con.FirstName}"/>
                <apex:inputField value="{!con.LastName}"/>
                <apex:inputField value="{!con.Date_of_Birth__c}"/>
                <apex:inputField value="{!con.Gender__c}"/> 
                <apex:inputField value="{!con.Do_you_have_a_primary_medical_provider__c}"/>
                <apex:inputField value="{!con.Do_you_have_a_primary_medical_provider__c}"/>
                <apex:inputField value="{!con.Address__c}"/>
                <apex:inputField value="{!con.City__c}"/>
                <apex:inputField value="{!con.State__c}"/>
                <apex:inputField value="{!con.County__c}"/>
                <apex:inputField value="{!con.Phone__c}"/>
                <apex:inputField value="{!con.Email_Address__c}"/>
                <apex:inputField value="{!con.Preferred_Method_of_Contact_Circle_One__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlocksection title="Demographic Data: (All information is confidential and is used in applying for grants to fund this program.)" columns="3">
                 <apex:inputField value="{!con.Spanish_translation_Services_Needed__c}"/>
                 <apex:inputField value="{!con.Race_Check_One__c}"/>
                 <apex:inputField value="{!con.Marital_Status_check_one__c}"/>
                 <apex:inputField value="{!con.HIGHEST_LEVEL_OF_EDUCATION_Check_one__c}"/>
                 <apex:inputField value="{!con.Employment_check_one__c}"/>
            </apex:pageBlocksection>
            <apex:pageBlocksection title="Income:" columns="3">
                <apex:inputField value="{!con.Annual_Income__c}"/> 
                <apex:inputField value="{!con.Source_of_Income__c}"/> 
                <apex:inputField value="{!con.Primary_Method_of_Transportation__c}"/>
            </apex:pageBlocksection>
            <apex:pageBlocksection title="HOUSEHOLD Information:" columns="3">
                <apex:inputField value="{!conc.Other_Adult_First_Name__c}"/>
                <apex:inputField value="{!conc.LastName}"/>
                <apex:inputField value="{!conc.Date_of_Birth__c}"/>
                <apex:inputField value="{!conc.Gender__c}"/> 
                <apex:inputField value="{!conc.Relationship_Primary_Care_Provider__c}"/>
                <apex:inputField value="{!conc.Medical_Insurance__c    }"/> 
            </apex:pageBlocksection>
                <apex:pageBlockButtons location="bottom" >
                <apex:commandButton action="{!save}" value="save"/>
            </apex:pageBlockButtons> 
            <apex:pageBlocksection title="Children (all children currently in your household, INCLUDING those participating in this program):" columns="1">
             <apex:pageBlockTable value="{!conct}" var="c">
             <apex:column headerValue="Name">
             <apex:commandButton action="{!AddRow}" value="AddRow"/>
             </apex:column>
             <apex:column headerValue="Name">
             <apex:inputfield value="{!c.LastName}"/>  
             </apex:column> 
             <apex:column headerValue="Date of Birth">
             <apex:inputfield value="{!c.Date_of_Birth__c}"/>
             </apex:column>
             <apex:column headerValue="Gender">
             <apex:inputfield value="{!c.Gender__c}"/>
             </apex:column>
             <apex:column headerValue="Relationship Primary Care Provider">
             <apex:inputfield value="{!c.Relationship_Primary_Care_Provider__c}"/>
             </apex:column>
             <apex:column headerValue="Medical Insurance">
             <apex:inputfield value="{!c.Medical_Insurance__c}"/>
             </apex:column>             
       </apex:pageBlockTable> 
       </apex:pageBlocksection>
       </apex:pageBlock>
    </apex:form>
</apex:page>
Hi Team,

After delete & update code not covered in trigger. please give me any idea about this requirement.

Trigger:
----------
trigger FinancialsCountTrigger on Financials__c (after insert, after update, after delete, after undelete) {
    
    if(checkRecursive.runOnce()){
        
        List<Account> updateAcc = new List<Account>();
        Set<Id> accid = new Set<Id>();
        
        Decimal totalRevenue;
        Decimal totalEBITDA;
        
        if(Trigger.isAfter && (Trigger.isInsert || Trigger.isUpdate || Trigger.isUndelete)){
            for(Financials__c fin : Trigger.New){
                if(fin.AccountName__c != null){
                    accid.add(fin.AccountName__c);
                }
            }
        }
        
        if(Trigger.isAfter && (Trigger.isUpdate || Trigger.isDelete)){
            for(Financials__c fin : Trigger.Old){
                if(fin.AccountName__c != null){
                    accid.add(fin.AccountName__c);
                    //system.debug('-----'+accid);
                }
            }
        }
        
            if(accid.size() > 0){
            List<Account> acclist = [select id,Name,Global_Revenue_Total__c,Global_EBITDA_B4_Total__c,
                                     (select id,Global_Revenue_Total__c,Global_EBITDA_B4_Total__c from Financial__r) from Account where id in :accid];
            
            for(Account acc : acclist){
                
                
                List<AggregateResult> aggres = [Select sum(Global_Revenue_Total__c)revtot,sum(Global_EBITDA_B4_Total__c)ebitdatot
                                                from Financials__c where AccountName__c=:acc.id and Year__c='FY-2017'];
                for(AggregateResult ag : aggres){
                    totalRevenue = (Decimal)ag.get('revtot');
                    totalEBITDA = (Decimal)ag.get('ebitdatot');
                }
                acc.Global_Revenue_Total__c = totalRevenue;
                acc.Global_EBITDA_B4_Total__c = totalEBITDA;
                updateAcc.add(acc);
            }
          }
          update updateAcc;
        
    }
    
}
Test Class
-----------------
@isTest
public class TestFinancialsCountTrigger {
    
    public static testMethod void financialCount(){
        
        Account acc = new Account(Name='3M Corporation',Industry='Conglomerate');
        insert acc;
        
        Account acc2 = new Account(Name='3M Corporation2',Industry='Conglomerate');
        insert acc2;
        
        Financials__c fin = new Financials__c(AccountName__c=acc.id,Name='Test',Year__c='FY-2017',Global_Revenue_Total__c=100,Global_EBITDA_Total__c=200);
        insert fin;
        
        Financials__c fin2 = new Financials__c(AccountName__c=acc2.id,Name='Test2',Year__c='FY-2017',Global_Revenue_Total__c=500,Global_EBITDA_Total__c=400);
        insert fin2;
        
        fin.Global_Revenue_Total__c = 500;
        update fin;
        delete fin;
                
        Test.startTest();
        
        List<Financials__c> finlist = [select id from Financials__c where AccountName__c = :acc.Id and Year__c='FY-2017'];
        delete finlist;
        
        Test.stopTest();
        
        
    }

}
Please give me reply any one......

Regards
Lakshmi

 
I need help with making 2 custom fields created to be required if the Do not create Opp checkbox is not checked. If it is checked then the 2 fields shud be required. I also need to map the value of these fields to 2 custom fields in Opportunity. Code from Class below : 
 
public with sharing class ConvertLeadExtn
{
    Final Lead curLead;
    public boolean IsSendEmailChecked{get;set;}
    public String SelectedAccType{get;set;}
    public Contact ContactAcctToRefer{get;set;}
    public boolean IsOppChecked{get;set;}
    public String SelectedConvrtdStatus{get;set;}
    
    //Returns the list of account types
    public list<selectOption> lstAccountType
    {
        get
        {
            List<selectOption> lstAcctType = new List<selectOption>();
            lstAcctType.add(new selectOption('','--None--'));
            lstAcctType.add(new selectOption('Create New Account','Create New Account'));
            lstAcctType.add(new selectOption('Attach to Existing','Attach to Existing'));
            return lstAcctType;
        }
        set;
    }
    
    // Returns the converted Status list
    public List<selectOption> lstConvertedStatusList
    {
        get
        {
            List<selectOption> lstConvertedStatus = new List<selectOption>();
            LeadStatus leadStatus = [Select Id, MasterLabel from LeadStatus where IsConverted=true limit 1];
            lstConvertedStatus.add(new selectOption(leadStatus.MasterLabel,leadStatus.MasterLabel));
            return lstConvertedStatus;
        }
        set;
    }
     
    //Controller
    public ConvertLeadExtn(ApexPages.StandardController controller)
    {
        this.curLead = (Lead)controller.getRecord();
        if(curLead.Id!=null)
        {
            ContactAcctToRefer = new Contact();
        }
    }
           
    //Converts the Lead
    public PageReference ConvertLead()
    {
        Id accountId;
        PageReference accPage;
        try
        {
            Database.LeadConvert leadCnvrt = new database.LeadConvert();
            if(SelectedAccType == null || SelectedAccType =='')
            {
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Please Select Account Type!'));
                return null;
            }
            
            //Sets all the fields that are required
            leadCnvrt.setLeadId(curLead.Id);
            leadCnvrt.setOwnerId(curLead.OwnerId);
            leadCnvrt.setSendNotificationEmail(IsSendEmailChecked);            
            leadCnvrt.setDoNotCreateOpportunity(IsOppChecked);
            leadCnvrt.setConvertedStatus(SelectedConvrtdStatus);
           
            if(SelectedAccType == 'Attach to Existing')
            {
                if(ContactAcctToRefer.accountId !=null)
                {
                    leadCnvrt.setAccountId(ContactAcctToRefer.accountId);
                }
                else
                {
                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Please Select Existing account to attach!'));
                    return null;
                }
            }
            
            if(!leadCnvrt.isDoNotCreateOpportunity())
            {
                leadCnvrt.setOpportunityName(curLead.Company);
            }
            
            Database.LeadConvertResult leadCnvrtResult = Database.convertLead(leadCnvrt);
            accountId=leadCnvrtResult.getAccountId();
            System.assert(leadCnvrtResult.isSuccess());
        }
        catch(exception excptn)
        {
            String excptnMsg = excptn.getMessage();
                     
            if(excptnMsg.contains('CANNOT_UPDATE_CONVERTED_LEAD') || excptnMsg.contains('INVALID_CROSS_REFERENCE_KEY'))
            {
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Lead Conversion Failed! Lead is already converted!'));
            }
            else if(excptnMsg.contains('TRANSFER_REQUIRES_READ'))
            {
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Opportunity can not be created, User do not have Read Permission!'));
            }
            else
            {
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,excptn.getMessage()));
            }
        }
        if(accountId!=null)
        {
            accPage = new pageReference('/'+accountId);
        }
        return accPage;
    }
}

 
I would like the user to see the number of notifications sent and the latest date. The date stamp is working fine but the number stamp isn't working. I have set the default value to 0 for the number field on case and the field update formula calls the field and adds 1 -  PRIORVALUE (Number_of_Dealer_Reminders_Sent__c) + 1. The problem is that the number field does not update nor does it show the default (0). Please help - is it maybe the way formula when setting the default? Basically I have 0 in the formula field - custom.
 
Error:Apex trigger InquiryTrigger caused an unexpected exception, contact your administrator: InquiryTrigger: execution of AfterUpdate caused by: System.QueryException: List has no rows for assignment to SObject: Class.InquiryTriggerHandler.InquiryHandler: line 13, column 1

How do I fix this issue?

 
public class InquiryTriggerHandler {
    
    public static void InquiryHandler(string caseid){
       
        
        
        
        
        Case cs=[SELECT id,OwnerId,ContactID,Confirmation_Email__c,ContactEmail From Case WHERE id=:caseid];
        
        system.debug('CaseID: '+caseid);
        
        user u=[select id,email from user where id=:cs.ownerid];
        
        system.debug('User Email: '+u.email);
        
        system.debug('Confirmation Mail: '+cs.Confirmation_Email__c);
        
        system.debug('Contact Email: '+cs.ContactEmail);
        
        List<Messaging.SingleEmailMessage> lsem=new List<Messaging.SingleEmailMessage>();
        
        Messaging.SingleEmailMessage sem=new Messaging.SingleEmailMessage();
        
        List<String> address=new List<String>();
        
        //address.add(u.email);
        
        address.add(cs.Confirmation_Email__c);
        
        address.add(cs.contactemail);
        
        address.add('siddharth.koduri@gmail.com');
        
        sem.setToAddresses(address);
        
        sem.setCcAddresses(new string[]{u.email});

        //sem.setSubject('testing');
        
        //sem.setplaintextbody('jjjj');
        EmailTemplate et=[SELECT id,Name FROM EmailTemplate WHERE name='Email Confirmation Template II'];
        
        sem.setTemplateId(et.id);
        
        sem.setTargetObjectId(cs.contactId);
        
        sem.setWhatId(cs.id);
        
       
       OrgWideEmailAddress owd=[SELECT id,Address FROM OrgWideEmailAddress WHERE Address=:system.label.Taconic_Mail_id];
       
       sem.setOrgWideEmailAddressId(owd.id);
        
        
       List<Attachment> att=[SELECT id,Name,Body,ContentType FROM Attachment WHERE ParentID=:caseid];
        
        List<Messaging.EmailFileAttachment> lefa=new List<Messaging.EmailFileAttachment>();
        
        for(Attachment a:att){
            
            Messaging.EmailFileAttachment efa=new Messaging.EmailFileAttachment();
            string contentvalue=(a.contentType).substringAfter('/');
            efa.setBody(a.body);
                efa.setFileName(a.Name);
            lefa.add(efa);
            
        } 
   
        sem.setFileAttachments(lefa); 
          
        
        
        lsem.add(sem);
            
        messaging.sendEmail(lsem);
    
        
        
    }
}

 
  • February 07, 2018
  • Like
  • 0
Hi. I've tried a few things, but I'm not getting the result that I'm hoping for. I'm trying to extract a fixed length string from a substring. Problem is that the string I'm looking for is not always in the same position in the substring. For example, see the string below. I want to extract "ECN_nnnn" from this. However, the letters "ECN_" isnt always in the same spot.  There will always be 4 characters to the right of "ECN_"

DOCUMENT APPROVAL: ECN_1053 - Auto Refractors Portuguese Labeling for Brazil

I think I'm using FIND and RIGHT, but cant get the syntax right. Thanks!
For system admin itself not working:
code:Trigger:
if(trigger.isafter && trigger.isinsert)
    {
        User_Case__Share userCaseShare=new User_Case__Share();
        User_case__c newUC=[SELECT Id, OwnerId FROM User_Case__c where id =:trigger.new];
        handler.shareUserCaseRec(newUC.Id,newUC.OwnerId);
    }

Hanlder class:
public class USRetail_StatusTypeChangeHandler {

    public void shareUserCaseRec(ID recordIDUC,ID UserOrGroupIdUC)
    {
         User_Case__Share userCaseShare=new User_Case__Share();
        userCaseShare.ParentId=recordIDUC;
        //userCaseShare.RowCause='Manual';
        userCaseShare.UserOrGroupId=UserOrGroupIdUC;
        userCaseShare.AccessLevel='Edit';
        insert userCaseShare;
    }
}
I am getting the above error. My requirement is to change the currency field data, if opportunity already having child quote records. So its not possible through standard . Thus I am working out for custom solution. Earlier its was working on clicking cancel it use to create clonned opportunity but now its not working now on create and on cancel both.

Apex:-


public with sharing class CloneOpportunityExtension {
    //to get opp id from url
    public String recId {get;set;}
    // for new currency and name
    public Opportunity cloneOpp {get;set;}
    
    public CloneOpportunityExtension(ApexPages.StandardController stdCon) {
        cloneOpp = new Opportunity();
        recId = null;
        recId = ApexPages.currentPage().getParameters().get('id'); 
        System.debug('recId'+recId);
        if(recId!=null) {
            // setting the currency on page load
            cloneOpp.CurrencyIsoCode = ((opportunity)stdCon.getRecord()).CurrencyIsoCode;
            // setting Name
            cloneOpp.Name = ((opportunity)stdCon.getRecord()).Name;
            

//setting Account Name
// cloneOpp.Account= ((opportunity)stdCon.getRecord()).Account;
        } else {
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, ' '+Label.select_a_vaild_Opportunity));
        }
    }
   
    /**
    * to save the Clone Opportunity with New Currency
    * 
    */
    public PageReference saveNewOpp(){   
        PageReference pRef = null;
        if(recId!=null) {
            if(cloneOpp!=null) {
                try{
                    // calling clone class
                    String returnId = null;
                    returnId = Cls_CloneOptyRelated.CloneOpportunity(recId, cloneOpp.CurrencyIsoCode, cloneOpp.Name);
                    if(returnId!=null) {
                        pRef = new PageReference('/'+returnId);
                        pRef.setRedirect(true);
                    }
                    else {
                       ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, ' '+Label.Issue_in_Cloning));
                    }
                }
                catch(Exception e) {
                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, ' ' + Label.Issue_in_Cloning + ' ' + e.getMessage()));
                }
            }
        }
        return pRef;
    }
}


Visualforce Page:-

<apex:page standardController="Opportunity" extensions="CloneOpportunityExtension" tabStyle="Opportunity" title="{!$ObjectType.Opportunity.Label} {!$Label.Clone}">
<apex:sectionHeader subtitle="{!Opportunity.Name}" title="{!Opportunity.Name} {!$Label.Clone}" rendered="{!recId != null}"/>
<apex:form >
<apex:pageMessages >
</apex:pageMessages>
<apex:pageBlock title="{!$ObjectType.Opportunity.Label} {!$Label.Clone}">
<apex:pageBlockButtons location="bottom">
<apex:commandButton action="{!saveNewOpp}" value="{!$Label.Clone}" rendered="{!recId != null}"/>
<apex:commandButton action="{!cancel}" value="{!$Label.Cancel}" rendered="{!recId != null}"/>
<apex:outputPanel rendered="{!recId == null}"> <input type="button" name="{!$Label.Back}" value="{!$Label.Back}" class="btn" onclick="window.top.location='/006/o';"/>
</apex:outputPanel>
</apex:pageBlockButtons>
<apex:pageBlockSection columns="1">
<apex:inputField value="{!cloneOpp.Name}" label="{!$ObjectType.Opportunity.fields.Name.Label}"/>
<apex:inputField value="{!cloneOpp.CurrencyIsoCode}" label="{!$ObjectType.Opportunity.fields.CurrencyIsoCode.Label}"/>
<!--- <apex:inputField value="{!cloneOpp.Account.Name}" label="{!$ObjectType.Opportunity.fields.Account.Name.Label}"/> ----> </apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

Errorr Message:-

Errors

Parent Opportunity: Value does not exist or does not match filter criteria.
Issue in cloning Opportunity, Please Contact System Administrator Insert failed. First exception on row 0; first error: FIELD_FILTER_VALIDATION_EXCEPTION, Value does not exist or does not match filter criteria.: [CBG_Parent_Opportunity__c]
Hi all, i am new to this so thanks in advance for help. I am struggling to create a test class for my Invocable Method. I just cant get it to work - i keep getting the error Method Does not exist Or incorrect Signature. I know i am doing something wrong. Below is the two classes - 
 
public class PrevetActive4 {

    
@InvocableMethod(label='Get Prevett and update MATT' description='Returns the list of Prevett names corresponding to the specified account IDs.')
  
    public static void getPrevett2(List<Id> Ids) {

       
        List<Prevet_Checklist__c> mt = [Select Name, id,Active_Prevett__c, Open_Closed__c FROM Prevet_Checklist__c WHERE Id in :Ids AND Open_Closed__c = 'Queue' AND OwnerId = '00528000000kb5s' Order by CreatedDate ASC Limit 1];
       
        for (Prevet_Checklist__c one1 : mt) {
            one1.Open_Closed__c = 'Ready';
            one1.Active_Prevett__c = true;
            
            
        }
        update mt ;

}
}
 
@IsTest
private class TEST_Prevett2

{
    private static testMethod void myPrevettTest2() 
    {

     
       Prevet_Checklist__c PV = new Prevet_Checklist__c(Open_Closed__c = 'Queue', Active_Prevett__c = False, OwnerId = '00528000000kb5s');

       Insert PV;
        
       
       PrevetActive4.getPrevett2(PV);

    
       Prevet_Checklist__c result = [Select ID, OwnerId, Open_Closed__c, Name, Active_Prevett__c, Client_Name__c, Name_of_Adviser__c From Prevet_Checklist__c WHERE Open_Closed__c = 'Ready' AND OwnerId = '00528000000kb5s' Order by CreatedDate ASC Limit 1];
       System.assertEquals('Ready', result.Open_Closed__c);
       System.assertEquals(True, result.Active_Prevett__c);



    }
}



Thanks
 
Hi

One profile does cannot convert Leads in UAT and Production. Is this an access issue on the profile or something on the Opportunity Triggers?

Sys Admin (me) can convert leads fine

error that the user recieves
"Error: There was an error converting the lead. Please resolve the following error and try again: OpportunityTriggers: execution of AfterInsert caused by: System.DmlException: Insert failed. 
First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: 0065D000002VBSk: [] Class.OLOpportunityTeamCreator.createOppTeamMemberForOL: 
line 50, column 1 Class.OpportunityAfterInsertTriggerHandler.mainEntry: line 18, column 1 Class.TriggerDispatcherBase.execute: line 117, 
column 1 Class.OpportunityTriggerDispatcher.afterInsert: 
line 63, column 1 Class.TriggerFactory.execute: line 51, column 1 Class.TriggerFactory.createTriggerDispatcher: line 21, column 1 Trigger.OpportunityTriggers: line 90, column 1

Error within the debug log
"16:50:35.208 (2588613820)|EXCEPTION_THROWN|[50]|System.DmlException: Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: 0065D000002VEvz: []
16:50:35.208 (2589179967)|HEAP_ALLOCATE|[50]|Bytes:174
16:50:35.208 (2589213069)|METHOD_EXIT|[18]|01p6F000006HWOz|OLOpportunityTeamCreator.createOppTeamMemberForOL(List<Opportunity>)
16:50:35.208 (2589228466)|METHOD_EXIT|[117]|01p6F000006SKst|OpportunityAfterInsertTriggerHandler.mainEntry(TriggerParameters)
16:50:35.208 (2589240942)|METHOD_EXIT|[63]|01p6F000006SKt2|TriggerDispatcherBase.execute(ITriggerHandler, TriggerParameters, TriggerParameters.TriggerEvent)
16:50:35.208 (2589250299)|METHOD_EXIT|[51]|01p6F000006SKsy|OpportunityTriggerDispatcher.afterInsert(TriggerParameters)
16:50:35.208 (2589265855)|METHOD_EXIT|[21]|01p6F000006SKt4|TriggerFactory.execute(ITriggerDispatcher)
16:50:35.208 (2589274199)|SYSTEM_MODE_EXIT|false
16:50:35.208 (2589287768)|METHOD_EXIT|[90]|01p6F000006SKt4|TriggerFactory.createTriggerDispatcher(Schema.SObjectType)
16:50:35.208 (2589388541)|FATAL_ERROR|System.DmlException: Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: 0065D000002VEvz: []"

I have looked at Triggers as listed in the debug log, but i am not sure exactly what i am looking for.  I don't see reference ot the profile anywhere
01p6F000006HWOz|OLOpportunityTeamCreator.createOppTeamMemberForOL(List<Opportunity>)
01p6F000006SKst|OpportunityAfterInsertTriggerHandler.mainEntry(TriggerParameters)
01p6F000006SKt2|TriggerDispatcherBase.execute(ITriggerHandler, TriggerParameters, TriggerParameters.TriggerEvent)
01p6F000006SKsy|OpportunityTriggerDispatcher.afterInsert(TriggerParameters)
01p6F000006SKt4|TriggerFactory.execute(ITriggerDispatcher)

i have debug logs for the profile that is failing 

i have debug logs for me that are allowing to convert the Lead.

what is the best way to figure out where i need to change the access?  The logs are long and this is my first time looking at debug logs. 

UAT refresh Dec 22nd - only change in environments

thank you
Cat




 
global class Edgeforce {
  global class searchResult
    {
        string thumbnail = '';
        string title = '';
        string description = '';
        string link = '';
        integer size = 0;
        string type = '';
        id recordId;
        sObject objectData;
        String startDate = '';
    }
    
        //By this field Tab would be selected on intranetPages 
    global static String tabName {get; set;}
    //This map is used to identified top level parent of CMS pages.
    global static map<String, String> parentTabMap {get;set;}
    //By this field category limit will be decided on each object. 
    global static final Integer categoryLimit {get;set;}
    //By this field no of records will be decided to show on Search page 
    global static final Integer paginationLimit {get; set;}
    //Key prefix of Intranet_Article__c object
    private static final String IntranetArticleKeyPrefix {get; set;}
    static Map<String, String> contentNameTitleMap;
    static Map<String, String> parentTabNameMap;
    static Map<SObject, Intranet_Content__c> versionContentMap = new Map<SObject, Intranet_Content__c>();
    static {
            //Initialize final varibles to decide search configuration
            for(Intranet_content__c searchConfig : [Select Name, value__c From Intranet_content__c where recordType.Name = 'Config - Portal']) {
            if(searchConfig.Name == 'Search Limit') {
                categoryLimit = Integer.valueOf(searchConfig.value__c);
            }
            if(searchConfig.Name == 'Search Pagination') {
                paginationLimit = Integer.valueOf(searchConfig.value__c);
            }           
        }
        IntranetArticleKeyPrefix = Schema.getGlobalDescribe().get('Intranet_Content_Version__c').getDescribe().getKeyPrefix();
    }
     
    /*remote method to be accessed via javascript for performing a search.
      arguments
          searchTerm: a string at least two characters long (not including wildcards) to search for
          objectList: a list/array of sObject names which to query for
          objectLabels: a map/javascript object of sObject names to a friendly label to use in the result. Multiple sObjects can have the same label and will be returned in the same group.
          typeLimit: a maxmimum amount of each kind of object to find. This is per sObject type, not per label or for the total search.  
    */ 
    @RemoteAction
    global static map<string,list<searchResult>> globalSearch(string searchTerm,boolean isMobile,list<string>objectList,map<string,string> objectLabels, integer typeLimit)
    {
        //map to hold the results. The results will have the objectLabels or names (if no label for that object type is provided) and a list of search results for it.
        map<string,list<searchResult>> results = new  map<string,list<searchResult>>();
        map<String, boolean> isIncludedInSearchMap = new map<String,Boolean>();
        parentTabMap = new map<String,String>();
        try
        { 
            string customObjectQuery = '';
            objectLabels = new map<string,string>();
           for(Intranet_Content__c searchConfig : [Select name,Object_Name__c,Display_In_Search__c From Intranet_Content__c Where RecordType.Name='Config - Search']) {
                isIncludedInSearchMap.put(searchConfig.Object_Name__c, searchConfig.Display_In_Search__c);
                objectLabels.put(searchConfig.Object_Name__c, searchConfig.Name);
            }
            
            String userLang = '';
            for(Intranet_content__c searchConfig : [Select Name, value__c From Intranet_content__c where recordType.Name = 'Config - Portal' AND name =: userinfo.getLanguage()]){
                if(searchConfig  != null){
                  userLang = searchConfig.Value__c;
                }
            }
            
            for(string obj : objectList)
            {
                if(obj == 'Intranet_Content_Version__c' && isIncludedInSearchMap.get(obj) == true) {
                    customObjectQuery += 'Intranet_Content_Version__c' +'(Name,Id,Language__c,Intranet_Content__c,Summary__c WHERE isPublished__c = true order by LastModifiedDate DESC LIMIT '+typeLimit+'),';
                }/*else if(obj == 'Intranet_CMS_Page__c' && isIncludedInSearchMap.get(obj) == true) {
                    customObjectQuery += 'Intranet_Content_Version__c'+'(Name,Id,Intranet_Content__c,Intranet_Content__r.Template__c,Intranet_Content__r.Skip_Menu_Link__c,Intranet_Content__r.URL__c,Intranet_Content__r.createdById,Intranet_Content__r.CreatedDate WHERE Intranet_Content__r.Status__c = \'Published\' AND Intranet_Content__r.RecordType.Name = \'Intranet CMS Pages\' order by Name LIMIT '+typeLimit+'),';
                }*/else if(obj == 'FeedItem' && isIncludedInSearchMap.get(obj) == true) {
                    customObjectQuery += obj+'(id, title, body, InsertedBy.Name, InsertedById, CreatedDate, ParentId order by CreatedDate DESC LIMIT '+typeLimit+'),';
                }else if(obj == 'ContentVersion' && isIncludedInSearchMap.get(obj) == true) {
                    customObjectQuery += obj+'(ContentDocumentId,ContentSize,ContentUrl,Description,IsLatest,PublishStatus,TagCsv,Title,FileType,Id order by RatingCount DESC LIMIT '+typeLimit+'),';
                }else if(obj == 'User' && isIncludedInSearchMap.get(obj) == true) {
                    customObjectQuery += obj+'(id, name, SmallPhotoUrl, email order by Name LIMIT '+typeLimit+'),';
                }else if(isIncludedInSearchMap.get(obj) == true){
                    customObjectQuery += obj+'(Name,Id,createdById,CreatedDate LIMIT '+typeLimit+'),';                
                }
            }
            
            system.debug(customObjectQuery);
            string objectsQuery = 'FIND \''+searchTerm+'\' IN ALL FIELDS RETURNING '+customObjectQuery.subString(0, customObjectQuery.length()-1);
            
            System.debug('debug objectsQuery >> ' + objectsQuery);
            List<List<SObject>> tempSearchList = search.query(objectsQuery);
            string objType = '';
            string objLabel = '';
            
            Map<ID,SObject>  contentVersionMap;
            List<List<SObject>> searchList = new List<List<SObject>>();
            List<SObject> sobjList;
            Set<ID> contentIdSet;
            boolean isContent;
            Map<ID, List<Intranet_Content_Version__c>> mapContContVersion;
            for(List<sObject> thisObjList : tempSearchList){
                sobjList= new List<SObject>();
                contentVersionMap = new Map<ID, SObject>();
                contentIdSet = new Set<ID>();
                mapContContVersion = new Map<ID, List<Intranet_Content_Version__c>>();
                isContent = false;
                for(sObject thisObj : thisObjList){
                  if(string.valueOf(thisObj.getsObjectType()) == 'Intranet_Content_Version__c'){
                     isContent = true;
                     //Added by Sidhant Agarwal T-331988
                     if(!mapContContVersion.containsKey((string)thisObj.get('Intranet_Content__c'))) {
                         mapContContVersion.put((string)thisObj.get('Intranet_Content__c'), new List<Intranet_Content_Version__c>());
                     }
                     mapContContVersion.get((string)thisObj.get('Intranet_Content__c')).add((Intranet_Content_Version__c)thisObj);
                    
                  }else{
                    sobjList.add(thisObj);
                  }
                }
                if(isContent){
                    for(String contentId : mapContContVersion.keyset()){
                      
                      for(Intranet_Content_Version__c icv : mapContContVersion.get(contentId)){
                          sobjList.add(icv);
                      }
                    }
                }
                searchList.add(sobjList);
            }
           
I need help with making 2 custom fields created to be required if the Do not create Opp checkbox is not checked. If it is checked then the 2 fields shud be required. I also need to map the value of these fields to 2 custom fields in Opportunity. Code from Class below : 
 
public with sharing class ConvertLeadExtn
{
    Final Lead curLead;
    public boolean IsSendEmailChecked{get;set;}
    public String SelectedAccType{get;set;}
    public Contact ContactAcctToRefer{get;set;}
    public boolean IsOppChecked{get;set;}
    public String SelectedConvrtdStatus{get;set;}
    
    //Returns the list of account types
    public list<selectOption> lstAccountType
    {
        get
        {
            List<selectOption> lstAcctType = new List<selectOption>();
            lstAcctType.add(new selectOption('','--None--'));
            lstAcctType.add(new selectOption('Create New Account','Create New Account'));
            lstAcctType.add(new selectOption('Attach to Existing','Attach to Existing'));
            return lstAcctType;
        }
        set;
    }
    
    // Returns the converted Status list
    public List<selectOption> lstConvertedStatusList
    {
        get
        {
            List<selectOption> lstConvertedStatus = new List<selectOption>();
            LeadStatus leadStatus = [Select Id, MasterLabel from LeadStatus where IsConverted=true limit 1];
            lstConvertedStatus.add(new selectOption(leadStatus.MasterLabel,leadStatus.MasterLabel));
            return lstConvertedStatus;
        }
        set;
    }
     
    //Controller
    public ConvertLeadExtn(ApexPages.StandardController controller)
    {
        this.curLead = (Lead)controller.getRecord();
        if(curLead.Id!=null)
        {
            ContactAcctToRefer = new Contact();
        }
    }
           
    //Converts the Lead
    public PageReference ConvertLead()
    {
        Id accountId;
        PageReference accPage;
        try
        {
            Database.LeadConvert leadCnvrt = new database.LeadConvert();
            if(SelectedAccType == null || SelectedAccType =='')
            {
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Please Select Account Type!'));
                return null;
            }
            
            //Sets all the fields that are required
            leadCnvrt.setLeadId(curLead.Id);
            leadCnvrt.setOwnerId(curLead.OwnerId);
            leadCnvrt.setSendNotificationEmail(IsSendEmailChecked);            
            leadCnvrt.setDoNotCreateOpportunity(IsOppChecked);
            leadCnvrt.setConvertedStatus(SelectedConvrtdStatus);
           
            if(SelectedAccType == 'Attach to Existing')
            {
                if(ContactAcctToRefer.accountId !=null)
                {
                    leadCnvrt.setAccountId(ContactAcctToRefer.accountId);
                }
                else
                {
                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Please Select Existing account to attach!'));
                    return null;
                }
            }
            
            if(!leadCnvrt.isDoNotCreateOpportunity())
            {
                leadCnvrt.setOpportunityName(curLead.Company);
            }
            
            Database.LeadConvertResult leadCnvrtResult = Database.convertLead(leadCnvrt);
            accountId=leadCnvrtResult.getAccountId();
            System.assert(leadCnvrtResult.isSuccess());
        }
        catch(exception excptn)
        {
            String excptnMsg = excptn.getMessage();
                     
            if(excptnMsg.contains('CANNOT_UPDATE_CONVERTED_LEAD') || excptnMsg.contains('INVALID_CROSS_REFERENCE_KEY'))
            {
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Lead Conversion Failed! Lead is already converted!'));
            }
            else if(excptnMsg.contains('TRANSFER_REQUIRES_READ'))
            {
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Opportunity can not be created, User do not have Read Permission!'));
            }
            else
            {
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,excptn.getMessage()));
            }
        }
        if(accountId!=null)
        {
            accPage = new pageReference('/'+accountId);
        }
        return accPage;
    }
}

 
Hi all, i am new to this so thanks in advance for help. I am struggling to create a test class for my Invocable Method. I just cant get it to work - i keep getting the error Method Does not exist Or incorrect Signature. I know i am doing something wrong. Below is the two classes - 
 
public class PrevetActive4 {

    
@InvocableMethod(label='Get Prevett and update MATT' description='Returns the list of Prevett names corresponding to the specified account IDs.')
  
    public static void getPrevett2(List<Id> Ids) {

       
        List<Prevet_Checklist__c> mt = [Select Name, id,Active_Prevett__c, Open_Closed__c FROM Prevet_Checklist__c WHERE Id in :Ids AND Open_Closed__c = 'Queue' AND OwnerId = '00528000000kb5s' Order by CreatedDate ASC Limit 1];
       
        for (Prevet_Checklist__c one1 : mt) {
            one1.Open_Closed__c = 'Ready';
            one1.Active_Prevett__c = true;
            
            
        }
        update mt ;

}
}
 
@IsTest
private class TEST_Prevett2

{
    private static testMethod void myPrevettTest2() 
    {

     
       Prevet_Checklist__c PV = new Prevet_Checklist__c(Open_Closed__c = 'Queue', Active_Prevett__c = False, OwnerId = '00528000000kb5s');

       Insert PV;
        
       
       PrevetActive4.getPrevett2(PV);

    
       Prevet_Checklist__c result = [Select ID, OwnerId, Open_Closed__c, Name, Active_Prevett__c, Client_Name__c, Name_of_Adviser__c From Prevet_Checklist__c WHERE Open_Closed__c = 'Ready' AND OwnerId = '00528000000kb5s' Order by CreatedDate ASC Limit 1];
       System.assertEquals('Ready', result.Open_Closed__c);
       System.assertEquals(True, result.Active_Prevett__c);



    }
}



Thanks