• Raju Mushke 19
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 4
    Replies

batch apex class:

public class lar_BatchConvertInterimPromptsToOpp implements Database.Batchable<sObject>,Schedulable,Database.Stateful,Database.AllowsCallouts{
   
    
   //Batch Configuration
    private String interimPromptQuery = 'SELECT  Id,Opportunity__c,End_Date__c,Client__r.RecordType.Name,Prompt__r.Prompt_Id__c,'+
        'Client__r.Customer_Id__c,Closed_Date__c,client__c,Prompt_Status__c,Type__c,Client__r.Customer_Status__c,'+
        'Last_Action_Owner__c,Interim_Action_Date__c,Client__r.Relationship_Manager_BRID__c,Client__r.End_Date__c,'+
        'Client__r.R_Marker__c,Prompt__r.Category__c,Customer_Prompt_ID__c, Prompt__r.Sub_Category__c,'+
        'Prompt__r.Short_Description__c,ActionNotesDesc__c,Last_Action_Owner_User__c '+
        'FROM Customer_Prompt__c ';
    public string queryFilter = '';    
    public bar_BatchService bService;  
    public static Id jobId;
    
    
    public lar_BatchConvertInterimPromptsToOpp() {
        queryFilter = queryFilter;
        
    }
    
    /**
* START BATCH
*/
    public Database.QueryLocator start(Database.BatchableContext BC){
        List<String> listLiveTRMS = new List<String>();
        //Change the Query accrding to JIRA: BUKSFBTWOC-125
        List<Interim_Prompts_Rollout__c> listInterimPromptsRollout = [Select Market__c from Interim_Prompts_Rollout__c where Enabled_for_Interim_Job__c = true Limit 50000];
        for (Interim_Prompts_Rollout__c obj : listInterimPromptsRollout) {
            listLiveTRMS.add(obj.Market__c);
        }

        queryFilter = ' WHERE Last_Action_Owner_User__r.Team_Name__c IN  (\''+String.join(listLiveTRMS, '\',\'')+'\') '+queryFilter ;
        
        String query = '';
        query = interimPromptQuery +''+ queryFilter;
        String emailIds = null;
        lar_Common_Setting__mdt emailSetting = lar_Utility.getSetting(lar_Constant.EMAIL_RECEIVER_BATCH_SETTING);
        if(emailSetting != null){
            emailIds = emailSetting.Value__C;
        }
        bService  = new bar_BatchService('lar_BatchConvertInterimPromptsToOpp','Batch to convert interim prompt', query, emailIds, true);
        return Database.getQueryLocator(query);
    }
    
    /**
* EXECUTE BATCH
*/
    public void execute(Database.BatchableContext BC, List<Customer_Prompt__c> interimPromptList){
        lar_ConvertPromptsToOppHelper.jobId = bc.getJobId();
        lar_ConvertPromptsToOppHelper.bService = bService;
        lar_ConvertPromptsToOppHelper.convertInterimPromptsToOpp(interimPromptList);
    }
    
    
    /*
* EXECUTE Schedular
*/
    public void execute(SchedulableContext sc) {
        
        lar_BatchConvertInterimPromptsToOpp objBatch = new lar_BatchConvertInterimPromptsToOpp();
        objBatch.queryFilter = buildQueryFilter();
        Database.executeBatch(objBatch,lar_Constant.CALLOUT_LIMIT);
    }
    
    /**
* FINISH BATCH
*/
    public void finish(Database.BatchableContext BC){
        bService.finish();
    }
    
    public String buildQueryFilter() {
        queryFilter = '';
        Map<String, Interim_Prompt_Batch_Processing__mdt> settingMap = getInerimProcessingSettings();
        
        if (settingMap.containsKey('premium')) {
            queryFilter = ' AND Internal_Status__c = \''+lar_Constant.INTERIM+'\' AND Interim_Action_Date__c != NULL AND Interim_Action_Date__c > LAST_N_DAYS:30  '+
                'AND End_Date__c = NULL AND Last_Action_Owner_User__c !=NULL AND Last_Action_Owner_User__r.IsActive = true '+
                'AND ( Client__r.Customer_Status__c = \'Active\' AND Client__r.RecordType.Name = \''+lar_Constant.ACC_RC_TYPE_PREMIER_CUSTOMER+'\' )  Order By Client__r.Id';
        } else if(settingMap.containsKey('community')) {
            queryFilter = ' WHERE Prompt__r.Prompt_Id__c = \''+lar_Constant.PROMPTID_1534+'\'';                        
        } else {
            queryFilter = ' WHERE ((Internal_Status__c = \'Interim\' AND Interim_Action_Date__c >= LAST_N_DAYS:30 AND Interim_Action_Date__c != NULL) '+
                ' OR (Prompt__r.Prompt_Id__c = \''+lar_Constant.PROMPTID_1534+'\'))'+ 
                ' AND End_Date__c = NULL Order By Client__r.Id ';
        }

        return queryFilter;
    }
    
    /**
* returns competitor product holding record type to be used for each topic heading
*/
    public static Map<String, Interim_Prompt_Batch_Processing__mdt> getInerimProcessingSettings(){
        Map<String, Interim_Prompt_Batch_Processing__mdt> settingMap = new Map<String, Interim_Prompt_Batch_Processing__mdt>();
        Map<String, Sobject> settings = bar_CustomMetadataUtility.getAll(new Interim_Prompt_Batch_Processing__mdt());
        
        for(Sobject sObj : settings.values()) {
            Interim_Prompt_Batch_Processing__mdt obj = (Interim_Prompt_Batch_Processing__mdt)sObj;
            if (obj.Default__c) {
                settingMap.put(obj.DeveloperName.toLowerCase(), obj);
            }            
        }
        return settingMap;
    }

    
}

 


can anyone please help how to do this.i am very new to the test clases.

 

Hi All,

could you please help on my requiremt.i am not able to do .please suggest and helpme how can i do the the below requirement.


Requirement:

we  hvae community portal in this community portal we have several users .if this users login in the community portal they able to see thier own records data in any one of the report chart.


for this i created report on my developer org. then i configure this report chart on community builder.but users can not see report chart while login in the community portal.

so i decedied i can achevie it through customazation. i have idea but i dont know how to achvie this through customiztion.

my requirement is:

1)fetch all the community users whoever in my org.(dynamically users login and see thier data on community portal).
2)fetch the report(what we created for showing in community portal).

3)then i call this apex method in the lightning component.

i dont know how i do it.


please hel me and suggest how can i do it.


Thank you&stay safe.

 

 


 

 


 

Challenge not yet complete in raju@ctrla.com
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Update failed. First exception on row 0 with id 0062v00001MoufGAAR; first error: CANNOT_EXECUTE_FLOW_TRIGGER, We can't save this record because the “Opportunity Management” process failed. Give your Salesforce admin these details. This error occurred when the flow tried to create records: FIELD_INTEGRITY_EXCEPTION: Account ID: id value of incorrect type: 0052v00000ZP6CKAA1. You can look up ExceptionCode values in the SOAP API Developer Guide. Error ID: 885716876-227304 (1978567413): [].

 

trailhead batch 

Build criteria and actions to replace your workflow rules.

 

could anyone please suggest how to achevie this error?

i am writing test class for below apex class. i am new to the apex coding.can anyone please help on this.

Apex class:

public class ContactsapexController {
    
    @AuraEnabled
    public static List<Account> getAccounts(){
        return [select id, Name, description,Owner.Name,Phone from Account];
    }
    
    @AuraEnabled
    public static List<Contact> getContacts(string accountId){
        list<contact> conlist=new list<contact>();
        system.debug(accountId);
        
        list<contact> con=[select id, Name, Title, Email, Phone, Account.Owner.Name from Contact where accountId =: accountId];
        for(contact c:con){
            conlist.add(c);
        }
        return conlist;
    }
    
    @AuraEnabled
    public static List<String> deleteRecords(List<contact> lstId){
        system.debug('lstId'+lstId);
        // for store Error Messages  
        List<String> oErrorMsg = new List<String> ();
        
        List<Contact> contacts = [select id from Contact where id in : lstId];
        Database.DeleteResult[] DR_Dels = Database.delete(contacts, false);
        for (Database.DeleteResult dr: DR_Dels){
            if (dr.isSuccess()) {
                system.debug('successful delete contact');
                // Operation was successful
            } else {
                // Operation failed, so get all errors   
                for (Database.Error err: dr.getErrors()) {
                // add Error message to oErrorMsg list and return the list
                    oErrorMsg.add(err.getStatusCode() + ': ' + err.getMessage());
                }
            }
        }
        return oErrorMsg;
    }
}

batch apex class:

public class lar_BatchConvertInterimPromptsToOpp implements Database.Batchable<sObject>,Schedulable,Database.Stateful,Database.AllowsCallouts{
   
    
   //Batch Configuration
    private String interimPromptQuery = 'SELECT  Id,Opportunity__c,End_Date__c,Client__r.RecordType.Name,Prompt__r.Prompt_Id__c,'+
        'Client__r.Customer_Id__c,Closed_Date__c,client__c,Prompt_Status__c,Type__c,Client__r.Customer_Status__c,'+
        'Last_Action_Owner__c,Interim_Action_Date__c,Client__r.Relationship_Manager_BRID__c,Client__r.End_Date__c,'+
        'Client__r.R_Marker__c,Prompt__r.Category__c,Customer_Prompt_ID__c, Prompt__r.Sub_Category__c,'+
        'Prompt__r.Short_Description__c,ActionNotesDesc__c,Last_Action_Owner_User__c '+
        'FROM Customer_Prompt__c ';
    public string queryFilter = '';    
    public bar_BatchService bService;  
    public static Id jobId;
    
    
    public lar_BatchConvertInterimPromptsToOpp() {
        queryFilter = queryFilter;
        
    }
    
    /**
* START BATCH
*/
    public Database.QueryLocator start(Database.BatchableContext BC){
        List<String> listLiveTRMS = new List<String>();
        //Change the Query accrding to JIRA: BUKSFBTWOC-125
        List<Interim_Prompts_Rollout__c> listInterimPromptsRollout = [Select Market__c from Interim_Prompts_Rollout__c where Enabled_for_Interim_Job__c = true Limit 50000];
        for (Interim_Prompts_Rollout__c obj : listInterimPromptsRollout) {
            listLiveTRMS.add(obj.Market__c);
        }

        queryFilter = ' WHERE Last_Action_Owner_User__r.Team_Name__c IN  (\''+String.join(listLiveTRMS, '\',\'')+'\') '+queryFilter ;
        
        String query = '';
        query = interimPromptQuery +''+ queryFilter;
        String emailIds = null;
        lar_Common_Setting__mdt emailSetting = lar_Utility.getSetting(lar_Constant.EMAIL_RECEIVER_BATCH_SETTING);
        if(emailSetting != null){
            emailIds = emailSetting.Value__C;
        }
        bService  = new bar_BatchService('lar_BatchConvertInterimPromptsToOpp','Batch to convert interim prompt', query, emailIds, true);
        return Database.getQueryLocator(query);
    }
    
    /**
* EXECUTE BATCH
*/
    public void execute(Database.BatchableContext BC, List<Customer_Prompt__c> interimPromptList){
        lar_ConvertPromptsToOppHelper.jobId = bc.getJobId();
        lar_ConvertPromptsToOppHelper.bService = bService;
        lar_ConvertPromptsToOppHelper.convertInterimPromptsToOpp(interimPromptList);
    }
    
    
    /*
* EXECUTE Schedular
*/
    public void execute(SchedulableContext sc) {
        
        lar_BatchConvertInterimPromptsToOpp objBatch = new lar_BatchConvertInterimPromptsToOpp();
        objBatch.queryFilter = buildQueryFilter();
        Database.executeBatch(objBatch,lar_Constant.CALLOUT_LIMIT);
    }
    
    /**
* FINISH BATCH
*/
    public void finish(Database.BatchableContext BC){
        bService.finish();
    }
    
    public String buildQueryFilter() {
        queryFilter = '';
        Map<String, Interim_Prompt_Batch_Processing__mdt> settingMap = getInerimProcessingSettings();
        
        if (settingMap.containsKey('premium')) {
            queryFilter = ' AND Internal_Status__c = \''+lar_Constant.INTERIM+'\' AND Interim_Action_Date__c != NULL AND Interim_Action_Date__c > LAST_N_DAYS:30  '+
                'AND End_Date__c = NULL AND Last_Action_Owner_User__c !=NULL AND Last_Action_Owner_User__r.IsActive = true '+
                'AND ( Client__r.Customer_Status__c = \'Active\' AND Client__r.RecordType.Name = \''+lar_Constant.ACC_RC_TYPE_PREMIER_CUSTOMER+'\' )  Order By Client__r.Id';
        } else if(settingMap.containsKey('community')) {
            queryFilter = ' WHERE Prompt__r.Prompt_Id__c = \''+lar_Constant.PROMPTID_1534+'\'';                        
        } else {
            queryFilter = ' WHERE ((Internal_Status__c = \'Interim\' AND Interim_Action_Date__c >= LAST_N_DAYS:30 AND Interim_Action_Date__c != NULL) '+
                ' OR (Prompt__r.Prompt_Id__c = \''+lar_Constant.PROMPTID_1534+'\'))'+ 
                ' AND End_Date__c = NULL Order By Client__r.Id ';
        }

        return queryFilter;
    }
    
    /**
* returns competitor product holding record type to be used for each topic heading
*/
    public static Map<String, Interim_Prompt_Batch_Processing__mdt> getInerimProcessingSettings(){
        Map<String, Interim_Prompt_Batch_Processing__mdt> settingMap = new Map<String, Interim_Prompt_Batch_Processing__mdt>();
        Map<String, Sobject> settings = bar_CustomMetadataUtility.getAll(new Interim_Prompt_Batch_Processing__mdt());
        
        for(Sobject sObj : settings.values()) {
            Interim_Prompt_Batch_Processing__mdt obj = (Interim_Prompt_Batch_Processing__mdt)sObj;
            if (obj.Default__c) {
                settingMap.put(obj.DeveloperName.toLowerCase(), obj);
            }            
        }
        return settingMap;
    }

    
}

 


can anyone please help how to do this.i am very new to the test clases.

 

Hi All,

could you please help on my requiremt.i am not able to do .please suggest and helpme how can i do the the below requirement.


Requirement:

we  hvae community portal in this community portal we have several users .if this users login in the community portal they able to see thier own records data in any one of the report chart.


for this i created report on my developer org. then i configure this report chart on community builder.but users can not see report chart while login in the community portal.

so i decedied i can achevie it through customazation. i have idea but i dont know how to achvie this through customiztion.

my requirement is:

1)fetch all the community users whoever in my org.(dynamically users login and see thier data on community portal).
2)fetch the report(what we created for showing in community portal).

3)then i call this apex method in the lightning component.

i dont know how i do it.


please hel me and suggest how can i do it.


Thank you&stay safe.

 

 


 

 


 

i am writing test class for below apex class. i am new to the apex coding.can anyone please help on this.

Apex class:

public class ContactsapexController {
    
    @AuraEnabled
    public static List<Account> getAccounts(){
        return [select id, Name, description,Owner.Name,Phone from Account];
    }
    
    @AuraEnabled
    public static List<Contact> getContacts(string accountId){
        list<contact> conlist=new list<contact>();
        system.debug(accountId);
        
        list<contact> con=[select id, Name, Title, Email, Phone, Account.Owner.Name from Contact where accountId =: accountId];
        for(contact c:con){
            conlist.add(c);
        }
        return conlist;
    }
    
    @AuraEnabled
    public static List<String> deleteRecords(List<contact> lstId){
        system.debug('lstId'+lstId);
        // for store Error Messages  
        List<String> oErrorMsg = new List<String> ();
        
        List<Contact> contacts = [select id from Contact where id in : lstId];
        Database.DeleteResult[] DR_Dels = Database.delete(contacts, false);
        for (Database.DeleteResult dr: DR_Dels){
            if (dr.isSuccess()) {
                system.debug('successful delete contact');
                // Operation was successful
            } else {
                // Operation failed, so get all errors   
                for (Database.Error err: dr.getErrors()) {
                // add Error message to oErrorMsg list and return the list
                    oErrorMsg.add(err.getStatusCode() + ': ' + err.getMessage());
                }
            }
        }
        return oErrorMsg;
    }
}
I used following component and controller with apex class: But i am knew to lightning, Please help me how to display related contactlist with accountid in new window...
DisplayAccountsWithContacts.cmp:
  1. <aura:component controller="accountsWithContactsClass" implements="flexipage:availableForAllPageTypes" access="global">
  2.    <aura:handler name="init" value="{!this}" action="{!c.myAction}"/>
  3.    <aura:attribute name="accounts" type="account[]"/>
  4.    <table>
  5.         <tr>
  6.             <td> Name </td>
  7.             <td> Industry </td>
  8.             <td> Phone</td>
  9.             <td> CreatedDate</td>
  10.             <td> ContactList Button</td>
  11.          </tr> <b/>
  12.          <aura:iteration items="{!v.accounts}" var="accs1" >
  13.                <tr>
  14.                 <td> {!accs1.Name} </td>
  15.                 <td> {!accs1.Industry} </td>
  16.                 <td> {!accs1.Phone} </td>
  17.                 <td> {!accs1.CreatedDate}</td>
  18.                 <td> <lightning:button variant="neutral" label="ContactList" onclick="{! c.handleClick }" /> 
  19.                    </td>
  20.                </tr><b/>
  21.          </aura:iteration>
  22.     </table>
  23.     <aura:attribute name="isOpen" type="boolean" default="false"/>
  24.          <div class="slds-m-around--xx-large">
  25.                 <aura:if isTrue="{!v.isOpen}">
  26.                  <div role="dialog" tabindex="-1" aria-labelledby="header99" class="slds-modal slds-fade-in-open ">
  27.                     <div class="slds-modal__container">
  28.                   <!-- ###### MODAL BOX HEADER Part Start From Here ######-->
  29.                       <div class="slds-modal__header">
  30.                     <button class="slds-button slds-modal__close slds-button--icon-inverse" title="Close" onclick="{!c.closeModel}">
  31.                     <span class="slds-assistive-text">Close</span>
  32.                     </button>
  33.                     <h2 id="header99" class="slds-text-heading--medium">ContactList</h2>
  34.                   <!--###### MODAL BOX FOOTER Part Start From Here ######-->
  35.                       <div class="slds-modal__footer">
  36.                         <button class="slds-button slds-button--neutral" onclick="{!c.closeModel}" >Cancel</button>
  37.                         <button class="slds-button slds-button--brand" onclick="{!c.likenClose}">Like and Close</button>
  38.                       </div>
  39.                       </div>
  40.                             
  41.                     </div>
  42.                    </div>
  43.                 </aura:if>
  44.          </div>
  45. </aura:component>
DisplayAccountsWithContactsController.js:
  1. ({    
  2.     myAction : function(component, event, helper) {
  3.         var action =component.get("c.getAllAccounts");
  4.         console.log('The action value is: '+action);
  5.          action.setCallback(this, function(a){              
  6.             component.set("v.accounts", a.getReturnValue());
  7.            //  console.log('The accs are :'+JSON.stringify(a.getReturnValue()));
  8.             console.log('The accs are :'+JSON.stringify(a.getReturnValue()));          
  9.         });
  10.         $A.enqueueAction(action);
  11.     },
  12.     handleClick : function(component, event, helper) { 
  13.         component.set("v.isOpen", true);   // for Hide/Close Model,set the "isOpen" attribute to "Fasle" 
  14.     }  , 
  15.       closeModel: function(component, event, helper) {
  16.          component.set("v.isOpen", false); // for Hide/Close Model,set the "isOpen" attribute to "Fasle"        
  17.    },
  18.    likenClose: function(component, event, helper) {
  19.         alert('thanks for like Us :)');// Display alert message on the click on the "Like and Close" button from Model Footer 
  20.                                        // and set set the "isOpen" attribute to "False for close the model Box.
  21.         component.set("v.isOpen", false);
  22.    },
  23. })
accountswithContactsClass.apxc:
public class accountsWithContactsClass {
    @auraEnabled
public static list<account> getAllAccounts()
    {
     list<account> accs =[select id,name,phone,industry,CreatedDate from account limit 10];
     return accs;
    }
}
===================================================================================================
User-added image