+ Start a Discussion
Rami HawlyRami Hawly 

Hello,

Did anyone else notice that the view state limit in Visualforce pages has been increased from 135 to 170 KB in the new release of Spring 2019

Best Answer chosen by Rami Hawly
DevADSDevADS
That's correct. With Spring'19 release the limit is increased from 135 KB to 170 KB.

Reference - https://releasenotes.docs.salesforce.com/en-us/spring19/release-notes/rn_vf_view_state_limit.htm
Sammy7Sammy7 
Hi, 
 Im getting the following error and cannot figure out why: 

System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_EMAIL_ADDRESS, Email address is invalid: null: [toAddresses, null]

Class.email_class.send: line 48, column 1
Class.TestquoteEmailclass.sendEmailTestMethod: line 47, column 1

Below is my test class: 
@isTest
public class TestquoteEmailclass {
    @isTest static void sendEmailTestMethod(){
    
        Product2 prod = new Product2(Name = 'SLA: Bronze', IsActive = true);
        insert prod;
        PricebookEntry pbe=new PricebookEntry(unitprice=0.01,Product2Id=prod.Id, Pricebook2Id=Test.getStandardPricebookId(), IsActive= true); 
        insert pbe; 
        Account acc = new Account (name='Acme');
        insert acc;
        Opportunity opp= new Opportunity (name='Testopp', Accountid=acc.id, CloseDate= date.today(), StageName='Closed Won', Pricebook2id=Test.getStandardPricebookId());
        insert opp; 
        OpportunityLineItem oppLine = new OpportunityLineItem( pricebookentryid=pbe.Id,TotalPrice=2000, Quantity = 2,Opportunityid = opp.Id);
        insert oppLine;       
        Quote q= new Quote (Name='Testq', Opportunityid=opp.id, QuotetoInvoice__c= True,  Pricebook2id=Test.getStandardPricebookId());
        insert q;
    
     System.currentPagereference().getParameters().put('id',q.id);
     Attachment objAtt = new Attachment();
     objAtt.Name = 'Test';
     objAtt.body = Blob.valueof('string');
     objAtt.ParentId = q.Id;
     insert objAtt;

         ApexPages.StandardController sc =new ApexPages.StandardController(q); 
        email_class ec=new email_class (sc);
        ec.ToAddresses='test@gmail.com';
         ec.CCAddresses='test2@gmail.com';
        ec.emailCC= 'test3@gmail.com';
        ec.email_body='test1111111';
        ec.subject='test22222';
        
         Messaging.InboundEmail email = new Messaging.InboundEmail();  
         Messaging.InboundEnvelope env = new Messaging.InboundEnvelope();
        email.plainTextBody = 'This should become a note';
        email.fromAddress ='test@test.com';
        String contactEmail = 'jsmith@salesforce.com';
        email.ccAddresses = new String[] {'Jon Smith <' + contactEmail + '>'};
        email.subject = 'Dummy Account Name 123';

        ec.send();

}
}

And my controller:
public class email_class{
        
    Public string ToAddresses {get;set;}
    Public string CCAddresses {get;set;}
    Public string quoteId {get;set;}
    Public string subject {get;set;}
    public string email_body {get;set;}
    public string emailTo {get;set;}
    public string emailCC {get;set;}
     public  string [] ccaddress;   
              
        
        
        public email_class(ApexPages.StandardController controller) {
                quoteId = ApexPages.currentPage().getParameters().get('id');
    }
        
    Public PageReference send(){

                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); // set the to address
                mail.setToAddresses(new String[] {emailTo}); 
               // mail.setCCAddresses(new String[] {emailCC});   //set the cc address
                   
        if(emailCC != null && emailCC.trim() != '')
        {
        ccaddress = emailCC.split(',',0);
        mail.setCCAddresses(ccaddress);}
                                                              
   
                mail.setSubject(subject);
                mail.setBccSender(false);
                mail.setUseSignature(false);
                mail.setPlainTextBody(email_body);
               

                List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>();

                for (Attachment a : [select Name, Body, BodyLength from Attachment where ParentId = :quoteId]){  // Add to attachment file list  
                        Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();  
                        efa.setFileName(a.Name); 
                        efa.setBody(a.Body); 
                        fileAttachments.add(efa);
                }
                mail.setFileAttachments(fileAttachments);// Send email
                Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
                return null;
        }
}

Any help is appreciated !
Best Answer chosen by Sammy7
Sammy7Sammy7
Forgot to pass "emailTo" DOH !
Sheetal Sonawane 19Sheetal Sonawane 19 
I tried adding visualforce page as tab in lightning app builder and I have also used standard controller in VF page but still I am gettinng error visualforce page not found
Please help.
Thank you in advance.
Best Answer chosen by Sheetal Sonawane 19
saket kole 15saket kole 15
Hi Sheetal,

You must enable "Available for Lightning Experience, Lightning Communities, and the mobile app" for a Visualforce page to make it available in the Lightning App Builder.

To enable "Available for Lightning Experience" please follow below steps.

Click setup -- enter Visualforce Pages in Quick find and click on Visualforce Pages

1) Then edit your Visualforce Page and enable "Available for Lightning Experience, Lightning Communities, and the mobile app" by clicking on checkbox.

User-added image


2) Add Standard controller and make Lightning stylesheet true in your visualforce eg.<apex:page standardController="Object Name(custom/standard)" extensions="ext1..">

Now Visualforce page available in components of Lightning App Builder.



 
Dharmendra KaramchandaniDharmendra Karamchandani 

Hi Team,

Not able to verify the step 5 of the BUSINESS ADMINISTRATION SPECIALIST SUPERBADGE because of the following error:
Challenge Not yet complete... here's what's wrong:&nbsp; Unwanted fields are still present in the 'Residential Opportunity Page' layout.

I cloned the Utility layout as "Residential Opportunity Page" and modified as per the requirement but still facing the same issue.

Please share some details regarding this, your support will be very helpful for me.

Thanks!
Best Answer chosen by Dharmendra Karamchandani
NagendraNagendra (Salesforce Developers) 
Hi Dharmendra,

First,  let’s create a new Sales Process and keep only required values.
User-added image
Now, copy the existing Opportunity Page layout and call it Residential Opportunity Page, delete the fields specified in the instructions and add the Quantity field. Don’t forget to save it.
User-added image
As next step, navigate to Compact Layouts section, click on New button and create a new Opportunity Compact Layout.
User-added image
Create a new Record Type. Assign it only to Custom: Sales Profile and System Administrator profiles.
User-added image
Lastly, assign the new record type to the profiles (don’t forget page layout assignments too).
User-added image
Aha! That’s that. Now check the fifth challenge and move on to the last one. I can almost see the new badge on your Trailhead profile.

Hope this helps you with the above challenge.

May I request you please mark this as solved if the information was helpful so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.

Thanks,
Nagendra
Stevie Burt 7Stevie Burt 7 
I am stuck on Step 4 of the Process Automation Specialist Superbadge. I am receiving the following error:
Challenge Not yet complete... here's what's wrong: 
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: GTJRSNVZ

Here are the Challenge Requirements: 
Create Sales Process and Validate Opportunities
Create a sales process with the required stages and name it RB Robotics Sales Process. Create a record type named RB Robotics Process RT. Add a field to the opportunity page layout as described in the business requirements and create the appropriate validation rule for high-value opportunities.

Hey, nice work on the setup records! Now let’s talk about our sales process. Most of the stages we use are already in Salesforce, but one of the stages we track doesn’t come standard so it would be great if you’d add it. These are the stages we use:  Prospecting, Qualification, Proposal/Price Quote, Negotiation/Review, Awaiting Approval, Closed Won, and Closed Lost. We want all our reps to follow the same process, so everyone should see those stages for every opportunity. 
Oh, and the biggest deals--anything over $100K--have to be approved before they can close. We should have a way to show on the record that the deal is approved--maybe you can add an “Approved” checkbox to the opportunity. Obviously the sales reps shouldn’t be able to check that box. Only system administrators like you and sales managers should be able to check it. By the way, all of us sales managers here have the Custom: Sales Profile in Salesforce.

I have created the following:
  1. Created a new Opportunity Stage: Awaiting Approval (Open, 95%, Pipeline)
  2. Created the following Opportunity Fields:
    1. Approved (Checkbox) Defaulted FALSE
  3. Sales Process:
    1. NAMED: RB Robotics Sales Process
    2. Stages Added:
      1. Prospecting (Open, 10%, Pipeline)
      2. Qualification (Open, 10%, Pipeline)
      3. Proposal/Price Quote (Open, 75%, Pipeline)
      4. Negotiation/Review (Open, 90%, Pipeline)
      5. Awaiting Approval (Open, 95%, Pipeline)
      6. Closed Won (Closed/Won, 100%, Closed)
      7. Closed Lost (Closed/Lost, 0%, Omitted)
  4. Opportunity Record Type:
    1. NAMED: RB Robotics Process RT
    2. Sales Process: RB Robotics Sales Process
    3. This is the only record type and assigned to all profiles. Also using the Opportunity Layout. 
  5. Opportunity Validation Rules:
    1. Approved_Field_Validation
      AND( 
      ISCHANGED(Approved__c), 
      OR( 
      $Profile.Name <> 'System Administrator', 
      $Profile.Name <> 'Custom: Sales Profile' 
      ) 
      )

      2. High_Value_Opportunity_Validation
      AND(
          ISCHANGED( IsClosed ),
          IsClosed = TRUE,
          Amount  > 100000,
          Approved__c  <> TRUE
          )
Im not sure what I am missing. Can anyone assist?
Best Answer chosen by Stevie Burt 7
Apoorv Shukla 8Apoorv Shukla 8
@Stevie, Remove the "ISCHANGED( IsClosed )" form your Validation Rule, I checked the Debug logs and looks like they are inserting a Opportunity with amout as "20000". and this validation rule is not passing in this case. everything else looks perfectly fine for your case.
Please mark this as Best answer if you pass Challenge 4 after this :-)
Patrick BulaczPatrick Bulacz 

Hi All,

 

Just wondering if anyone has had any experience with working around the 100000 char limit on Strings in Apex.

 

Basically am producing a large text file that needs to then be attached to a record via notes and attachments.

 

I've got a few workarounds but wondering if there are any other ideas out there.

 

Ideally I'd like to check the length of the string and if it's 'nearing' the limit convert it to a blob and add it to a list of blobs and then run a loop and add all the blobs together to create 1 large file and then attach that via notes and attachments. Obviously that can't be done because you can't just simply add blobs but that's the basic dilemma so if anyone has any suggestions please let me know.

 

My other solutions are to generate the output to a visualforce page then scrape the visualforce page but I get the ugly <Html> and </Html> tags at the beginning and the formatting is a little off (would be good to just be able to 'renderAs=text' but oh well.

 

Anyway any help is much appreciated.

 

Cheers,

 

Patrick

Best Answer chosen by Admin (Salesforce Developers) 
wesnoltewesnolte

Hey

 

What about this:

 

 

Blob myBIGblob;
for(Blob thisB:myBlobs){
// unfortunately can't do the following with binary types like you can
// with strings :(
myBIGblob.valueOf(myBIGblob.toString() + thisB.toString());
}
Ajay Anikar H RAjay Anikar H R 
All,

Debug log - Not showing any entries, i was wondering if anyone else faced similar issue before.

I can confirm the settings is correct and when i drilldown on other screen (either accounts or contacts), nothing up in the logs.
any idea ?
 
Best Answer chosen by Ajay Anikar H R
Ajay Anikar H RAjay Anikar H R
Thanks for the responses; 
No setup was changed but today the debug logs started to appear again. Not sure of the root cause either. 

Thanks again.
farah sheriffarah sherif 
the trigger should be on account to check the assets and if ALL Assets where product family = "bla bla "  and their status was "Canceled" the trigger should update bla bla Account stage (API Name = Account_Status__c )  to "Cancel".
Best Answer chosen by farah sherif
Abdul KhatriAbdul Khatri
Can you try the below
 
trigger AccountUpdateFromAssetProduct on Asset (after insert, after update) {
    
    List<Asset> assetList = Trigger.new;

	List<Id> idAccountList = new List<Id>();    
    for(Asset asset : assetList) {
        
        if(Trigger.isUpdate && asset.Product2.Family == Trigger.oldMap.get(asset.Id).Product2.Family && asset.Status == Trigger.oldMap.get(asset.Id).Status) continue;
        
        if(asset.AccountId == null) continue;
        
        idAccountList.add(asset.AccountId);
    }
    
    if(idAccountList.isEmpty()) return;
    
    List<Account> acctList = [SELECT Id, (SELECT Id FROM Assets WHERE Product2.Family = 'bla bla' AND Status = 'Canceled') FROM Account LIMIT 50];
    
    for(Account acct : acctList)
    {
        if(acct.Assets.isEmpty()) continue;
        
        acct.Account_Status__c = 'Cancel';
    }

    update acctList;
}

 
Nilesh Borse 9Nilesh Borse 9 
I am littile bit confuse about <lightnign:input /> & <ui:input /> when to use which and what differences does it makes?
 
Best Answer chosen by Nilesh Borse 9
Rahul KumarRahul Kumar (Salesforce Developers) 
Hi Nilesh,

You can find base Lightning components in the lightning namespace to complement the existing ui namespace components. In instances where there are matching ui and lightning namespace components, we recommend that you use the lightning namespace component. The lightning namespace components are optimized for common use cases. Beyond being equipped with the Lightning Design System styling, they handle accessibility, real-time interaction, and enhanced error messages.

Please refer the below link for reference. hope it will help.

Please mark it as best answer if the information is informative.so that question is removed from an unanswered question and appear as a proper solution.

Thanks
Rahul Kumar
Amit Singh1989Amit Singh1989 

Hi friend,

i have created an visualforce page where i have used <apex:inputFile /> to take any CSV file as input

then i am displaying that CSV file's data into the same vf page in tabular format...

 

but i want that selected CSV's data should be displayed in another vf page. (so by setting attribute renderas="pdf" i can view CSV's data in a PDF format)

 

 

how can i do this?

 

 

here is my code...

 

<apex:page controller="uploadCSVcontroller">
  <apex:form >
  <apex:pageMessages id="pm"/>
  <apex:inputFile value="{!contentFile}" filename="{!nameFile}"/>
  <apex:commandButton value="Display" id="theButton"/>  
  
  
  
  <apex:pageBlock >
  <apex:outputPanel id="results">
  <p>nameFile: {!nameFile}</p>
  <p>rowCount: {!rowCount}</p>
  <p>colCount: {!colCount}</p>
    <table title="CSV Output" border="1" width="100%">
       <apex:repeat value="{!results}" var="row">
           <tr>
               <apex:repeat value="{!row}" var="cell">
                   <td> {!cell} </td>
               </apex:repeat>
           </tr>
       </apex:repeat>
     </table>
  </apex:outputPanel>
  </apex:pageBlock>
  </apex:form>
</apex:page>







Controller


public class uploadCSVcontroller 
  {

    public Blob contentFile { get; set; }
    public String nameFile { get; set; }
    public Integer rowCount { get; set; }
    public Integer colCount { get; set; }
    
    public List<List<String>> getResults() 
    {
        List<List<String>> parsedCSV = new List<List<String>>();
        rowCount = 0;
        colCount = 0;
        if (contentFile != null)
        {
            String fileString = contentFile.toString();
            parsedCSV = parseCSV(fileString, False);
            rowCount = parsedCSV.size();
            for (List<String> row : parsedCSV)
            {
                if (row.size() > colCount)
                {
                    colCount = row.size();
                }
            }
        }
        return parsedCSV;
    }
    
    public Pagereference CreatePDF()
     {
      pagereference pr = new pagereference('/apex/FinalReport1');
      pr.setredirect(true);
      return pr;
     }
    
    public static List<List<String>> parseCSV(String contents,Boolean skipHeaders) 
     {
        List<List<String>> allFields = new List<List<String>>();
        contents = contents.replaceAll(',"""',',"DBLQT').replaceall('""",','DBLQT",');
        contents = contents.replaceAll('""','DBLQT');
        List<String> lines = new List<String>();
        try 
        {
          lines = contents.split('\r'); // using carriage return accomodates windows, unix, and mac files
        }
        catch (System.ListException e) 
        {
            System.debug('Limits exceeded?' + e.getMessage());
        }
        Integer num = 0;
        for(String line: lines) 
        {
           if (line.replaceAll(',','').trim().length() == 0) break;
            List<String> fields = line.split(',');  
            List<String> cleanFields = new List<String>();
            String compositeField;
            Boolean makeCompositeField = false;
            for(String field: fields) 
            {
                if (field.startsWith('"') && field.endsWith('"')) 
                {
                    cleanFields.add(field.replaceAll('DBLQT','"'));
                }
                else if (field.startsWith('"')) 
                {
                    makeCompositeField = true;
                    compositeField = field;
                }
                else if (field.endsWith('"')) 
                {
                    compositeField += ',' + field;
                    cleanFields.add(compositeField.replaceAll('DBLQT','"'));
                    makeCompositeField = false;
                }
                else if (makeCompositeField) 
                {
                    compositeField +=  ',' + field;
                }
                else
                {
                    cleanFields.add(field.replaceAll('DBLQT','"'));
                }
            }
            
            allFields.add(cleanFields);
        }
        if (skipHeaders) allFields.remove(0);
        return allFields;       
     }

}

 

 

 

Thanks,

Amit Singh

Best Answer chosen by Admin (Salesforce Developers) 
abivenkatabivenkat

 

hi amit singh1989,

 

Better read the CSV file and store in the document object in first VF page. give a button as "View and Convert to PDF" in the first VF Page. 

 

When clicking the button, just redirect them to the second VF page and just show the content of the CSV page by querying the file from the Document object and put "RenderAs" attribute in that page itself.

 

What i think is, upload the file and show the content in the first page itself and provide a button as "Convert to PDF". while clicking the button, u just redirect to the second page. in that second page controller class, retrieve the same CSV file and convert to PDF by adding the "RenderAs" attribute in the second page. 

 

Accept as solution if u find this post is useful for you..

 

Thanks,

abivenkat.