• Austin G
  • 5 Points
  • Member since 2015
  • Developer

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 8

I need help on replacing reserved keywords with other values in my JSON response string. I have tried with replace and replaceAll methods, but​ I am getting error (System.LimitException: Regex too complicated) because of large JSON response.

Can someone help me  on this issue?​​
Created a custom object, everything looked fine in the sandbox, went through the deployment steps and looks like only my custome object and the tab came through but not the custom fields or the page layout even though I made sure to include all custom objects and it is showing that it successfully deployed. Any ideas?

User-added image
Yo Team,

I'm new to the apex development and really confuse how to use contructor in the Class. So I look other Sr.developer's code and mimic the apex class, I'm so lucky that works. But turn to Test, I kind stuck there. Following is my Apex class and test class(not working) I created, I truely appriate that if anyone could give me some advises.

Apex Class:

public class HouseholdpageController {
    List<Account> accounts;
    public Lead currentlead{get;set;}
    public ApexPages.StandardSetController stdCntrlr {get; set;}
    public HouseholdpageController (ApexPages.StandardController controller)
    this.currentlead = (Lead)controller.getRecord(); 
    public List<Account> getAccounts(){
        currentlead = [ Select Id, Equifax_Household_ID__c from Lead where Id =: ApexPages.currentPage().getParameters().get('Id') ];
        if(currentlead.Equifax_Household_ID__c != null) accounts = [select name, Loan_Balance__c, Deposit_Balance__c from account where Equifax_Household_ID__c =: currentlead.Equifax_Household_ID__c];
        return accounts;


Test Class(Error:System.QueryException: List has no rows for assignment to SObject)
 * This class contains unit tests for validating the behavior of Apex classes
 * and triggers.
 * Unit tests are class methods that verify whether a particular piece
 * of code is working properly. Unit test methods take no arguments,
 * commit no data to the database, and are flagged with the testMethod
 * keyword in the method definition.
 * All test methods in an organization are executed whenever Apex code is deployed
 * to a production organization to confirm correctness, ensure code
 * coverage, and prevent regressions. All Apex classes are
 * required to have at least 75% code coverage in order to be deployed
 * to a production organization. In addition, all triggers must have some code coverage.
 * The @isTest class annotation indicates this class only contains test
 * methods. Classes defined with the @isTest annotation do not count against
 * the organization size limit for all Apex scripts.
 * See the Apex Language Reference for more information about Testing and Code Coverage.
private class HouseholdpageControllerTest {
    static testMethod void UnitTest() {
        RecordType rt = [SELECT Id,Name FROM RecordType WHERE SobjectType='Account' AND Name = 'Person Account'];   
        RecordType lead = [select Id from RecordType where DeveloperName = 'Relationship_Expansion_Leads']; 
        Profile p = [
            select Id
            from Profile
            where Name = 'System Administrator'
        User u = new User(
            Alias = 'standt',
            Email = 'standarduser@testorg.com',
            EmailEncodingKey = 'UTF-8',
            LastName = 'Testing',
            LanguageLocaleKey = 'en_US',
            LocaleSidKey = 'en_US',
            ProfileId = p.Id,
            TimeZoneSidKey = 'America/Los_Angeles',
        Account testAccount1 = new Account(       
          FirstName='Test Description', 
          LastName='Test Last Name',
          RecordTypeId = rt.Id,
        Equifax_Household_ID__c = '123',
        Loan_Balance__c = 321,
        Deposit_Balance__c  = 456
        Lead testLead1 = new Lead(
            LastName = 'TEST Name 1',
            status = 'Open',
            Phone = '5165039576',
            Email = '1@1.com',
            Classification__c = 'Consumer',
            RecordTypeId = lead.Id,
            Equifax_Household_ID__c = '123'
            List<Account> results;
            System.runAs(u) {
                insert testLead1;
                insert testAccount1;
            HouseholdpageController ctrl = new HouseholdpageController(new ApexPages.StandardController(testLead1));
            results = ctrl.getAccounts();

Jason Liu
Hi Everyone,
I have a requirement to display different fieldsets after rerender based on its respective picklist value selection by user in the field called Request Type.
After clicking save(saverequest custom method to save records) one record in Case Object and one in Custom Obj (Functional_Request__c) should be created along with an attached document(document should go into document object),now my records are saving in objects but i am unable to provide upload and download  functionality to my webforms.

Note: The upload option shoud be enabled/available to users only for the 1st Select option and download option for the 3rd option out of 3 options and currently there are unused variable and methods in the cotroller, i left it in as they are,thought it gets easier for anyone of you to help me.
Sample Web form

I have tried the steps from below links but no luck,i wonder it is because i have custom save method to save records and may not be close to my use case.

Help will be highly appreciated.

VF Page code:

                         <apex:actionRegion >
                            <apex:selectList label="Request Type" value="{!RequestValue}" size="1" multiselect="false">
                                    <apex:actionSupport event="onchange"  reRender="fieldSet"/>
                                    <apex:actionstatus startText="Applying Values.............">                   
                                     <apex:selectOption itemLabel="Provide Access Request" itemValue="Provide_Access_Request"></apex:selectOption
                                     <apex:selectOption itemLabel="Other" itemValue="Other"></apex:selectOption>
                                     <apex:selectOption itemLabel="Package Request" itemValue="Package_Request"></apex:selectOption> 

          <apex:commandButton action="{!saveRequest}" value="Submit" styleClass="js-save-button button green submitButton" />
          <apex:commandButton action="{!Cancel}" value="Cancel" styleClass="js-save-button button green submitButton" />


Public without sharing class  Provisional_Request_ctrl extends WSitesController


    /*Public Variables*/
    Public Functional_Request__c FormExtn {get;set;}
    Public List<Functional_Request__c> licaseformextn;// {get;set;}
    Public Map<string,Functional_Request__c> caseformmap;// {get;set;}
    Public Case Ocase; //{get;set;} 
    Public List<RecordType> OcaseRecordType;// {get;set;}
    public String recordType {get;set;}
    public String requesttype {get;set;}
    public String additionalcomments;//{get;set;} 
    public List<RecordType> ProvisionalRecordtypes {get; set;}
    public List<SelectOption> orecordtypes {get; set;}
    Public string iscentraloginisuue{get;set;}
    Functional_Request__c str;
    Public Document doc {get;set;}
    public List<String> docIdList = new List<string>();
    public boolean addAttachment{get; set;}
    public string setpopdisplay{get;set;}
    public List<Document> selectedDocumentList {get;set;}
    /* Error Message related variables */
    public boolean pageError {get; set;}
    public boolean showlist{get; set;}
    public boolean RenderFunction{get; set;}
    public boolean RenderFieldSetBlock{get; set;}
    public String pageErrorMessage {get; set;}
    public string formname{get;set;}
    Public Map<string,Id> caseformextrecordtypeMap{get;set;}
    public boolean displayPopup{get; set;}
    Public string contactemailid{get;set;}
    public boolean fileUpload{get;set;}
    public string RequestValue{get; set;}
    Public Provisional_Request_ctrl(){
      //Create New Record in Functional Request Obj Object      
        FormExtn = new Functional_Request__c ();
        caseformmap =  new Map<string,Functional_Request__c> ();
        Ocase = new case();        
        doc = new Document();
        doc = null;
       // UploadedDocumentList = new List<AttachmentsWrapper>();
        showlist = false;
        RenderFieldSetBlock = false;
        requesttype = 'None';
        iscentraloginisuue = 'false';
        RenderFunction = true;
        displayPopup = true;
        contactemailid = '';
        addAttachment = false;
        setpopdisplay = ''; 
   public pagereference Cancel()
        pageReference pg=new PageReference('https://domain.visual.force.com/apex/FRS_Request');
        return pg;
   // Get record types for  request forms and display in 'Request type'.
    Public void getfields(){
           RenderFunction = false;
           requesttype = apexpages.currentpage().getparameters().get('Param1');
           requesttype = EncodingUtil.urlDecode(requesttype, 'UTF-8');
           FormExtn.TDR_Request_Type__c = requesttype ;   
           DlccategorySelection = '';
           system.debug('12784563' + requesttype);
           if(requesttype != 'None'){
               requesttype=requesttype.replace(' ','_').replace('(' , '').replace(')' , '').replace(',' , '_').replace('-' , '_').replace('/' , '_').replace('.' , '');
           if(requesttype.length() > 41){
             requesttype = requesttype.substring(0,40);
             system.debug('@@@@@@@@@@@@' + requesttype );
              requesttype= requesttype.removeEnd('_');
   // saverequest method is to save the request.
    Public PageReference saveRequest(){
         pageError = false;
         pageErrorMessage = '';
        // If there is no validation error save the request.
          if(pageError == false){  
              RecordType rectype = new RecordType();
             string recrdtname; 
             if( RequestValue=='Provide_Access_Request')//referring fieldsets
                         FormExtn.RecordTypeId = System.Label.Provide_Access_Request; //custom labels which has record typeIds in its value field
             if( RequestValue=='Other')
                        FormExtn.RecordTypeId = System.Label.Other; 
                        fileUpload = true;
             if( RequestValue=='Package_Request')
                         FormExtn.RecordTypeId = System.Label.Package_Request; 
        //Insert Case
              Ocase = new case();
              Ocase.Status    = 'New';
              Ocase.Subject =  System.Label.TDR_Case_Subject;
              Ocase.Origin = System.Label.TDR_Case_Origin;
              Ocase.Description = apexpages.currentpage().getparameters().get('description') ;  
              Ocase.Contactid   = loggedInContact.id;             
              Ocase.Gen_Request_Type__c = RequestValue;
              Ocase.RecordTypeid   = System.Label.Provisional_RecordTypeId;
           // Assigning Case using Case-Assignment Rule.
             Database.DMLOptions dmlOpts = new Database.DMLOptions();
             dmlOpts.assignmentRuleHeader.assignmentRuleId= Label.Case_Assignment_Rule_Id ;
             dmlOpts.EmailHeader.TriggerUserEmail = true;
             Database.insert(Ocase, dmlOpts);
             system.debug('=========Case=======' + Ocase);
           // Insert Functional Request Obj. 
             FormExtn.Case_Form_App__c = System.Label.Case_Form_App;
             FormExtn.TDR_Employee__c  = loggedInContact.id;
             FormExtn.GEN_Case__c= Ocase.Id;
             system.debug('=========Form Extension=======' + FormExtn);
             Insert FormExtn;
             return new PageReference('/apex/AutoResponse_Page url); 
             }catch(Exception e){
             return null;
           return null;
catch(Exception ex){
 return null;


  • December 24, 2015
  • Like
  • 0
Hi ,
Can some one tell me how to delete the comment from the chatter post if the post contains specific keywords in the set.any ideas?

Hi everyone.
The code from example works only once for me.
I have method where I'm getting data from the salesforce.
public static async Task QuerySalesForceRestApi()
            ForceClient newClient = new ForceClient(instanceUrl, apiVersion, accessToken, new System.Net.Http.HttpClient());
            var contacts2 = await newClient.QueryAsync<Account>("SELECT  Name From Account");

This method works perfect when I'm try to get data at a first time. The same method not working when I'm try to get data after few seconds. I'm getting error System.NullReferenceException in this line.
var contacts2 = await newClient.QueryAsync<Account>("SELECT  Name From Account");
I've checked that newClient is created properly.
Why this code not working twice?