• vishal-negandhi
  • SMARTIE
  • 645 Points
  • Member since 2017
  • Salesforce Application Architect
  • Flixbus


  • Chatter
    Feed
  • 21
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 1
    Questions
  • 121
    Replies
I have created the Multiselect picklist component and got above error while loading component. Any help would be appreciated!.
Please see below code:

Client Side Controller file :

({
    doInit:function(component,event,helper){
       
        helper.getOpetionsHelper(component);       
    },
    openDropdown:function(component,event,helper){
        $A.util.addClass(component.find('dropdown'),'slds-is-open');
        $A.util.removeClass(component.find('dropdown'),'slds-is-close');
    },
    closeDropDown:function(component,event,helper){
        $A.util.addClass(component.find('dropdown'),'slds-is-close');
        $A.util.removeClass(component.find('dropdown'),'slds-is-open');
    },
    selectOption:function(component,event,helper){        
        var label = event.currentTarget.id.split("#BP#")[0];
        var isCheck = event.currentTarget.id.split("#BP#")[1];
        helper.getOpetionsHelper(component,label,isCheck);
    }
})

Helper File : 

({
    getOpetionsHelper: function(component)
{
          var action = component.get("c.getOptions");
        
    action.setCallback(this, function(response) {
        var state  = response.getState();
        var optionResult = response.getReturnValue();
        console.log('response '+JSON.stringify(optionResult));
         var opt = new Array();
        for(var i=0;i<=optionResult.length;i++){  

            opt.push({isChecked:optionResult[i].isChecked,label:optionResult[i].label});
        }
        component.set("v.options",opt);
    });
    
    Server Side Controller : 
    
    public class MultiSelectPicklistCls {
    
    @AuraEnabled
    public static List<PickListOptions> getOptions()
    {
        List<PickListOptions> optList = new List<PickListOptions>();
        
    optList.add(new PickListOptions('Option 1',false));
    optList.add(new PickListOptions('Option 2',true));
    optList.add(new PickListOptions('Option 3',false));
    return optList;
    }

    // wrapper class 
    public class PickListOptions
    {
        @AuraEnabled 
        public String label {get;set;}
        @AuraEnabled 
        public boolean isChecked {get;set;}
        public PickListOptions(String label,boolean isChecked){
            this.label = label;
            this.isChecked = isChecked;
        }
    }
}
This whole works fine in sandbox but I couldn't figure out where to test to clear the test coverage. Thanks for your help!

ApexClass
public with sharing class AccountSearchController {
    @AuraEnabled
    public static List<Account> searchAccounts( String searchTerm, String searchOption, Integer searchLimit, Integer searchRadius ) {            
        List<Account> accounts = new List<Account>(); 
        if ( String.isNotBlank( searchTerm ) ) {
        	List<List<SObject>> results = [FIND :searchTerm IN ALL FIELDS
                    RETURNING Account(
                      Id, BillingLatitude, BillingLongitude
                      WHERE BillingLatitude != Null AND BillingLongitude !=null
                      LIMIT 1)
            ];
            Account [] tempAccts = (Account[])results[0];
            Account centerAcct = tempAccts.get(0);
            
            List<List<SObject>> searchResults = [FIND :searchTerm IN ALL FIELDS
                RETURNING Account(
                    Id,Name,BillingAddress,Recent_Closed_Won_Date__c,Last_Sales_Activity__c,Last_Sales_Activity_By__c,Related_Opportunities_y__c,Owner_Alias__c,Client_Type_new__c,Industry,BillingState,BillingCity,BillingStreet,BillingPostalCode,BillingLatitude,BillingLongitude
                	WHERE DISTANCE (BillingAddress, Geolocation(:centerAcct.BillingLatitude, :centerAcct.BillingLongitude),'km')<:searchRadius
                    ORDER BY Related_Opportunities_y__c DESC
                    LIMIT :searchLimit
                )
            ];
            accounts = searchResults[0];
       
        }  else {
                List<List<SObject>> searchResults = [
                FIND '東京都' IN ALL FIELDS
                RETURNING Account(
                    Id,Name,BillingAddress,Recent_Closed_Won_Date__c,Last_Sales_Activity__c,Last_Sales_Activity_By__c,Related_Opportunities_y__c,Owner_Alias__c,Client_Type_new__c,Industry,BillingState,BillingCity,BillingStreet,BillingPostalCode,BillingLatitude,BillingLongitude
                    ORDER BY Related_Opportunities_y__c DESC
                    LIMIT :searchLimit
                )
            ];
            accounts = searchResults[0];
        }        
    	return accounts;
    }
    @AuraEnabled   
    public static List<Lead> searchLeads(  String searchTerm, String searchOption, Integer searchLimit, Integer searchRadius ) {            
        List<Lead> leads = new List<Lead>();   
        if ( String.isNotBlank( searchTerm ) ) {
	       	List<List<SObject>> results = [FIND :searchTerm IN ALL FIELDS
                           RETURNING Lead(
                           Id, Latitude, Longitude
                           WHERE Latitude != Null AND Longitude !=null
                           LIMIT 1)
                           ];
            Lead [] tempLeads = (Lead[])results[0];
            Lead centerLead = tempLeads.get(0);
            
            List<List<SObject>> searchResults = [
                FIND :searchTerm IN ALL FIELDS
                RETURNING Lead(
                    Id,LastName,Address,Company,State,City,Street,PostalCode,Latitude,Longitude,Owner__c, Client_Type_new__c
                    WHERE Latitude !=null AND Longitude !=null AND DISTANCE (Address, Geolocation(:centerLead.Latitude, :centerLead.Longitude),'km')<:searchRadius
                    ORDER BY Company DESC
                    LIMIT :searchLimit
                )
            ];
            leads = searchResults[0];
        }
    	return leads;
    }
}

Test Class
@isTest
public with sharing class AccountSearchControllerTest {

    @isTest
    public static void testAccountSearchController() {
        Account acct = new Account(Name ='Test');
        acct.BillingPostalCode = '105-0011';
        acct.BillingCountry = 'JP';
        acct.BillingState = 'Tokyo';
        acct.BillingCity = 'Minato';
        acct.BillingStreet = 'Shibakoen 3-1-1';
        acct.BillingLatitude = 35.661;
        acct.BillingLongitude = 139.748;
        insert acct;
                
        Lead lead = new Lead (LastName ='Test');
        lead.PostalCode = '105-0011';
        lead.Country = 'JP';
        lead.State = 'Tokyo';
        lead.City = 'Minato';
        lead.Street = 'Shibakoen 3-1-1';
        lead.Latitude = 35.661;
        lead.Longitude = 139.748; 
        insert lead;
        
        Test.startTest();
            List<Account> searchAccounts = AccountSearchController.searchAccounts(acct.BillingState,'option1',25,6);
            System.assertEquals(true,searchAccounts.isEmpty());
      
            List<Lead> searchLeads = AccountSearchController.searchLeads(lead.State,'option2',25,6);
            System.assertEquals(true,searchLeads.isEmpty());
        Test.stopTest();

    }
}

I attached the debug result with highlighting the lines are not test.
Thank you!
  • January 25, 2021
  • Like
  • 0
Hello,

I have this method that works fine: 
Public class AutoConvertLeads
{
    @InvocableMethod
    public static void LeadAssign(List<Lead> Leads)
    {
        LeadStatus CLeadStatus= [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true Limit 1];
        System.debug('Lead Converted Status' + CLeadStatus.MasterLabel);
        List<Database.LeadConvert> MassLeadconvert = new List<Database.LeadConvert>();
        for(Lead currentlead: Leads){
                Database.LeadConvert Leadconvert = new Database.LeadConvert();
                Leadconvert.setLeadId(currentlead.Id);                
                Leadconvert.setConvertedStatus(CLeadStatus.MasterLabel);
                if (currentlead.Account__c != null) {
                    System.debug('Lead Account' + currentlead.Account__c);
                    Leadconvert.setAccountId(currentlead.Account__c);
                }
            	MassLeadconvert.add(Leadconvert);
        }
        System.debug('List Convert' + MassLeadconvert);
        if (!MassLeadconvert.isEmpty()) {
            List<Database.LeadConvertResult> lcr = Database.convertLead(MassLeadconvert);
        	System.debug('Result' + lcr);
        }
    }
}

But I want to add a return value.
The value would be the variabe "lcr" which is List<Database.LeadConvertResult>. It could also be a list of strings or opportunity.

When I'm trying this :
Public class AutoConvertLeads
{
    @InvocableMethod
    public static List<Database.LeadConvertResult> LeadAssign(List<Lead> Leads)
    {
        LeadStatus CLeadStatus= [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true Limit 1];
        System.debug('Lead Converted Status' + CLeadStatus.MasterLabel);
        List<Database.LeadConvert> MassLeadconvert = new List<Database.LeadConvert>();
        for(Lead currentlead: Leads){
                Database.LeadConvert Leadconvert = new Database.LeadConvert();
                Leadconvert.setLeadId(currentlead.Id);                
                Leadconvert.setConvertedStatus(CLeadStatus.MasterLabel);
                if (currentlead.Account__c != null) {
                    System.debug('Lead Account' + currentlead.Account__c);
                    Leadconvert.setAccountId(currentlead.Account__c);
                }
            	MassLeadconvert.add(Leadconvert);
        }
        System.debug('List Convert' + MassLeadconvert);
        if (!MassLeadconvert.isEmpty()) {
            List<Database.LeadConvertResult> lcr = Database.convertLead(MassLeadconvert);
        	System.debug('Result' + lcr);
            return lcr;
        }
    }
}

I'm having the following error : InvocableMethod methods do not support return type of List<Database.LeadConvertResult>
I have tested  all kind of value like string etc but none of those are accepted.

Do you have any idea ?

Thanks,
Matthias

I'm trying to call this class which uses @Future with a trigger. I'm unsure how to reference the class in the trigger. Also, since I am attempting to trigger the code with a field change it is difficult because I can't have the callout execute after an update. So, I'm not sure what trigger context should be used as well. 

 

Here is my trigger : 

trigger Trigger_ProgramContactRole on Program_Contact_Role__c (after insert, after update, before insert, before update ,after delete) {
    //Checking for the event type
    if(Trigger.isAfter){
        
        
        if(Trigger.isInsert){
                     
                        
        }
        
        
        if(Trigger.isUpdate){
                     
            
            
        }


But I don't know how to start this class with it : 

public class UpdateContactPCRController {

    @InvocableMethod
    public static String  updateContact(String recordId){        
       
        String contactId = '';       
        
        List<Contact> contactToBeupdate = new List<Contact>();        
        
        if(String.isNotBlank(recordId)){            
            
            List<Program_Contact_Role__c> programContacList = [SELECT Id,Contact__c,Program_Name__c FROM Program_Contact_Role__c WHERE Id =:recordId AND Contact__c != null];
            contactId = programContacList[0].Contact__c;
            
            if(String.isNotBlank(contactId)){
                
                contactToBeupdate = [Select Id,Pardot_Action_Trigger__c,PCR_Register_Button_Link__c,PCR_URL_for_UI__c FROM Contact Where Id =: contactId Limit 1];                
                
                contactToBeupdate[0].Program_Contact_Role_Id__c = recordId;
            }
                        List<Program_Communication_Recipients__c> programCommunicationRecs = [Select Id,Name,
                                  Program_Communication__r.Program__r.Buyer__r.Name,Receipient__c,                
                                              From Program_Communication_Recipients__c Where 
                                                           Program_Communication__r.Program__c =: programContacList[0].Program_Name__c AND 
                                                           Receipient__c =: programContacList[0].Id];                                           
                                
                
                    contactToBeupdate[0].PCR_Welcome_Message__c = String.valueOf(programCommunicationRecs[0].Program_Communication__r.Welcome_Message__c);                                                    

 pardotCallout(contactToBeupdate[0].Id);
    {

        @future(callout=true) 
        public static void pardotCallout(String contactId) {
            String returnedResponseFromPardot = Http_Utility_Pardot.pardotCreateProspect(new Set<Id> {contactId});
            // new treatment here with the returned value included DML operations.
    }

        if(contactToBeupdate.size() > 0){
            update contactToBeupdate;  
        }
        
        return 'Updated Successfully';
    }
}

Any help you can give would be very appreciate. Thank you.
I want to do a "left join" of CONTACT table to TargetX_SRMb__Application__c, but I want to filter the Application table by "Class_Year = '2021'

and can't seem to get that.

I can do a successful query like this but ALL rows are returned, so it's ignoring the WHERE clause in my inline (SELECT ...)
select 

ais_candidate_number__c,
AIS_Record_Type_Name__c, 
TargetX_SRMb__Status__c,

FirstName, LastName, birthdate,
TargetX_SRMb__Gender__c,

(select 
TargetX_SRMb__Application_Decision__c,
TargetX_SRMb__Start_Term_Year__c,
AIS_Feeder_Source__c
from TargetX_SRMb__Application__r
where TargetX_SRMb__Start_Term_Year__c = '2021')

from Contact
where AIS_Record_Type_Name__c = 'Recruitment_Manager_Student'
  and TargetX_SRMb__Application__r.TargetX_SRMb__Start_Term_Year__c = '2020'
But if I flip the query I can't get it to work ... CONTACT__r doesn't work ... 
select 
name,
recordtypeid,
targetx_srmb__contact__c,
targetx_srmb__application_decision__c,
targetx_srmb__start_term_year__c,
(select 
AIS_PRMI_Id__c, 
ais_candidate_number__c,
AIS_Record_Type_Name__c, 
TargetX_SRMb__Status__c,
FirstName, LastName, birthdate,
TargetX_SRMb__Gender__c, 
usna_international__c
from Contact__r
)
from TargetX_SRMb__Application__c
where targetx_srmb__start_term_year__c = '2021'
Just learning SOQL so it's a challenge.

I'm trying to do this, logically:
(
select [this and that],
   (select [other stuff] from Table_B)
from Table_A
)
where Table_B_field = '2021'

I can do this in Oracle with a snap, but how to do so in Salesforce / SOQL / Workbench.
 
*** No idea what Topic to put this under ...

​​​​​​​

 
I know nothing about triggers but I've determined that the only way to leverage Match Rules for Birthdate is to create a Before Insert trigger that replicates the Birthdate value as a text value into a custom text field. This would in turn allow me to use this field as a filter.

Can anyone help me out with the APEX trigger?
I'm having trouble displaying a picklist value in a ligthning component. See below for methods used. What am I missing?

I have added a new picklist field the query in a controller, and I'm using these methods to return the picklist values used in the Lighting Component:
//Grabs options for all picklists on the page.   @AuraEnabled   public static List<returnFieldOptions> getPicklistOptions(string picklistFieldsJson){     System.debug('Picklist Fields Json: '+picklistFieldsJson);          //Create new list of return options for returning picklists to the page (returnFieldOptions class defined at bottom of this page).     List<returnFieldOptions> allFieldOptions = new List<returnFieldOptions>();     //Turn the JSON received from the page into a list of a custom class (defined at bottom of the page).     List<fieldLookups>picklistFields = (List<fieldLookups>)System.JSON.deserializeStrict(picklistFieldsJson,List<fieldLookups>.Class);     //For each item received, find all the fields and put them into the allFieldOptions list.     for(fieldLookups fieldInfo : picklistFields){       System.debug(fieldInfo);       //Create object for returning picklist fields and instantiate the list where we will be storing the values.       returnFieldOptions targetFieldOptions = new returnFieldOptions();       targetFieldOptions.picklistOptions = new List<String>();       //Add in the attribute name where this will be stored when it goes back to the page. Add "--None--" as the first option.       targetFieldOptions.attributeName = fieldInfo.attributeName;       targetFieldOptions.picklistOptions.add('--None--');       //Retrieve object metadata.       Schema.sObjectType targetObjectType = Schema.getGlobalDescribe().get(fieldInfo.objectName);       Schema.DescribeSObjectResult targetObjectDescribe = targetObjectType.getDescribe();       Map<String, Schema.SObjectField> fieldMap = targetObjectDescribe.fields.getMap();                          system.debug(fieldInfo.fieldName);       //Retrieve picklist options for the specific field.       List<Schema.PicklistEntry> values = fieldMap.get(fieldInfo.fieldName).getDescribe().getPicklistValues();       //Add their name to the return object list as a string.       for(Schema.PicklistEntry a: values){         targetFieldOptions.picklistOptions.add(a.getValue());       }       //Add the return object for this picklist to the overall list that will go back to the page.       allFieldOptions.add(targetFieldOptions);     }     System.debug(allFieldOptions);     return allFieldOptions;   }  }   public class fieldLookups {     Public string attributeName{get;set;}     Public string objectName {get;set;}     Public string fieldName {get;set;}   }   public class returnFieldOptions{     @AuraEnabled     Public string attributeName{get;set;}     @AuraEnabled     Public List<String>picklistOptions{get;set;}   }



Here is the Lighting Component:
<aura:attribute name="RequestChangeOptions" access="private" type="String[]"/> <div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1"> <lightning:select name="RequestChangeSelect" label="Request Change to Classroom?" value="{!v.SelectedClassroom.Provider_Request_Classroom_Changes__c}" required="true"> <aura:iteration items="{!v.RequestChangeOptions}" var="RequestClassroomChange"> <option text="{!RequestClassroomChange}"></option> </aura:iteration> </lightning:select>

 
Hi and thanks in advance...

I found this class online without Test class.  The class works great and I found a Test class for it, but it doesn't work.  

I've included the Class and the Test Class and associated errors for test class

Class:
global class UnlockRecordBatchJob implements Database.batchable<sObject> {
    //Start of this batch job
    global Database.QueryLocator start(Database.BatchableContext BC) {
        String query = 'SELECT Id FROM Case LIMIT 50000000 '; //50 Million records
        return Database.getQueryLocator(query);
    }
    //Exeution of batch job
    global void execute(Database.BatchableContext BC, List<Case> scope) { //Scope max = 2000
        //List<Case> caseList = [SELECT Id From CaseLimit 2]; case already in scope varible
        //Check locked records
        List<Case> caseLockList = new List<Case>();
        for(Case c : scope)
        {
            if(Approval.isLocked(c.id)){
                caseLockList.add(c);
            }
        }
        
        if(!caseLockList.isEmpty()){
            //Unlock records
            List<Approval.UnlockResult> ulrList = Approval.unlock(caseLockList, false);
            
            // Iterate through each returned result
            for(Approval.UnlockResult  ulr : ulrList) {
                if (ulr.isSuccess()) {
                    //Operation was successful, so get the ID of the record that was processed
                    System.debug('Successfully locked account with ID: ' + ulr.getId());
                }
                else {
                    //Operation failed, so get all errors                
                    for(Database.Error err : ulr.getErrors()) {
                        System.debug('The following error has occurred.');                    
                        System.debug(err.getStatusCode() + ': ' + err.getMessage());
                        System.debug('Case fields that affected this error: ' + err.getFields());
                    }
                }
            }
        }
    }
    //finish job
    global void finish(Database.BatchableContext BC) {
    }
}
test Class:
@isTest
public class TestDemoTest {
    @isTest
    private static void testDemo(){
        List<Case> lcase=new List<Case>();
        for(integer i=0;i<10;i++){
            Case c=new Case();
            c.Status='New';
            c.Origin='Email';
            lcase.add(c);
            
        }
        insert lcase;
        List<Approval.LockResult> lrList = Approval.lock(lcase, false);
        Test.startTest();
        TestDemo td=new TestDemo();
        Database.executeBatch(td);
        Test.stopTest();
        
    }
}

The errors I get are:
Invalid type: TestDemo

Method does not exist or incorrect signature: void executeBatch(TestDemo) from the type Database



 
Any reason why my code is not displaying the colour?

I want the colour to appear red when it is an appointment and yellow if it is a diary booking:
Table

Here is my code:

Code
I have the following:
for(SVMXC__SVMX_Event__c svmxEv : Trigger.New)
    {
       
        System.debug('#############' + svmxEv.SVMXC__Technician__r.SVMXC__Service_Group__r.Name);
    }

User-added image


I tried to make a formula field with this: SVMXC__Technician__r.SVMXC__Service_Group__r.Name and it's working... I don't know why in my trigger it's not working...
P.S. my trigger is after update, after insert, before update

Hello everyone,

Through searching various past threads it looks like this questions has been asked a few times, however I am hoping to get some specific help.

I've just last week started dedicating myself to learning to develop (SF99!)  So I understand this is beyond my range, but this is a need at my current Org, and I thought it would be fun to actually try to do some development.

Note* I understand that a junction object could be an option here.  Given the users that will be using these objects, the fewer clicks the better so I need to stick with this model.

 

We have a Contract Agreement Object that has 5 lookup fields for parties that can be related to the Contract Agreement.  On the Party Object, I have 5 list.  I would like to combine them into one list, and display them on the Party object.  Here is what I have for code so far,  I'm a newbie so I'm sure I am far off, but I'm excited to learn.

public class CombineContractAgreement {
public CombineContractAgreement(ApexPages.StandardController controller) {
    
}

   Public List <Contract_Agreement__C> AllRelatedAgreements;
    
    Public List<Contract_Agreement__c>GetAllRelatedAgreement()
    {
        AllRelatedAgreements = [SELECT id, RecordTypeId, APXT_Redlining_Status__c, APXT_Redlining__Effective_Date__c, Agreement_Name__c FROM Contract_Agreement__c 
                                
                                WHERE //Current record is value on any 1 of 5 lookup fields on the Contract Agreement Record.//
 								return AllRelatedAgreements 
                               }
 

Any help you can provide will be greatly apprchated.




 

I'm on the Display Records, Fields, and Tables module under Visualforce Basics, and I'm unable to complete the challenge

Here is the criteria:
Create a page which displays a subset of Opportunity fields using apex:outputField components. Bind the Name, Amount, Close Date and Account Name fields to the apex:outputField components.
Challenge Requirements
The page must be named OppView
It must reference the Opportunity standard controller
It must have four apex:outputField components bound to the following Opportunity fields:
Opportunity Name
Amount
Close Date
Account Name of the Opportunity

Here is my code from the dev console:
<apex:page standardController="Opportunity">
    <apex:pageBlock title="Opportunities">
        <apex:pageBlockSection>
            <apex:outputField value="{!Opportunity.Name}"/>
            <apex:outputField value="{!Opportunity.Amount}"/>
            <apex:outputField value="{!Opportunity.CloseDate}"/>
            <apex:outputField value="{!Opportunity.AccountId}"/>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>


Here's the error I receive:
The page does not include a apex:outputField component bound to the opportunity amount

Also here's the error I receive from the dev console, it is having trouble running the outputField line for the Opportunity.Amount:
Currency fields on entities with effective dated currency are not supported.

I'm not sure if it's a configuration or dev issue, but any assistance to clear this challenge would be greatly appreciated!
When trying to do some debugging in lightning Salesforce keeps switching to classic view whenever I open the inspector. I'm getting this error in the Inspector console:
DevTools failed to load SourceMap: Could not load content for https://hgv--qa.lightning.force.com/javascript/1515605724000/ui-sfdc-javascript-impl/source/RecordGVP.js.map: 

I am attempting to start this Apex class with Process Builder, triggered by a field change. I've never done this before and I'm unsure what invoke code needs to be added in order to accomplish this. I tried adding @InvocableMethod but I'm getting an error telling me this :

 

Compile Error: Unsupported parameter type String. 
Valid invocable parameters must be List types like List<T> 
where T is a supported type at line 26 column 27

It is a class which is currently being invoked with a Lightning Component button in a record.

public class UpdateContactPCRController {

    @InvocableMethod
    public static String  updateContact(String recordId){        
       
        String contactId = '';       
        
        List<Contact> contactToBeupdate = new List<Contact>();        
        
        if(String.isNotBlank(recordId)){            
            
            List<Program_Contact_Role__c> programContacList = [SELECT Id,Contact__c,Program_Name__c FROM Program_Contact_Role__c WHERE Id =:recordId AND Contact__c != null];
            contactId = programContacList[0].Contact__c;
            
            if(String.isNotBlank(contactId)){
                
                contactToBeupdate = [Select Id,Pardot_Action_Trigger__c,PCR_Register_Button_Link__c,PCR_URL_for_UI__c FROM Contact Where Id =: contactId Limit 1];                
                
                contactToBeupdate[0].Program_Contact_Role_Id__c = recordId;
            }
                        List<Program_Communication_Recipients__c> programCommunicationRecs = [Select Id,Name,
                                  Program_Communication__r.Program__r.Buyer__r.Name,Receipient__c,                
                                              From Program_Communication_Recipients__c Where 
                                                           Program_Communication__r.Program__c =: programContacList[0].Program_Name__c AND 
                                                           Receipient__c =: programContacList[0].Id];                                           
                                
                
                    contactToBeupdate[0].PCR_Welcome_Message__c = String.valueOf(programCommunicationRecs[0].Program_Communication__r.Welcome_Message__c);                                                    

        if(contactToBeupdate.size() > 0){
            update contactToBeupdate;  
        }
        
        return 'Updated Successfully';
    }
}

Thank you very much for any help you can give with this. It is very appreciated.
As a admin, I have created a DML Statement to run in the Developer Console adhoc whenever I need to change account record owners en mass.

Now I need to convert that into an Apex Class and Trigger so that when records are uploaded from an external party the account record owner will be changed automatically based on shippingcity. See DML Code below:
 
List<Account> recList = [select id, shippingcountry, ownerid, name, shippingcity FROM Account WHERE shippingcountry = 'NL' AND sasid__c = null and ownerid='0052o00000AHDCeAAP' AND shippingcity IN ('Nijmegen','Arnhem')];
for (Account rec : recList) {
rec.ownerid = '0052o00000AI4zfAAD';
}
update recList;

3rd Party OwnerID = '0052o00000AHDCeEAP'
New record owner = '0052o00000AI4zfACD'
Hi,

Controller functions:

A:function(component, event, helper){
   helper.getExample(component,event);
},
B:function(component, event, helper){
   helper.getExample(component,event,parameters);
},
C:function (component, event, helper){
   helper.getExample(component,event)
},
D:function (component, event, helper)//which is actually a search function
{
    helper.getExample(component,event,searchString);
},
E:function(component, event, helper){
   helper.getExample(component,event,searchString,numberofrecords);
}

Helper function:

getExample:function(component,parameters,searchString,numberofrecords)
{
},

My doubt is in A (Controller function),we are passing event but in helper function we don't have event parameter in function declaration.
In D (Controller function),searchString is passed to helper as third argument and it is getting assigned correctly to  searchString without getting assigned to parameters.How???

In C (Controller function), event is passed but we don't have event in helper function.

And the code is working fine without any errors?!

How is this even possible?
I guess I'm lacking some concept.Could you help me understand this?!
 
Hello!

I am making contact search page where the Results and Errors pageblocks render based on the value of their corresponding booleans:
  • public boolean ResultsPresent
  • public boolean ErrorsPresent
The problem is when I do this: 

<apex:pageBlock title="Results" rendered="{!ResultsPresent}"> 

or this

<apex:pageBlock title="Errors" id="ErrorSection" rendered="{!ErrorsPresent}">

I keep getting "Unknown Property" errors.

Here are the pageblocks in question:
<!-- Results Display -->
            <apex:pageBlock title="Results" rendered="{!ResultsPresent}"> 
                
                <apex:outputText value="There are currently '' results found." />
                                
                <apex:pageBlockSection >
                
                    <apex:pageBlockTable value="{!contacts}" var="c" id="contact-table">
                            
                            <apex:column >
                                <apex:facet name="header">Name</apex:facet>
                                {!c.Name}
                            </apex:column>
        
                            <apex:column >
                                <apex:facet name="header">Phone Number</apex:facet>
                                {!c.Phone}
                            </apex:column>
                            
                            <apex:column >
                                <apex:facet name="header">Email</apex:facet>
                                {!c.Email}
                            </apex:column>
                            
                        </apex:pageBlockTable>
                    
                </apex:pageBlockSection>
   
            </apex:pageBlock>
              
              
              
          <!-- Error Display -->    
          <apex:pageBlock title="Errors" id="ErrorSection" rendered="{!ErrorsPresent}">
              
                <apex:pageMessages id="ErrorsListing">
                  
                </apex:pageMessages>
              
          </apex:pageBlock>

Here is my Controller
 
public with sharing class Ctrl_ContactSearch
{
    public List<Contact> contacts { get; set; }
    
    public String name { get; set; }
    public String phone { get; set; }
    public String email { get; set; }   
    
    
   	public integer MatchingContacts = 0;
    
    public boolean ResultsPresent = false;
    public boolean ErrorsPresent = false;
    
    public boolean Error_NoResults = false;
    public boolean Error_FieldsEmpty = false;
    public boolean Error_NameSyntax = false;
   	public boolean Error_PhoneSyntax = false;
    public boolean Error_EmailSyntax = false;
    
    
   /* Name Input Validation Regex*/
   public static Boolean ValidationName (String name)
            {
              	Boolean NameIsValid = false;
                
              
                String nameRegex = '[a-zA-Z]*[\\s]{1}[a-zA-Z].*';
                Pattern PatternName = Pattern.compile(nameRegex);
                Matcher nameMatcher = PatternName.matcher(name);
                
                if (nameMatcher.matches())
                    {
                        NameIsValid = true;
                    } 
 
                return NameIsValid;	
			}
    
     
    /* Phone Input Validation Regex*/
    public static Boolean ValidationPhone (String phone)
            {
              	Boolean PhoneIsValid = false;
                
               
                String phoneRegex = '^([0-9\\(\\)\\/\\+ \\-]*)$';
                Pattern PatternPhone = Pattern.compile(phoneRegex);
                Matcher phoneMatcher = PatternPhone.matcher(phone);
                
                if (phoneMatcher.matches())
                    {
                        PhoneIsValid = true;
                    } 
                   
                return PhoneIsValid;		
			}          
    
   
     /* Email Input Validation Regex*/
     public static Boolean ValidationEmail (String email)
            {
              	Boolean EmailIsValid = false;
                
               
                String emailRegex = '^[a-zA-Z0-9._|\\\\%#~`=?&/$^*!}{+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}$';
                Pattern PatternEmail = Pattern.compile(emailRegex);
                Matcher emailMatcher = PatternEmail.matcher(email);
                
                if (emailMatcher.matches())
                    {
                        EmailIsValid = true;
                    } 
                    
                return EmailIsValid;	
			}       
    
    

    
    /* Runs when "Clear Fields" button is pressed*/
    public void ClearFields()
            {
               name = '';
               phone = '';
               email = ''; 
            }
    
    
    /* Runs when "Search Contacts" button is pressed*/
    public PageReference searchContacts()
        {
          			       
            /* Checks if input fields are empty*/
            if (name == '' && phone == '' && email == '')
                {
                    Error_FieldsEmpty = true;   
                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Your fields are blank. Please enter your information in the remaining fields to proceed'));
                }
            
            else 
                {
                    /* Checks Input Validation Results*/                      
                    if (ValidationName(name) == false) 
                         {      
                              Error_NameSyntax = true;
                              ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Inproper name format. Please enter name in following format : Firstname Lastname.'));
                          }
                                                                                 
                    if (ValidationPhone(phone) == false) 
                         {
                              Error_PhoneSyntax = true;
                              ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Inproper phone number format. Please enter number in following format : XXX-XXX-XXXX.'));
                          }
                    
                    if (ValidationEmail(email) == false) 
                         {	 
                              Error_EmailSyntax = true;
                              ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Inproper email format. Please enter email in following format : XXX@emailprovider.com'));
                          }
                        
                    /* Runs if all Validation results are 'true'*/ 
                    if (ValidationName(name) == true && ValidationPhone(phone) == true && ValidationEmail(email) == true)
                        {
                              ResultsPresent = true;
                              contacts = [select Name, Phone, Email from Contact where Name = :name or Phone = :phone or email = :email];
                              MatchingContacts = contacts.size();
                            
                              /* Checks if/how many matches were found from the search*/ 
                              if(MatchingContacts != 0)
                                  {  
                                     return null;
                                  }
                              
                              else
                                  {    
                                      Error_NoResults = true;
                                      ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'No matching Contacts were found.'));   
                                  }
                        }
                    
                   
                }
                    

              
         	 /* Displays "Error" field if any errors are found*/
            if (Error_NoResults == true || Error_FieldsEmpty == true || Error_NameSyntax == true || Error_PhoneSyntax == true || Error_EmailSyntax == true)
                {
                    ErrorsPresent = true;
                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'There are errors present. Please read and follow instructions accordingly.'));                     
                }     
            
            
           return null;     
      }           
}

In a similar vein, I'm trying to also make an outputtext box that displays the number of results based  the value of MatchingContacts  but when I do that, I ALSO get an unknown property error. 

What am I missing here?
On user object - I want to display warning message via VF page, but here the problem is there is no option for Inline VF page on User Layout. is there any workaround?
OR
Apart from VF page is there any other options to display warning?
User object there is no option for Inline VF page
Hi, I'm trying to add a registration form widget that uses javascript to one of our community pages using the HTML editor component. However, I get an error saying the markup inlcudes unsupported tags or attritbutes. Upon further investigation for supported HTML tags and attributes (https://help.salesforce.com/articleView?id=ideas_html_def.htm&type=5) I found the <script> in not supported. 

Is there another way to accomplish embedding this widget on a community page? 

code line with script is flagged with red X

Review your content. The markup includes unsupported tags or attributes. Remove them and try again.

Hello Experts, 

I've been stuck in a problem and need some inputs.
We have a contact form and on submit of it, we are creating a Case record in the backend.

The problem is, the logic is pretty complex and the form submission at times takes more than 10 seconds. We have optimized our code as much as we could, but we have a lot of background processes on Cases such as PB's, WF's, before and after triggers, etc and all of that combined is making the response too slow.

What we have on the aura component
 

submitCase: function(component, fileNames, fileTypes, files, t0){
    llet action = component.get('c.submit');
    action.setParams({
       // set some params
    });
    
    action.setCallback(this,function(response){
        let status = response.getState();
     
        if(status === 'SUCCESS'){
            // some console statements
        }
        else if(status === 'ERROR'){
           // some console statements
        }
    }); 
    
    $A.enqueueAction(action); 
    var cmpEvent = component.getEvent("someEventt");
    cmpEvent.fire({
        // show success message as soon as users submit
    });
},


And our apex method looks like this
 
@AuraEnabled 
public static String submit(Case caseRecord, List<String> fileNames, List<String> base64Data, List<String> contentType){
            // create case with assignment rule attached as dmlOptions
            // create ContentVersion records
            // create ContentDocumentLink records to attach the files to cases
            return caseRecord.Id;
        }
        catch(Exception ex){
            // "Convert" the exception into an AuraHandledException
            throw handleException(ex.getMessage());
        }
    }
    return '';
}

This is a web form and the returning Case ID is of no use to our guest users.
Also, they see a success message almost immediately when they submit their data, as you can see in the aura component code.

Now, where I need your help is to understand what's the best way for us to handle this situation - we don't need to wait for the response from Apex.

- Is it okay to remove the "action.setCallback()" since we simply do not need to see what comes back from salesforce?

- Move everything in the apex to a future method and immediately send back a response to aura component. I personally don't think this makes much sense because I'm sending a dummy response anyway.

Am I overlooking anything if I go with #1 or are there any better ways of handling this that I am missing.

Thanks in advance.
How can we choose a Queue as an approver on the Account object? When I know that Queue can't be created on Account. Is there any way?
trigger updatecontact on Account (after insert, after update) {
list<Contact> conlist=new list<Contact>([select Id,Name,AccountId,Industry__c from Contact where AccountId IN:Trigger.new ]);
    map<Id,Account>mapAccountIdAccount=new map<Id,Account>([select Id,Industry,AccountSubType1__c,AccountType1__c,businessunit__c,ProductInterest__c,
                                                            TranslocRelationship__c from Account where Id IN:Trigger.new]);
  list<Contact>contactstobeupdate=new list<Contact>();
    if(Trigger.isInsert || Trigger.isUpdate && Trigger.isAfter) {
        
        for(contact obj:conlist){
            
            Account objAccount=mapAccountIdAccount.get(obj.AccountId);
            obj.TranslocRelationship__c =objAccount.TranslocRelationship__c;
            obj.ProductInterest__c=objAccount.ProductInterest__c;
            //obj.Industry__c=objAccount.Industry;
            obj.AccountType__c=objAccount.AccountType1__c;
            obj.AccountSubType__c=objAccount.AccountSubType1__c;
            contactstobeupdate.add(obj);
        }
        update contactstobeupdate;
    }
  }
There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: JQXGIEDU

I was about to get a badge for my reports module. And this error popped up
I have created the Multiselect picklist component and got above error while loading component. Any help would be appreciated!.
Please see below code:

Client Side Controller file :

({
    doInit:function(component,event,helper){
       
        helper.getOpetionsHelper(component);       
    },
    openDropdown:function(component,event,helper){
        $A.util.addClass(component.find('dropdown'),'slds-is-open');
        $A.util.removeClass(component.find('dropdown'),'slds-is-close');
    },
    closeDropDown:function(component,event,helper){
        $A.util.addClass(component.find('dropdown'),'slds-is-close');
        $A.util.removeClass(component.find('dropdown'),'slds-is-open');
    },
    selectOption:function(component,event,helper){        
        var label = event.currentTarget.id.split("#BP#")[0];
        var isCheck = event.currentTarget.id.split("#BP#")[1];
        helper.getOpetionsHelper(component,label,isCheck);
    }
})

Helper File : 

({
    getOpetionsHelper: function(component)
{
          var action = component.get("c.getOptions");
        
    action.setCallback(this, function(response) {
        var state  = response.getState();
        var optionResult = response.getReturnValue();
        console.log('response '+JSON.stringify(optionResult));
         var opt = new Array();
        for(var i=0;i<=optionResult.length;i++){  

            opt.push({isChecked:optionResult[i].isChecked,label:optionResult[i].label});
        }
        component.set("v.options",opt);
    });
    
    Server Side Controller : 
    
    public class MultiSelectPicklistCls {
    
    @AuraEnabled
    public static List<PickListOptions> getOptions()
    {
        List<PickListOptions> optList = new List<PickListOptions>();
        
    optList.add(new PickListOptions('Option 1',false));
    optList.add(new PickListOptions('Option 2',true));
    optList.add(new PickListOptions('Option 3',false));
    return optList;
    }

    // wrapper class 
    public class PickListOptions
    {
        @AuraEnabled 
        public String label {get;set;}
        @AuraEnabled 
        public boolean isChecked {get;set;}
        public PickListOptions(String label,boolean isChecked){
            this.label = label;
            this.isChecked = isChecked;
        }
    }
}
This whole works fine in sandbox but I couldn't figure out where to test to clear the test coverage. Thanks for your help!

ApexClass
public with sharing class AccountSearchController {
    @AuraEnabled
    public static List<Account> searchAccounts( String searchTerm, String searchOption, Integer searchLimit, Integer searchRadius ) {            
        List<Account> accounts = new List<Account>(); 
        if ( String.isNotBlank( searchTerm ) ) {
        	List<List<SObject>> results = [FIND :searchTerm IN ALL FIELDS
                    RETURNING Account(
                      Id, BillingLatitude, BillingLongitude
                      WHERE BillingLatitude != Null AND BillingLongitude !=null
                      LIMIT 1)
            ];
            Account [] tempAccts = (Account[])results[0];
            Account centerAcct = tempAccts.get(0);
            
            List<List<SObject>> searchResults = [FIND :searchTerm IN ALL FIELDS
                RETURNING Account(
                    Id,Name,BillingAddress,Recent_Closed_Won_Date__c,Last_Sales_Activity__c,Last_Sales_Activity_By__c,Related_Opportunities_y__c,Owner_Alias__c,Client_Type_new__c,Industry,BillingState,BillingCity,BillingStreet,BillingPostalCode,BillingLatitude,BillingLongitude
                	WHERE DISTANCE (BillingAddress, Geolocation(:centerAcct.BillingLatitude, :centerAcct.BillingLongitude),'km')<:searchRadius
                    ORDER BY Related_Opportunities_y__c DESC
                    LIMIT :searchLimit
                )
            ];
            accounts = searchResults[0];
       
        }  else {
                List<List<SObject>> searchResults = [
                FIND '東京都' IN ALL FIELDS
                RETURNING Account(
                    Id,Name,BillingAddress,Recent_Closed_Won_Date__c,Last_Sales_Activity__c,Last_Sales_Activity_By__c,Related_Opportunities_y__c,Owner_Alias__c,Client_Type_new__c,Industry,BillingState,BillingCity,BillingStreet,BillingPostalCode,BillingLatitude,BillingLongitude
                    ORDER BY Related_Opportunities_y__c DESC
                    LIMIT :searchLimit
                )
            ];
            accounts = searchResults[0];
        }        
    	return accounts;
    }
    @AuraEnabled   
    public static List<Lead> searchLeads(  String searchTerm, String searchOption, Integer searchLimit, Integer searchRadius ) {            
        List<Lead> leads = new List<Lead>();   
        if ( String.isNotBlank( searchTerm ) ) {
	       	List<List<SObject>> results = [FIND :searchTerm IN ALL FIELDS
                           RETURNING Lead(
                           Id, Latitude, Longitude
                           WHERE Latitude != Null AND Longitude !=null
                           LIMIT 1)
                           ];
            Lead [] tempLeads = (Lead[])results[0];
            Lead centerLead = tempLeads.get(0);
            
            List<List<SObject>> searchResults = [
                FIND :searchTerm IN ALL FIELDS
                RETURNING Lead(
                    Id,LastName,Address,Company,State,City,Street,PostalCode,Latitude,Longitude,Owner__c, Client_Type_new__c
                    WHERE Latitude !=null AND Longitude !=null AND DISTANCE (Address, Geolocation(:centerLead.Latitude, :centerLead.Longitude),'km')<:searchRadius
                    ORDER BY Company DESC
                    LIMIT :searchLimit
                )
            ];
            leads = searchResults[0];
        }
    	return leads;
    }
}

Test Class
@isTest
public with sharing class AccountSearchControllerTest {

    @isTest
    public static void testAccountSearchController() {
        Account acct = new Account(Name ='Test');
        acct.BillingPostalCode = '105-0011';
        acct.BillingCountry = 'JP';
        acct.BillingState = 'Tokyo';
        acct.BillingCity = 'Minato';
        acct.BillingStreet = 'Shibakoen 3-1-1';
        acct.BillingLatitude = 35.661;
        acct.BillingLongitude = 139.748;
        insert acct;
                
        Lead lead = new Lead (LastName ='Test');
        lead.PostalCode = '105-0011';
        lead.Country = 'JP';
        lead.State = 'Tokyo';
        lead.City = 'Minato';
        lead.Street = 'Shibakoen 3-1-1';
        lead.Latitude = 35.661;
        lead.Longitude = 139.748; 
        insert lead;
        
        Test.startTest();
            List<Account> searchAccounts = AccountSearchController.searchAccounts(acct.BillingState,'option1',25,6);
            System.assertEquals(true,searchAccounts.isEmpty());
      
            List<Lead> searchLeads = AccountSearchController.searchLeads(lead.State,'option2',25,6);
            System.assertEquals(true,searchLeads.isEmpty());
        Test.stopTest();

    }
}

I attached the debug result with highlighting the lines are not test.
Thank you!
  • January 25, 2021
  • Like
  • 0
Hello everyone,

I want to be an expert on flows and process builder. Can anyone recommend me online tutorials that can help me to reach there?
I have studied Trailhead already. 

Appreciate your response,
SW

Hello, 

I made changes to a query in an apex class. From:

where A=x and B=true; To: where (A=x OR C=y) AND B=true

I thought this was simple enought to not warrant writing new apex test code, I had made the same change in a total of 5 instances in the apex class. And I was right, it showed 82% code coverage in the full sandbox after making these edits.

However, when I sent this change set containing only the single apex class to production, I'm getting a code coverage of 21% there. I text compared the test class in prod and the full sandbox, they are an exact match. 

I wonder what the problem is and why I'm getting this discrepency in code coverage. Any help would be much appreciated. 

Thanks in advance! 

Hello everyone, I'm new to Salesforce and I'm doing some exercices where I have to restrict the visibility or access to a group of users where they can only see the clients and contacts of the same region in the object Leads.

 

I imagine I have to create a group of profiles right? Then apply some sharing rules but I get completly lost. Can anyone explain me what would be the path to achieve it?

I need to create a field for a salesforce object that holds multiple date/time stamps. Each time an event happens, a date/time stamp will be added to the field. So this field is effectively a list of objects. I am unclear on how to do this. Any suggestions on workflow and specifically what data type this field would be are appreciated.
Hi, 

I'm trying to upgrade a lookup to Lead from a custom object to Master-detail, but the option is not there.
  • This is a custom object
  • There are records already
  • Every record has Lead populated
Thanks 

JUser-added imageUser-added image
How do I troubleshoot a button is not working? I have created a flow that is supposed to send an email alert to a member of the opportunity team when the opportunity owner presses the button. The email alert decision based on the opp owner's region (from the user record). The opportunity team member is not recieving the email. How do I troubleshoot this? 
The current code coverage is 25% 

BATCH CLASS

global class SendMembershipRenewalEmail30Days implements Database.Batchable<SObject>, schedulable {
    
    public Database.QueryLocator start(Database.BatchableContext bc){
        
        Date oneMonthFromToday  = Date.today().addDays(30); // Date 30 days from today
        return Database.getQueryLocator([select id, name, Organisation__r.npe01__one2onecontact__r.Email,regular_payment__c  FROM Membership__c WHERE Expiry_Date__c =: oneMonthFromToday and (regular_payment__r.npsp4hub__Payment_Method__c = 'cash' or regular_payment__r.npsp4hub__Payment_Method__c = 'Direct Debit' )]);
    }
    
    public void execute(Database.BatchableContext bc, list<Membership__c> scope){
        
        list <EmailTemplate> templateIds = new list <EmailTemplate> ([Select id from EmailTemplate where (name = 'Organisation Membership Renewals Direct Debit' OR name = 'Organisation Membership Renewals Not Direct Debit') ORDER BY name asc]);
        for(membership__c ta : (List<membership__c>)scope) {
            Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
            email.setToAddresses(new String[] {ta.Organisation__r.npe01__one2onecontact__r.Email});
            email.setSaveAsActivity(false);
            email.setTargetObjectId(ta.OwnerId);
            email.setTemplateId(ta.regular_payment__c == null ? templateIds[1].id : templateIds[0].id);
            email.setWhatId(ta.Id);
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
        }
    }
    
    public void finish(Database.BatchableContext bc){
        
        
    }
    
    global void execute(SchedulableContext SC) {
        database.executebatch(new SendMembershipRenewalEmail30Days());
    }
}


TEST CLASS 

@isTest(seeAllData = false)
private class Test_SendMembershipRenewalEmail30Days {
    
    static testMethod void unitTest_SendMembershipRenewalEmail30Days()
    {
        Test.startTest();
        Account acc = new Account(name ='test name');
        insert acc;
        
        Contact cont = new Contact();
        cont.FirstName ='Test';
        cont.LastName ='Test';
        cont.email ='Test@Test.com';
        cont.accountid = acc.id;
        insert cont;
        
        Id oppRecordTypeId = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('Membership').getRecordTypeId();
        Opportunity opp = new Opportunity();
        opp.amount = 10.00;
        opp.Name = 'test name';
        opp.StageName = 'Closed Won';
        opp.RecordTypeId = oppRecordTypeId;
        opp.CloseDate = date.today();
        insert opp;
        
        
        
        
        
        SendMembershipRenewalEmail30Days obj = new SendMembershipRenewalEmail30Days();
        Database.executeBatch(obj);
        Test.stopTest();
        
    }
    
    
    
}
My method is now returning null. However, I want to return a String saying that 'No value found' instead of null. My method is public static Map<Id,sObject>() type. Please refer to my code below:

 
public static Map<Id,Workday_Project_Hierarchy__c> getWorkdayHierarchies(Map<Id,Opportunity> WorkdayOppProject,Map<Id,String> Opp_ProjectTypeVal){
        Map<Id,String> workDayProjectHierarchyNames = new Map<Id,String>();
        Map<Opportunity,String> workdayProHierMap = new Map<Opportunity,String>();
        Map<Id,Workday_Project_Hierarchy__c> proHierarchyMap = new Map<Id,Workday_Project_Hierarchy__c>();
        List<String> Projecttypelst = new List<String> ();
        List<String> ProjectHierlst = new List<String> ();
        Map<Id,Workday_Project_Hierarchy__c> hierarchyList;
        Map<Id,Workday_Project_Hierarchy__c> Opp_ProjectHierFinalVal = new Map<Id,Workday_Project_Hierarchy__c> ();
        String ADS = 'Adaptive Insights';
        String DA = 'Delivery Assurance';
        String NonDANonAI = 'Non DA && Non AI';
        String PSA ='Planning Office Hours';
        String Greater = 'greater than or equals to';
        String Hire_Val = 'Null Values';
        List<String> WDHlst = new List <String> ();
        List<Workday_Project_Hierarchy__c> WorkProjHie_With_State = new List<Workday_Project_Hierarchy__c> ();
        List<Workday_Project_Hierarchy__c> WorkProjHie_Without_State = new List<Workday_Project_Hierarchy__c> ();
        if(!Opp_ProjectTypeVal.isEmpty())
            Projecttypelst.addall(Opp_ProjectTypeVal.values());
        
        System.debug('values of Projecttypelst' + Projecttypelst);
        if(!Projecttypelst.isEmpty())
            hierarchyList = new Map<Id,Workday_Project_Hierarchy__c>([SELECT Id,Name,Customer_Account_Region__c,Customer_Address__c,Employee_Count__c,Operator__c,Project_Type__c,
                                                                      PS_Region__c,PS_Sub_Region__c,Type__c,Workday_Services__c,State__c,Maximum_Employee_Count__c,Region__c,
                                                                      Minimum_Employee_Count__c
                                                                      From Workday_Project_Hierarchy__c /*Where Project_Type__c IN : Projecttypelst*/]);
        System.debug('values of hierarchyList' + hierarchyList);  
        
        if(!hierarchyList.isEmpty()){
            for(Workday_Project_Hierarchy__c w : hierarchyList.values()){
                if(w.State__c != null && w.State__c != '')
                WorkProjHie_With_State.add(w);
                else
                WorkProjHie_Without_State.add(w);
                 WDHlst.add(w.Project_Type__c);
            }
         
        system.debug('WorkProjHie_Without_State' + WorkProjHie_Without_State);
            //loop through all the Opp values to get the Map<OppId,ProjectHierarchy>.
        if(!WorkProjHie_With_State.isEmpty() || !WorkProjHie_Without_State.isEmpty())
       for(Opportunity o : WorkdayOppProject.values()){
                    
        if(o.Opportunity_PS_Region__c != null && o.Opportunity_PS_Region__c != '' && o.WD_Prime_Type__c == 'Planning' 
           && o.Opportunity_PS_Region__c != 'EMEA' && o.Opportunity_PS_Region__c != 'APJ'){
                           
              for(Workday_Project_Hierarchy__c wp0 : WorkProjHie_With_State){  
                  system.debug('Project type' + wp0.Project_Type__c);
                  system.debug( 'Opp Project type' + Opp_ProjectTypeVal.get(o.id).trim());
                               
                      List<String> w0 = new List<String> ();
                      String s0 = '';
                      s0 = wp0.Project_Type__c;
                      w0.addall(s0.split(';')); 
              if(w0.contains(Opp_ProjectTypeVal.get(o.id).trim())){       
                     system.debug('Contains check' + wp0.PS_Region__c + '>>> '+ o.Opportunity_PS_Region__c); 
                         if(wp0.Employee_Count__c != null && wp0.Operator__c == 'greater than or equals to' &&  o.APTS_Account_NumberOfEmployees__c >= wp0.Employee_Count__c
                            && (wp0.State__c != null || wp0.State__c != '') && o.Account_billing_state__c != null && o.Account_billing_state__c == wp0.State__c 
                            && (wp0.Workday_Services__c == '' || wp0.Workday_Services__c == null)){
                            system.debug('with state / greater than ');
                                          
                                 Opp_ProjectHierFinalVal.put(o.id,wp0);
                             }
                          if(wp0.Employee_Count__c != null && wp0.Operator__c == 'less than or equals to' &&  o.APTS_Account_NumberOfEmployees__c <= wp0.Employee_Count__c
                             && (wp0.State__c != null || wp0.State__c != '') && o.Account_billing_state__c != null && o.Account_billing_state__c == wp0.State__c 
                             && (wp0.Workday_Services__c == '' || wp0.Workday_Services__c == null)){
                                          
                                   Opp_ProjectHierFinalVal.put(o.id,wp0);
                             }
                           if(wp0.Employee_Count__c != null && wp0.Operator__c == 'between' && wp0.Employee_Count__c == null  && o.APTS_Account_NumberOfEmployees__c != null 
                              && o.APTS_Account_NumberOfEmployees__c < wp0.Maximum_Employee_Count__c 
                              && o.APTS_Account_NumberOfEmployees__c > wp0.Minimum_Employee_Count__c
                              && (wp0.State__c != null || wp0.State__c != '') && o.Account_billing_state__c == wp0.State__c && (wp0.Workday_Services__c == '' || wp0.Workday_Services__c == null)){
                                          
                                     Opp_ProjectHierFinalVal.put(o.id,wp0);
                              }                              
                          }       
                    }           
      } else if (o.Opportunity_PS_Region__c != null && o.Opportunity_PS_Region__c !='' 
                      /* && o.Opportunity_PS_Sub_Region__c !=null && o.Opportunity_PS_Sub_Region__c !=''*/){         
                                      
           for(Workday_Project_Hierarchy__c wp : WorkProjHie_Without_State){
               
              system.debug('Project type without' + wp.Project_Type__c);
              system.debug( 'Opp Project typewithout' + Opp_ProjectTypeVal.get(o.id).trim());
                                          
                      List<String> w = new List<String> ();
                      String s = '';
                      s = wp.Project_Type__c;
                      w.addall(s.split(';'));
               system.debug('split project type-->' + w);
                                          
            if(w.contains(Opp_ProjectTypeVal.get(o.id).trim())){
                                              
               system.debug('Contains check without' + wp.PS_Region__c + '>>> '+ o.Opportunity_PS_Region__c);
       //check for the Opp deal type is planning and PS region not equal to EMEA and APJ to check the state values.
                                              
                if(wp.PS_Region__c != null && wp.PS_Region__c != ''){                                                  
                    if(wp.PS_Sub_Region__c == '' || wp.PS_Sub_Region__c == null){
                       System.debug('In Ps sub region Null');                               
                       if(o.Opportunity_PS_Region__c != null && o.Opportunity_PS_Region__c == wp.PS_Region__c.trim()
                           && wp.Employee_Count__c == null  && (wp.Workday_Services__c == '' || wp.Workday_Services__c == null)){
                                                             
                                  Opp_ProjectHierFinalVal.put(o.id,wp);
                         }
                       If(o.Opportunity_PS_Region__c != null && o.Opportunity_PS_Region__c == wp.PS_Region__c.trim()
                          && (wp.Workday_Services__c == '' || wp.Workday_Services__c == null)
                          &&  wp.Employee_Count__c != null && wp.Operator__c == 'greater than or equals to' 
                          &&  o.APTS_Account_NumberOfEmployees__c >= wp.Employee_Count__c){
                                                             
                                   Opp_ProjectHierFinalVal.put(o.id,wp);
                         }
                       If(o.Opportunity_PS_Region__c != null && o.Opportunity_PS_Region__c == wp.PS_Region__c.trim()
                          && (wp.Workday_Services__c == '' || wp.Workday_Services__c == null)
                          && wp.Employee_Count__c != null && wp.Operator__c == 'less than or equals to' 
                          &&  o.APTS_Account_NumberOfEmployees__c <= wp.Employee_Count__c){
                                                             
                                    Opp_ProjectHierFinalVal.put(o.id,wp);
                         }                                                      
                 }// Sub region null check
                If(wp.PS_Sub_Region__c != null && wp.PS_Sub_Region__c != ''){
                     System.debug('In PS sub region Not Null--> ');                                 
                   if(o.Opportunity_PS_Region__c.trim() == wp.PS_Region__c.trim() && 
                      o.Opportunity_PS_Sub_Region__c.trim() == wp.PS_Sub_Region__c){
                           system.debug('Ps region and PS sub region');                                  
                      if(wp.Employee_Count__c != null && wp.Operator__c == 'greater than or equals to'
                         &&  o.APTS_Account_NumberOfEmployees__c >= wp.Employee_Count__c
                         && (wp.Workday_Services__c == '' || wp.Workday_Services__c == null)){
                              system.debug('Emp count greater than :--');                                      
                              Opp_ProjectHierFinalVal.put(o.id,wp);  
                      }
                      if(wp.Employee_Count__c != null && wp.Operator__c == 'less than or equals to' && 
                        o.APTS_Account_NumberOfEmployees__c <= wp.Employee_Count__c && 
                       (wp.Workday_Services__c == '' || wp.Workday_Services__c == null)){
                                                                    
                              Opp_ProjectHierFinalVal.put(o.id,wp);                                            
                     }                                        
                     if(wp.Employee_Count__c == null && wp.Operator__c == 'between' && 
                        o.APTS_Account_NumberOfEmployees__c != null &&
                        o.APTS_Account_NumberOfEmployees__c < wp.Maximum_Employee_Count__c &&
                        o.APTS_Account_NumberOfEmployees__c > wp.Minimum_Employee_Count__c ){
                                                                    
                              Opp_ProjectHierFinalVal.put(o.id,wp);        
                    }                                                            
                    if(wp.Employee_Count__c == null && (wp.Operator__c == null || wp.Operator__c == '') &&
                      (wp.Workday_Services__c == '' || wp.Workday_Services__c == null)){
                                                                    
                             Opp_ProjectHierFinalVal.put(o.id,wp); 
                    }
                    if(wp.Employee_Count__c != null && wp.Operator__c == 'greater than or equals to' 
                       &&  o.APTS_Account_NumberOfEmployees__c >= wp.Employee_Count__c 
                       && wp.Workday_Services__c != null
                       &&  o.Workday_Services__c != null 
                       && o.Workday_Services__c == wp.Workday_Services__c){
                                                                    
                             Opp_ProjectHierFinalVal.put(o.id,wp);   
                   }                                                             
                   if(wp.Employee_Count__c != null && wp.Operator__c == 'less than or equals to'
                      &&  o.APTS_Account_NumberOfEmployees__c <= wp.Employee_Count__c
                      && wp.Workday_Services__c != null
                      && o.Workday_Services__c != null
                      && o.Workday_Services__c == wp.Workday_Services__c){   
                          
                              Opp_ProjectHierFinalVal.put(o.id,wp);
                    }                                     
                  } //Ps region and Ps sub region Not null
                                                      
               }// wp.PS_Sub_Region__c null check.(Not null)
            }// null check for wp.PS_Region__c.
          }//Project Type If ends here.
        }//WSP for loop end here  //WPH for without state 
      }//else loop if Opp is EMEA and APJ
                   else{
                        system.debug('the opportunity region is blank.');
                    }
                }//Opportunity For end ghere.
   // }//state with or without
       } //hierarchyList empty check.
        if(!Opp_ProjectHierFinalVal.isEmpty() || Opp_ProjectHierFinalVal!= null){
            system.debug('final Workday hierarchy Project record:' + Opp_ProjectHierFinalVal);
            return Opp_ProjectHierFinalVal;
        }
        
return null; // HERE I WANT TO RETURN A STRING MESSAGE SAYING THAT 'NO VALUE FOUND' 
}//end of method. 










 
Hello,

I have this method that works fine: 
Public class AutoConvertLeads
{
    @InvocableMethod
    public static void LeadAssign(List<Lead> Leads)
    {
        LeadStatus CLeadStatus= [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true Limit 1];
        System.debug('Lead Converted Status' + CLeadStatus.MasterLabel);
        List<Database.LeadConvert> MassLeadconvert = new List<Database.LeadConvert>();
        for(Lead currentlead: Leads){
                Database.LeadConvert Leadconvert = new Database.LeadConvert();
                Leadconvert.setLeadId(currentlead.Id);                
                Leadconvert.setConvertedStatus(CLeadStatus.MasterLabel);
                if (currentlead.Account__c != null) {
                    System.debug('Lead Account' + currentlead.Account__c);
                    Leadconvert.setAccountId(currentlead.Account__c);
                }
            	MassLeadconvert.add(Leadconvert);
        }
        System.debug('List Convert' + MassLeadconvert);
        if (!MassLeadconvert.isEmpty()) {
            List<Database.LeadConvertResult> lcr = Database.convertLead(MassLeadconvert);
        	System.debug('Result' + lcr);
        }
    }
}

But I want to add a return value.
The value would be the variabe "lcr" which is List<Database.LeadConvertResult>. It could also be a list of strings or opportunity.

When I'm trying this :
Public class AutoConvertLeads
{
    @InvocableMethod
    public static List<Database.LeadConvertResult> LeadAssign(List<Lead> Leads)
    {
        LeadStatus CLeadStatus= [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true Limit 1];
        System.debug('Lead Converted Status' + CLeadStatus.MasterLabel);
        List<Database.LeadConvert> MassLeadconvert = new List<Database.LeadConvert>();
        for(Lead currentlead: Leads){
                Database.LeadConvert Leadconvert = new Database.LeadConvert();
                Leadconvert.setLeadId(currentlead.Id);                
                Leadconvert.setConvertedStatus(CLeadStatus.MasterLabel);
                if (currentlead.Account__c != null) {
                    System.debug('Lead Account' + currentlead.Account__c);
                    Leadconvert.setAccountId(currentlead.Account__c);
                }
            	MassLeadconvert.add(Leadconvert);
        }
        System.debug('List Convert' + MassLeadconvert);
        if (!MassLeadconvert.isEmpty()) {
            List<Database.LeadConvertResult> lcr = Database.convertLead(MassLeadconvert);
        	System.debug('Result' + lcr);
            return lcr;
        }
    }
}

I'm having the following error : InvocableMethod methods do not support return type of List<Database.LeadConvertResult>
I have tested  all kind of value like string etc but none of those are accepted.

Do you have any idea ?

Thanks,
Matthias
Hello,

I can't find access to the second level account record.
On the case record in the lightning component we need to pull Account field and Parent Account field. In first level Account, field is set properly, but not for the second level parent Account. Example below, and input that not working is underlined.
 
({
    initialize: function(component, event, helper) {
        var caseId = component.get("v.recordId");
        var action = component.get("c.getAccountInformation");
         action.setParams({
             caseId
         });
        action.setCallback(this, function(a){
             var rtnValue = a.getReturnValue();
             var state = a.getState();
             if (state === 'SUCCESS'){
                 component.set("v.AM", rtnValue.Account.Account_Manager__c);
                 component.set("v.ParentAM", rtnValue.Account.ParentId.Account_Manager__c);

              } else {
                  console.log(a.getReturnValue());
             }
          });

Please advice,
 
  • October 21, 2020
  • Like
  • 0

Hello everyone,

Through searching various past threads it looks like this questions has been asked a few times, however I am hoping to get some specific help.

I've just last week started dedicating myself to learning to develop (SF99!)  So I understand this is beyond my range, but this is a need at my current Org, and I thought it would be fun to actually try to do some development.

Note* I understand that a junction object could be an option here.  Given the users that will be using these objects, the fewer clicks the better so I need to stick with this model.

 

We have a Contract Agreement Object that has 5 lookup fields for parties that can be related to the Contract Agreement.  On the Party Object, I have 5 list.  I would like to combine them into one list, and display them on the Party object.  Here is what I have for code so far,  I'm a newbie so I'm sure I am far off, but I'm excited to learn.

public class CombineContractAgreement {
public CombineContractAgreement(ApexPages.StandardController controller) {
    
}

   Public List <Contract_Agreement__C> AllRelatedAgreements;
    
    Public List<Contract_Agreement__c>GetAllRelatedAgreement()
    {
        AllRelatedAgreements = [SELECT id, RecordTypeId, APXT_Redlining_Status__c, APXT_Redlining__Effective_Date__c, Agreement_Name__c FROM Contract_Agreement__c 
                                
                                WHERE //Current record is value on any 1 of 5 lookup fields on the Contract Agreement Record.//
 								return AllRelatedAgreements 
                               }
 

Any help you can provide will be greatly apprchated.




 

Hello, I have an email template with the following layout.  All the field display properly except the OD Sets fields and I can't figure out why.  Can anyone suggest what I may do to fix the issue? 

Email Template