• Raquib SF
  • NEWBIE
  • 60 Points
  • Member since 2017


  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 4
    Likes Given
  • 2
    Questions
  • 16
    Replies
Hoping someone can help out. I am an Administrator and my company is currently without a true developer, so I am doing my best to fill in. We have an external website where customers are able to sign up for our program, these come into Salesforce as Leads and are converted to Contacts/Accounts. Previously we used the standard Industry field on the Lead object to identify the customer's field of work, linked to the standard Industry field on the Account object. We are replacing both instances of the standard Industry field with a custom Business Type field (Business_Type__c), we're also adding two more custom fields that I will want to map in this code but haven't even begun to tackle that. The connector from the website to the Lead form is correct, but the conversion from Lead to Account does not bring over the new Business Type field from Lead to Account (the field exists on both objects). 

I thought a simple update of the Apex Code replacing Industry with Business_Type__c would do the trick, but I am running into an error stating the variable does not exist, though it does.

Original Code:
public with sharing class MembershipManagmentController {

    private final sObject mysObject;
    public Account accObj {get;set;}

    public Boolean inputShown{get;set;}
    public Boolean outputShown{get;set;}

    public List<SelectOption> industriesList {get;set;}
    public List<SelectOption> programTypeList {get;set;}
    public Map<String, List<SelectOption>> membershipLevelMap {get;set;}
    public Map<String, List<SelectOption>> programTypeMap {get;set;}
    public Map<String, List<SelectOption>> programTierMap {get;set;}

    // The extension constructor initializes the private member
    // variable mysObject by using the getRecord method from the standard
    // controller.
    public MembershipManagmentController(ApexPages.StandardController stdController) {
   if(!Test.isRunningTest()) { 
        stdController.addFields(new List<String>{'Industry', 'Program_Type__c', 'Program_Tier__c', 'Account_Level__c'});
   }
        this.accObj = (Account)stdController.getRecord();
        initData();
        inputShown = false;
        outputShown = true;
    }

    public MembershipManagmentController() {
        accObj = new Account();
        initData();
    }

    private void initProgramTierMap()
    {
        programTierMap = new Map<String, List<SelectOption>>();
        programTierMap.put('Chefs',new List<SelectOption>{new SelectOption('Chefs 20%','Chefs 20%')});
        programTierMap.put('Designer 10',new List<SelectOption>{new SelectOption('Trade 10%','Trade 10%')});
        programTierMap.put('Designer 15',new List<SelectOption>{new SelectOption('Gold 15%','Gold 15%')});
        programTierMap.put('Designer 20',new List<SelectOption>{new SelectOption('Platinum 20%','Platinum 20%')});

        programTierMap.put('Home Builder 10',new List<SelectOption>{new SelectOption('Trade 10%','Trade 10%')});
        programTierMap.put('Home Builder 15',new List<SelectOption>{new SelectOption('Gold 15%','Gold 15%')});
        programTierMap.put('Home Builder 20',new List<SelectOption>{new SelectOption('Platinum 20%','Platinum 20%')});

        programTierMap.put('Volume 10',new List<SelectOption>{new SelectOption('Trade 10%','Trade 10%')});
        programTierMap.put('Volume 15',new List<SelectOption>{new SelectOption('Gold 15%','Gold 15%')});
        programTierMap.put('Volume 20',new List<SelectOption>{new SelectOption('Platinum 20%','Platinum 20%')});
    }
    private void initData(){


        Map<String, Membership_Level_Dependency__c> dependencies = Membership_Level_Dependency__c.getAll();
        Set<String> industriesSet = new Set<String>();
        Set<String> programsSet = new Set<String>();
        programTypeMap = new Map<String, List<SelectOption>>{'' => new List<SelectOption>{new SelectOption('','No Options')}};
            Map<String, Set<String>> programsMap = new Map<String, Set<String>>();

        initProgramTierMap();
        industriesList = new List<SelectOption>();
        membershipLevelMap =  new Map<String, List<SelectOption>>{'/' => new List<SelectOption>{new SelectOption('','No Options')}};
            programTypeList = new List<SelectOption>();

        for (Membership_Level_Dependency__c item : dependencies.values()){
            if (!industriesSet.contains(item.Industry__c)){
                industriesSet.add(item.Industry__c);
                industriesList.add(new SelectOption(item.Industry__c,item.Industry__c));
            }
            if (programTypeMap.containsKey(item.Industry__c)){
                if (!programsMap.get(item.Industry__c).contains(item.Program_Type__c)){
                    programsMap.get(item.Industry__c).add(item.Program_Type__c);
                    programTypeMap.get(item.Industry__c).add(
                        new SelectOption(item.Program_Type__c,item.Program_Type__c));
                }
            } else {
                programsMap.put(item.Industry__c, new Set<String>{item.Program_Type__c});
                programTypeMap.put(item.Industry__c,
                                   new List<SelectOption>{
                                       new SelectOption(item.Program_Type__c,item.Program_Type__c)});
            }
            if (membershipLevelMap.containsKey(item.Industry__c+'/'+item.Program_Type__c)){
                membershipLevelMap.get(item.Industry__c+'/'+item.Program_Type__c).add(
                    new SelectOption(item.Membership_Level__c,item.Membership_Level__c));
            } else {
                membershipLevelMap.put(item.Industry__c+'/'+item.Program_Type__c,
                                       new List<SelectOption>{
                                           new SelectOption(item.Membership_Level__c,item.Membership_Level__c)});
            }
            if (!programTierMap.containsKey(item.Membership_Level__c))
                programTierMap.put(item.Membership_Level__c, new List<SelectOption>{
                    new SelectOption('','-None-')});
        }
        if (String.isBlank(accObj.Industry)){
            accObj.Industry = industriesList[0].getValue();
        }
        if (String.isBlank(accObj.Program_Type__c)){
            accObj.Program_Type__c = programTypeMap.get(industriesList[0].getValue())[0].getValue();
        }

        industriesList.sort();
        for (String key: programTypeMap.keySet())
            programTypeMap.get(key).sort();

        for (String key: membershipLevelMap.keySet())
            membershipLevelMap.get(key).sort();

    }

    public List<SelectOption> getMembershipLevels(){
        if(membershipLevelMap.containsKey(accObj.Industry+'/'+accObj.Program_Type__c)){
            return membershipLevelMap.get(accObj.Industry+'/'+accObj.Program_Type__c);
        } else {
            return new List<SelectOption>{new SelectOption('', '--None--')};
        }
    }

    public List<SelectOption> getProgramTires(){
        if(programTierMap.containsKey(accObj.Account_Level__c)){
            return membershipLevelMap.get(accObj.Account_Level__c);
        } else {
            return new List<SelectOption>{new SelectOption('', '--None--')};
        }
    }

    public PageReference showInput(){
        inputShown = true;
        outputShown = false;
        return null;
    }

    public PageReference showOutput(){
        inputShown = false;
        outputShown = true;
        return null;
    }

    public String getRecordName() {
        return 'Hello ' + (String)mysObject.get('name') + ' (' + (Id)mysObject.get('Id') + ')';
    }

    public void updateProgramTier()
    {
        if (accObj!=null)                    
                accObj.Program_Tier__c = programTierMap.get(accObj.Account_Level__c).get(0).getValue();        
    }
}

New Code:
public with sharing class MembershipManagmentController {

    private final sObject mysObject;
    public Account accObj {get;set;}

    public Boolean inputShown{get;set;}
    public Boolean outputShown{get;set;}

    public List<SelectOption> BusinessTypeList {get;set;}
    public List<SelectOption> programTypeList {get;set;}
    public Map<String, List<SelectOption>> membershipLevelMap {get;set;}
    public Map<String, List<SelectOption>> programTypeMap {get;set;}
    public Map<String, List<SelectOption>> programTierMap {get;set;}

    // The extension constructor initializes the private member
    // variable mysObject by using the getRecord method from the standard
    // controller.
    public MembershipManagmentController(ApexPages.StandardController stdController) {
   if(!Test.isRunningTest()) { 
        stdController.addFields(new List<String>{'Business_Type__c', 'Program_Type__c', 'Program_Tier__c', 'Account_Level__c'});
   }
        this.accObj = (Account)stdController.getRecord();
        initData();
        inputShown = false;
        outputShown = true;
    }

    public MembershipManagmentController() {
        accObj = new Account();
        initData();
    }

    private void initProgramTierMap()
    {
        programTierMap = new Map<String, List<SelectOption>>();
        programTierMap.put('Chefs',new List<SelectOption>{new SelectOption('Chefs 20%','Chefs 20%')});
        programTierMap.put('Designer 10',new List<SelectOption>{new SelectOption('Trade 10%','Trade 10%')});
        programTierMap.put('Designer 15',new List<SelectOption>{new SelectOption('Gold 15%','Gold 15%')});
        programTierMap.put('Designer 20',new List<SelectOption>{new SelectOption('Platinum 20%','Platinum 20%')});

        programTierMap.put('Home Builder 10',new List<SelectOption>{new SelectOption('Trade 10%','Trade 10%')});
        programTierMap.put('Home Builder 15',new List<SelectOption>{new SelectOption('Gold 15%','Gold 15%')});
        programTierMap.put('Home Builder 20',new List<SelectOption>{new SelectOption('Platinum 20%','Platinum 20%')});

        programTierMap.put('Volume 10',new List<SelectOption>{new SelectOption('Trade 10%','Trade 10%')});
        programTierMap.put('Volume 15',new List<SelectOption>{new SelectOption('Gold 15%','Gold 15%')});
        programTierMap.put('Volume 20',new List<SelectOption>{new SelectOption('Platinum 20%','Platinum 20%')});
    }
    private void initData(){


        Map<String, Membership_Level_Dependency__c> dependencies = Membership_Level_Dependency__c.getAll();
        Set<String> BusinessTypeSet = new Set<String>();
        Set<String> programsSet = new Set<String>();
        programTypeMap = new Map<String, List<SelectOption>>{'' => new List<SelectOption>{new SelectOption('','No Options')}};
            Map<String, Set<String>> programsMap = new Map<String, Set<String>>();

        initProgramTierMap();
        BusinessTypeList = new List<SelectOption>();
        membershipLevelMap =  new Map<String, List<SelectOption>>{'/' => new List<SelectOption>{new SelectOption('','No Options')}};
            programTypeList = new List<SelectOption>();

        for (Membership_Level_Dependency__c item : dependencies.values()){
            if (!BusinessTypeSet.contains(item.Business_Type__c)){
                BusinessTypeSet.add(item.Business_Type__c);
                BusinessTypeList.add(new SelectOption(item.Business_Type__c,item.Business_Type__c));
            }
            if (programTypeMap.containsKey(item.Business_Type__c)){
                if (!programsMap.get(item.Business_Type__c).contains(item.Program_Type__c)){
                    programsMap.get(item.Business_Type__c).add(item.Program_Type__c);
                    programTypeMap.get(item.Business_Type__c).add(
                        new SelectOption(item.Program_Type__c,item.Program_Type__c));
                }
            } else {
                programsMap.put(item.Business_Type__c, new Set<String>{item.Program_Type__c});
                programTypeMap.put(item.Business_Type__c,
                                   new List<SelectOption>{
                                       new SelectOption(item.Program_Type__c,item.Program_Type__c)});
            }
            if (membershipLevelMap.containsKey(item.Business_Type__c+'/'+item.Program_Type__c)){
                membershipLevelMap.get(item.Business_Type__c+'/'+item.Program_Type__c).add(
                    new SelectOption(item.Membership_Level__c,item.Membership_Level__c));
            } else {
                membershipLevelMap.put(item.Business_Type__c+'/'+item.Program_Type__c,
                                       new List<SelectOption>{
                                           new SelectOption(item.Membership_Level__c,item.Membership_Level__c)});
            }
            if (!programTierMap.containsKey(item.Membership_Level__c))
                programTierMap.put(item.Membership_Level__c, new List<SelectOption>{
                    new SelectOption('','-None-')});
        }
        if (String.isBlank(accObj.Business_Type__c)){
            accObj.Business_Type__c = BusinessTypeList[0].getValue();
        }
        if (String.isBlank(accObj.Program_Type__c)){
            accObj.Program_Type__c = programTypeMap.get(BusinessTypeList[0].getValue())[0].getValue();
        }

        BusinessTypeList.sort();
        for (String key: programTypeMap.keySet())
            programTypeMap.get(key).sort();

        for (String key: membershipLevelMap.keySet())
            membershipLevelMap.get(key).sort();

    }

    public List<SelectOption> getMembershipLevels(){
        if(membershipLevelMap.containsKey(accObj.Business_Type__c+'/'+accObj.Program_Type__c)){
            return membershipLevelMap.get(accObj.Business_Type__c+'/'+accObj.Program_Type__c);
        } else {
            return new List<SelectOption>{new SelectOption('', '--None--')};
        }
    }

    public List<SelectOption> getProgramTires(){
        if(programTierMap.containsKey(accObj.Account_Level__c)){
            return membershipLevelMap.get(accObj.Account_Level__c);
        } else {
            return new List<SelectOption>{new SelectOption('', '--None--')};
        }
    }

    public PageReference showInput(){
        inputShown = true;
        outputShown = false;
        return null;
    }

    public PageReference showOutput(){
        inputShown = false;
        outputShown = true;
        return null;
    }

    public String getRecordName() {
        return 'Hello ' + (String)mysObject.get('name') + ' (' + (Id)mysObject.get('Id') + ')';
    }

    public void updateProgramTier()
    {
        if (accObj!=null)                    
                accObj.Program_Tier__c = programTierMap.get(accObj.Account_Level__c).get(0).getValue();        
    }
}



Any help would be greatly appreciated!
Hi can you revise my code if it is not correct wherein I want to update all case records wherein I will unlock all of them. I tested one record and its updating but I think when its all or bulk its not updating.
 
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 2';
        return Database.getQueryLocator(query);
    }
    //Exeution of batch job
    global void execute(Database.BatchableContext BC, List<Case> scope) {
        List<Case> caseList = [SELECT Id From CaseLimit 2];
        //Check locked records
        List<Case> caseLockList = new List<Case>();
        for(Case c : caseList)
        {
            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) {
    }
}

 
Hello guys,

I am getting the below errow then trying to complete one of the modules: Lightning Components Basics, Input data using forms

Challenge Not yet complete... here's what's wrong: 
The campingList component doesn't appear to have a Packed checkbox field in the form using a Lightning Base component.

Although i am using the base lightning comp:
                        
<lightning:input type="checkbox"
                                         aura:id="campaingItem"
                                         label="Packed"
                                         name="campaignPacked"
                                         value="{!v.newItem.Packed__c}"                                        
                                         />

Please help

 
I am getting this error while trying to complete the trailhed module --> https://trailhead.salesforce.com/modules/apex_integration_services/units/apex_integration_soap_callouts

Please help!!

Thanks,
Raquib
Hoping someone can help out. I am an Administrator and my company is currently without a true developer, so I am doing my best to fill in. We have an external website where customers are able to sign up for our program, these come into Salesforce as Leads and are converted to Contacts/Accounts. Previously we used the standard Industry field on the Lead object to identify the customer's field of work, linked to the standard Industry field on the Account object. We are replacing both instances of the standard Industry field with a custom Business Type field (Business_Type__c), we're also adding two more custom fields that I will want to map in this code but haven't even begun to tackle that. The connector from the website to the Lead form is correct, but the conversion from Lead to Account does not bring over the new Business Type field from Lead to Account (the field exists on both objects). 

I thought a simple update of the Apex Code replacing Industry with Business_Type__c would do the trick, but I am running into an error stating the variable does not exist, though it does.

Original Code:
public with sharing class MembershipManagmentController {

    private final sObject mysObject;
    public Account accObj {get;set;}

    public Boolean inputShown{get;set;}
    public Boolean outputShown{get;set;}

    public List<SelectOption> industriesList {get;set;}
    public List<SelectOption> programTypeList {get;set;}
    public Map<String, List<SelectOption>> membershipLevelMap {get;set;}
    public Map<String, List<SelectOption>> programTypeMap {get;set;}
    public Map<String, List<SelectOption>> programTierMap {get;set;}

    // The extension constructor initializes the private member
    // variable mysObject by using the getRecord method from the standard
    // controller.
    public MembershipManagmentController(ApexPages.StandardController stdController) {
   if(!Test.isRunningTest()) { 
        stdController.addFields(new List<String>{'Industry', 'Program_Type__c', 'Program_Tier__c', 'Account_Level__c'});
   }
        this.accObj = (Account)stdController.getRecord();
        initData();
        inputShown = false;
        outputShown = true;
    }

    public MembershipManagmentController() {
        accObj = new Account();
        initData();
    }

    private void initProgramTierMap()
    {
        programTierMap = new Map<String, List<SelectOption>>();
        programTierMap.put('Chefs',new List<SelectOption>{new SelectOption('Chefs 20%','Chefs 20%')});
        programTierMap.put('Designer 10',new List<SelectOption>{new SelectOption('Trade 10%','Trade 10%')});
        programTierMap.put('Designer 15',new List<SelectOption>{new SelectOption('Gold 15%','Gold 15%')});
        programTierMap.put('Designer 20',new List<SelectOption>{new SelectOption('Platinum 20%','Platinum 20%')});

        programTierMap.put('Home Builder 10',new List<SelectOption>{new SelectOption('Trade 10%','Trade 10%')});
        programTierMap.put('Home Builder 15',new List<SelectOption>{new SelectOption('Gold 15%','Gold 15%')});
        programTierMap.put('Home Builder 20',new List<SelectOption>{new SelectOption('Platinum 20%','Platinum 20%')});

        programTierMap.put('Volume 10',new List<SelectOption>{new SelectOption('Trade 10%','Trade 10%')});
        programTierMap.put('Volume 15',new List<SelectOption>{new SelectOption('Gold 15%','Gold 15%')});
        programTierMap.put('Volume 20',new List<SelectOption>{new SelectOption('Platinum 20%','Platinum 20%')});
    }
    private void initData(){


        Map<String, Membership_Level_Dependency__c> dependencies = Membership_Level_Dependency__c.getAll();
        Set<String> industriesSet = new Set<String>();
        Set<String> programsSet = new Set<String>();
        programTypeMap = new Map<String, List<SelectOption>>{'' => new List<SelectOption>{new SelectOption('','No Options')}};
            Map<String, Set<String>> programsMap = new Map<String, Set<String>>();

        initProgramTierMap();
        industriesList = new List<SelectOption>();
        membershipLevelMap =  new Map<String, List<SelectOption>>{'/' => new List<SelectOption>{new SelectOption('','No Options')}};
            programTypeList = new List<SelectOption>();

        for (Membership_Level_Dependency__c item : dependencies.values()){
            if (!industriesSet.contains(item.Industry__c)){
                industriesSet.add(item.Industry__c);
                industriesList.add(new SelectOption(item.Industry__c,item.Industry__c));
            }
            if (programTypeMap.containsKey(item.Industry__c)){
                if (!programsMap.get(item.Industry__c).contains(item.Program_Type__c)){
                    programsMap.get(item.Industry__c).add(item.Program_Type__c);
                    programTypeMap.get(item.Industry__c).add(
                        new SelectOption(item.Program_Type__c,item.Program_Type__c));
                }
            } else {
                programsMap.put(item.Industry__c, new Set<String>{item.Program_Type__c});
                programTypeMap.put(item.Industry__c,
                                   new List<SelectOption>{
                                       new SelectOption(item.Program_Type__c,item.Program_Type__c)});
            }
            if (membershipLevelMap.containsKey(item.Industry__c+'/'+item.Program_Type__c)){
                membershipLevelMap.get(item.Industry__c+'/'+item.Program_Type__c).add(
                    new SelectOption(item.Membership_Level__c,item.Membership_Level__c));
            } else {
                membershipLevelMap.put(item.Industry__c+'/'+item.Program_Type__c,
                                       new List<SelectOption>{
                                           new SelectOption(item.Membership_Level__c,item.Membership_Level__c)});
            }
            if (!programTierMap.containsKey(item.Membership_Level__c))
                programTierMap.put(item.Membership_Level__c, new List<SelectOption>{
                    new SelectOption('','-None-')});
        }
        if (String.isBlank(accObj.Industry)){
            accObj.Industry = industriesList[0].getValue();
        }
        if (String.isBlank(accObj.Program_Type__c)){
            accObj.Program_Type__c = programTypeMap.get(industriesList[0].getValue())[0].getValue();
        }

        industriesList.sort();
        for (String key: programTypeMap.keySet())
            programTypeMap.get(key).sort();

        for (String key: membershipLevelMap.keySet())
            membershipLevelMap.get(key).sort();

    }

    public List<SelectOption> getMembershipLevels(){
        if(membershipLevelMap.containsKey(accObj.Industry+'/'+accObj.Program_Type__c)){
            return membershipLevelMap.get(accObj.Industry+'/'+accObj.Program_Type__c);
        } else {
            return new List<SelectOption>{new SelectOption('', '--None--')};
        }
    }

    public List<SelectOption> getProgramTires(){
        if(programTierMap.containsKey(accObj.Account_Level__c)){
            return membershipLevelMap.get(accObj.Account_Level__c);
        } else {
            return new List<SelectOption>{new SelectOption('', '--None--')};
        }
    }

    public PageReference showInput(){
        inputShown = true;
        outputShown = false;
        return null;
    }

    public PageReference showOutput(){
        inputShown = false;
        outputShown = true;
        return null;
    }

    public String getRecordName() {
        return 'Hello ' + (String)mysObject.get('name') + ' (' + (Id)mysObject.get('Id') + ')';
    }

    public void updateProgramTier()
    {
        if (accObj!=null)                    
                accObj.Program_Tier__c = programTierMap.get(accObj.Account_Level__c).get(0).getValue();        
    }
}

New Code:
public with sharing class MembershipManagmentController {

    private final sObject mysObject;
    public Account accObj {get;set;}

    public Boolean inputShown{get;set;}
    public Boolean outputShown{get;set;}

    public List<SelectOption> BusinessTypeList {get;set;}
    public List<SelectOption> programTypeList {get;set;}
    public Map<String, List<SelectOption>> membershipLevelMap {get;set;}
    public Map<String, List<SelectOption>> programTypeMap {get;set;}
    public Map<String, List<SelectOption>> programTierMap {get;set;}

    // The extension constructor initializes the private member
    // variable mysObject by using the getRecord method from the standard
    // controller.
    public MembershipManagmentController(ApexPages.StandardController stdController) {
   if(!Test.isRunningTest()) { 
        stdController.addFields(new List<String>{'Business_Type__c', 'Program_Type__c', 'Program_Tier__c', 'Account_Level__c'});
   }
        this.accObj = (Account)stdController.getRecord();
        initData();
        inputShown = false;
        outputShown = true;
    }

    public MembershipManagmentController() {
        accObj = new Account();
        initData();
    }

    private void initProgramTierMap()
    {
        programTierMap = new Map<String, List<SelectOption>>();
        programTierMap.put('Chefs',new List<SelectOption>{new SelectOption('Chefs 20%','Chefs 20%')});
        programTierMap.put('Designer 10',new List<SelectOption>{new SelectOption('Trade 10%','Trade 10%')});
        programTierMap.put('Designer 15',new List<SelectOption>{new SelectOption('Gold 15%','Gold 15%')});
        programTierMap.put('Designer 20',new List<SelectOption>{new SelectOption('Platinum 20%','Platinum 20%')});

        programTierMap.put('Home Builder 10',new List<SelectOption>{new SelectOption('Trade 10%','Trade 10%')});
        programTierMap.put('Home Builder 15',new List<SelectOption>{new SelectOption('Gold 15%','Gold 15%')});
        programTierMap.put('Home Builder 20',new List<SelectOption>{new SelectOption('Platinum 20%','Platinum 20%')});

        programTierMap.put('Volume 10',new List<SelectOption>{new SelectOption('Trade 10%','Trade 10%')});
        programTierMap.put('Volume 15',new List<SelectOption>{new SelectOption('Gold 15%','Gold 15%')});
        programTierMap.put('Volume 20',new List<SelectOption>{new SelectOption('Platinum 20%','Platinum 20%')});
    }
    private void initData(){


        Map<String, Membership_Level_Dependency__c> dependencies = Membership_Level_Dependency__c.getAll();
        Set<String> BusinessTypeSet = new Set<String>();
        Set<String> programsSet = new Set<String>();
        programTypeMap = new Map<String, List<SelectOption>>{'' => new List<SelectOption>{new SelectOption('','No Options')}};
            Map<String, Set<String>> programsMap = new Map<String, Set<String>>();

        initProgramTierMap();
        BusinessTypeList = new List<SelectOption>();
        membershipLevelMap =  new Map<String, List<SelectOption>>{'/' => new List<SelectOption>{new SelectOption('','No Options')}};
            programTypeList = new List<SelectOption>();

        for (Membership_Level_Dependency__c item : dependencies.values()){
            if (!BusinessTypeSet.contains(item.Business_Type__c)){
                BusinessTypeSet.add(item.Business_Type__c);
                BusinessTypeList.add(new SelectOption(item.Business_Type__c,item.Business_Type__c));
            }
            if (programTypeMap.containsKey(item.Business_Type__c)){
                if (!programsMap.get(item.Business_Type__c).contains(item.Program_Type__c)){
                    programsMap.get(item.Business_Type__c).add(item.Program_Type__c);
                    programTypeMap.get(item.Business_Type__c).add(
                        new SelectOption(item.Program_Type__c,item.Program_Type__c));
                }
            } else {
                programsMap.put(item.Business_Type__c, new Set<String>{item.Program_Type__c});
                programTypeMap.put(item.Business_Type__c,
                                   new List<SelectOption>{
                                       new SelectOption(item.Program_Type__c,item.Program_Type__c)});
            }
            if (membershipLevelMap.containsKey(item.Business_Type__c+'/'+item.Program_Type__c)){
                membershipLevelMap.get(item.Business_Type__c+'/'+item.Program_Type__c).add(
                    new SelectOption(item.Membership_Level__c,item.Membership_Level__c));
            } else {
                membershipLevelMap.put(item.Business_Type__c+'/'+item.Program_Type__c,
                                       new List<SelectOption>{
                                           new SelectOption(item.Membership_Level__c,item.Membership_Level__c)});
            }
            if (!programTierMap.containsKey(item.Membership_Level__c))
                programTierMap.put(item.Membership_Level__c, new List<SelectOption>{
                    new SelectOption('','-None-')});
        }
        if (String.isBlank(accObj.Business_Type__c)){
            accObj.Business_Type__c = BusinessTypeList[0].getValue();
        }
        if (String.isBlank(accObj.Program_Type__c)){
            accObj.Program_Type__c = programTypeMap.get(BusinessTypeList[0].getValue())[0].getValue();
        }

        BusinessTypeList.sort();
        for (String key: programTypeMap.keySet())
            programTypeMap.get(key).sort();

        for (String key: membershipLevelMap.keySet())
            membershipLevelMap.get(key).sort();

    }

    public List<SelectOption> getMembershipLevels(){
        if(membershipLevelMap.containsKey(accObj.Business_Type__c+'/'+accObj.Program_Type__c)){
            return membershipLevelMap.get(accObj.Business_Type__c+'/'+accObj.Program_Type__c);
        } else {
            return new List<SelectOption>{new SelectOption('', '--None--')};
        }
    }

    public List<SelectOption> getProgramTires(){
        if(programTierMap.containsKey(accObj.Account_Level__c)){
            return membershipLevelMap.get(accObj.Account_Level__c);
        } else {
            return new List<SelectOption>{new SelectOption('', '--None--')};
        }
    }

    public PageReference showInput(){
        inputShown = true;
        outputShown = false;
        return null;
    }

    public PageReference showOutput(){
        inputShown = false;
        outputShown = true;
        return null;
    }

    public String getRecordName() {
        return 'Hello ' + (String)mysObject.get('name') + ' (' + (Id)mysObject.get('Id') + ')';
    }

    public void updateProgramTier()
    {
        if (accObj!=null)                    
                accObj.Program_Tier__c = programTierMap.get(accObj.Account_Level__c).get(0).getValue();        
    }
}



Any help would be greatly appreciated!
Dear Salesforce community,

I'm trying to send a Post request to an external system. In this json I am sending fields from an opportunity. I ran in to a problem when trying to add all the product line item, product codes in to the class that generates the json. I keep getting this error message: static can only be used on methods of a top level type. This is what my code looks like at the moment:
 
public class LeopardSubscriptionUpdate {
    public static HttpResponse makeGetCallout() {

 

Opportunity o= [Select Id ,AVSFQB__Primary_Contact__r.name, Account.name, Account.Market_Segment__c, AVSFQB__Billing_State__c, AVSFQB__Primary_Contact__r.Email from Opportunity Limit 1] ; 
JSONGenerator gen = JSON.createGenerator(true); 
    gen.writeStartObject();      
    gen.writeStringField('Customer User Full Name', o.AVSFQB__Primary_Contact__r.name);
    gen.writeStringField('Customer Name',o.Account.name);
    gen.writeStringField('Organization Type',o.Account.Market_Segment__c);
    gen.writeStringField('State',o.AVSFQB__Billing_State__c);
    gen.writeStringField('Email', o.AVSFQB__Primary_Contact__r.Email);
    gen.writeEndObject();    
    String jsonS = gen.getAsString();
System.debug('jsonMaterials'+jsonS);
string returnValue = generateStringArray();
System.debug(returnValue);

 

// Sending the http body with JSON 

 

String endpoint = 'myurl.com';
HttpRequest req = new HttpRequest();
req.setEndpoint(endpoint);
req.setMethod('POST');
req.setbody(jsonS);
Http http = new Http();
HTTPResponse response = http.send(req);
  return response;  }
    
   public void generateStringArray(){
        List<OpportunityLineItem> prodCodeList = [Select ProductCode from OpportunityLineItem];
    }
}

I feel like i'm failing to understand the relationship between public classes, public static classes and public void classes. I'm not a developer and kind of just winging it.

Thank you!

 

Hello all,

I've created a custom field called "Case_Queue__c" on the Case object. I want the field to display the name of the Queue the case is currently assigned to.

I thought I could use a formula on text field but it's not working:

IF( Owner:Queue.Id <> null, Owner:Queue.QueueName, "No Value" )

What am I missing, please?

Thank you,
B

Hi can you revise my code if it is not correct wherein I want to update all case records wherein I will unlock all of them. I tested one record and its updating but I think when its all or bulk its not updating.
 
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 2';
        return Database.getQueryLocator(query);
    }
    //Exeution of batch job
    global void execute(Database.BatchableContext BC, List<Case> scope) {
        List<Case> caseList = [SELECT Id From CaseLimit 2];
        //Check locked records
        List<Case> caseLockList = new List<Case>();
        for(Case c : caseList)
        {
            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) {
    }
}

 
I want to display case fields based on related opportunity recordtype. I am facing issues.Anyone please help on this.

<apex:page standardController="Case"   showHeader="false" applyBodyTag="false" applyHtmlTag="false">
<apex:form >
<apex:outputPanel rendered="{!IF(Case.Opportunity__r.RecordType.Name =’proposed Recordtype’,true,false)}"> -->
<apex:pageBlocksection >
<apex:outputLabel value="space" /> 
<apex:inputField value="{!Case.space__c}" />
</apex:pageBlocksection>
</apex:outputPanel >

<apex:outputPanel rendered="{!IF(Case.Opportunity__r.RecordType.Name =’Intial Recordtype’,true,false)}"> -->
<apex:pageBlocksection >
<apex:outputLabel value="counter" /> 
<apex:inputField value="{!Case.counter__c}" />
</apex:pageBlocksection>
</apex:outputPanel >
</apex:form> 
</apex:page>
Hi All,

We have a requirement wherein the Start Date of the Child Record can be only 6 months less than the Start Date of the Parent Record.

Also, the End Date of the Child Record can be only 6 months more than the End Date of the Parent Record.

Please help me create the Validation Rule for this.

Thank You for all the Help in Advance!
I currently have an SOAP API process to push/update from our DB to Salesforce twice daily - once at 6 AM and again at 9 PM. The 9 PM job does not connect to Salesforce. I need to resolve the error below:

    
Try to connect to Salesforce via SOAP connection.
Error Message (If applicable)    
21:08:47.073 [main] INFO c.p.pinksync.salesforce.impl.BaseSF - LOGGING IN NOW....
21:08:47,344 ERROR (SforcePartnerImpl:105) - Connection Exception occurred while creating ...for compid 687802 and spmid 5543
[UnexpectedErrorFault [ApiFault exceptionCode='UNKNOWN_EXCEPTION'
exceptionMessage='An unexpected error occurred. Please include this ErrorId if you contact support: 471974694-49049 (550841919)'
extendedErrorDetails='{[0]}'
]
]

at sun.reflect.GeneratedConstructorAccessor52.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at java.lang.Class.newInstance(Class.java:438)
at com.sforce.ws.bind.TypeMapper.readSingle(TypeMapper.java:682)
at com.sforce.ws.bind.TypeMapper.readObject(TypeMapper.java:557)
at com.sforce.ws.transport.SoapConnection.parseDetail(SoapConnection.java:236)
at com.sforce.ws.transport.SoapConnection.createException(SoapConnection.java:210)
at com.sforce.ws.transport.SoapConnection.receive(SoapConnection.java:156)
at com.sforce.ws.transport.SoapConnection.send(SoapConnection.java:99)
at com.sforce.soap.enterprise.EnterpriseConnection.create(EnterpriseConnection.java:432)
at com.pinkotc.pinksync.salesforce.impl.SforcePartnerImpl.createSforcePartner(SforcePartnerImpl.java:90)
at com.pinkotc.pinksync.salesforce.impl.SforcePartnerImpl.updateSforcePartner(SforcePartnerImpl.java:40)
at com.pinkotc.pinksync.cli.PinksyncAdmin.main(PinksyncAdmin.java:222)
21:08:47.344 [main] INFO o.s.c.s.ClassPathXmlApplicationContext - Closing org.springframework.context.support.ClassPathXmlApplicationContext@546a03af: startup date [Mon Oct 21 21:00:02 EDT 2019]; root of context hierarchy
21:08:47.346 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'lifecycleProcessor'
Hi All,

When i try to write Page reference
GenerateDocument - It is Visual force page in CPQ Managed Package.It is called when Generate Document button is clicked in Quote Detail Page.
//Quote.id --> retrieves current CPQ Quote id
PageReference pr = new PageReference('apex/GenerateDocument?id=' + quote.id);
               
        
                 Attachment at     =   new Attachment();
                 Blob b = pr.getContentAsPDF();
                    at.Body        =  b;
                        at.ParentId   =   quo1.Id;
                 at.ContentType = 'pdf';
                 insert at;
Displays Error as :
core.apexpages.exceptions.ApexPagesGenericException: The page can't be loaded because the remote site apex/GenerateDocument isn't listed in your organization's Remote Sites Settings.
But I try to create new Remote Site  --> but it does not works on my end.

Please Advice and suggest.

Thanks,
Sumitha P
 
Hey Community,

I need to create a checkbox formula so that it will mark the checkbox 20hrs after the case was opened. I need this for the report to track service times for managers' information and the SLA for case resolution is set to 20hrs. I want to show all cases which were created more than 20hrs ago and they are still not closed.

What I got so far is this: 

HOUR(TIMENOW()) - HOUR(TIMEVALUE(CreatedDate)) > 20

It returns strange results. I am not sure whether the "20" I put, in the end, is counted as 'hours' or does it have some other value.

Your help would be much appreciated.

Regards,
Dominik
Hi Everyone,

I have function inside JS file, where i am trying to invoke a apex imperative call as below-
getdlcontactscount({dls:str3})
.then(res => {
if (res.data) {
for(var i=0; i<data.length; i++) {
console.log('id=------' + data[i].TempValue__c);
this.refreshTable = data[i].TempValue__c;
}
this.error = undefined;
}

The request is hitting the apex method as below-

List<String> st= dls.split(';');
List<Contact> countval= new List<Contact>();
System.debug(LoggingLevel.INFO,'st value-----------'+st);
List<Contact> contactfinalids=new List<Contact>();
List<contact> lstcon=[Select Id,Email,Distributions_List_Assigned_To__c FROM Contact where email!=null];
for(String s:st)
{
for(Contact ct:lstcon){
if(ct.Distributions_List_Assigned_To__c!=null && (ct.Distributions_List_Assigned_To__c).contains(s.trim()))
contactfinalids.add(ct);
}
}
System.debug('contactfinalids-----------'+contactfinalids);
//countval.add(contactfinalids.size());
Contact c = new Contact();
c.TempValue__c=contactfinalids.size();
countval.add(c);
System.debug('contactfinalids----countval-------'+countval);
return countval;

I am getting the output in apex class, but when i am checking at the JS function the console statement itself is not getting printed
Can someone please help me on how to return values from apex imeprative calls , i.e how can i send a Integer value or a string value? 
 
I have a Opportunity Trigger Handler were I want to create custom Sportsman__c records related to the created or updated Opportunity. 

In case of Update, to find wheter the updated Opportunity already has Sportsman__c records, i execute the following: 
 
// check if trigger is update
if (oldMap != null) {
	oldRecordList.addAll(oldMap.values());
    System.debug('oldRecordList: ' + oldRecordList);
    // create list with sportsman records related to an opportunity
    sportsmanCheckList = [SELECT Id, Sportsman__c, Opportunity__c FROM Sportsman__c WHERE Opportunity__c IN :oldRecordList];
    System.debug('Checklist: ' + sportsmanCheckList);
    System.debug('oldMap: ' + oldMap);

        for (Opportunity o : oldRecordList) {
        // put opportunities w/o sportsman records in opportunityWithoutSportsmanList
           for (Sportsman__c s : sportsmanCheckList) {
                if (o.Id != s.Opportunity__c) {
               opportunityWithoutSportsmanList.add(o);
                        } 
                    }
                }
The problem is that the sportsmanCheckList never gets filled, I suspect something is wrong with my SOQL query. But when I debug the oldRecordList it contains the updated Opportunity.

Can someone help me with this issue?
 
I am trying to import 4k records using data loader. I want to maintain a one unique id  for all  4k records The unique id should be generate automatically in the salesforce..
Will it possible?..
I want to display more than 1000 account names in one picklist using select option.

<apex:selectList value="{!myAccountspicklist}" >
<apex:selectOptions value="{!myaccounts}"/>
  </apex:selectList>

public List<Account> getMyaccounts(){
        List<Account> lstAccount = [select id,name from account];
        return lstAccount;
    }
Hi All,

Can someone please help me resolve this issue.
I am getting error as "SampleClass.cls Method sampleMethod at line 3 of classes\SampleClass.cls gets user input from the strVar element. This element’s value then flows through the code without being properly sanitized or validated, and is eventually used in a database query in method sampleMethod at line 3 of classes\SampleClass.cls. This may enable an SOQL Injection attack. line no: 2, 5, 6" in checkmarx report. Thanks in advance.

Below is code:
 
public class SampleClass {
public String strVar {get; set;};
public void sampleMethod(){
if(strVar != null){     
    strVar = strVar.trim();
    List<String> varList = strVar.split(' ');   
    //logic
    String str1;
    String qString =  'select id, Description FROM Account';
    if(varList.size()==1){
        str1 = varList.get(0);
        queryStr+= ' and (Account.Name like \'%' + str1 + '%\')'; 
    }
}
}
}
Issue at below piece of code:

public String strVar {get; set;};
public void sampleMethod(){
if(strVar != null){
strVar = strVar.trim();
List<String> varList = strVar.split(' ');

 
Good morning All,

Can someone suggest me to find duplicate reocrds in custom object (which have more than 15 million reocods). I tried by using below query but it consumes more time and failing with CPU time limit exception.

List<AggregateResult> acc=[SELECT Name, count(Id) FROM Account GROUP BY Name HAVING count(Id)>1];

Now i am planning to create batch job find and update those records, but it has to be done by subset of records I guess. 

Can someone advise me "Is there any other way to achieve this?"

Thanks in advance !!!
Hi Guys,
 
I have a scenario where there are 2 different custom objects in which there are 2 picklist fields with the same values.
 
Q. When the values in object 1 are deactivated, then is it possible to deactivate or hide that particular value in the object 2 field.
 
please help me in which way it is possible..!!
 
Thanks in advance. 
Hey guys

I'm trying to run the flow hereunder but I am getting an error because I am trying to loop through multiple records (approx 2000). The flow works great when I change the filter criteria to only loop through 50 records but I would like to loop through all of them at one go. Is there a way I can do this using the visual flow builder? Unfortunately I'm not that experienced in APEX code.

User-added imageThanks
Aaron
I currently have apex class in lightning component that is getting a specific Queue Id to assign as owner of the record the component is launched from.

This is the current  way I'm getting the id, but I'm guessing there is a better way to do this, any ideas?
Group marketingQueue = [SELECT id,Name FROM Group WHERE Type = 'Queue' and DeveloperNAME = 'MarketingProspectLeads'];
         	ID marketingQueueId = marketingQueue.id;
            //l.OwnerId = UserInfo.getUserId();
            system.debug('marketingQueue');
            l.OwnerId = marketingQueueId;

I just need to make sure this can't break so I'm assuming I should add some error checking or be doing this a different way.  Thanks in advance.  
I have a lightning component embedded in a flow, how do I pass the recordId from the flow into the lightning component?

Everything I have found shows the old flow designer.  The new lightning flow designer does not have an option to set input fields on the lightning component.

Thanks.
I am receiving the error:
Unexpected file found in package directory:
When I try to deploy a class that I have just created.  The file is saved in the /force-app/main/default/classes/Case_Trigger_Alert_Count.

I have also noticed that in the 'Problems' tab, I have the message:
The sourcepath ".../force-app/main/default/classes/Case_Trigger_Alert_Count" is not a valid source file path.  SourcePathInvalid [1,1]

The filename of the file I have just created and attempting to deploy is 'Case_Trigger_Alert_Count"
What am I missing to be able to deploy to my Sandbox?