• Andrea Bruman
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 3
    Questions
  • 10
    Replies
I am trying to bold the word "eligible".
So far I have this:
<apex:pageBlockSection title="S Assistance" columns="1">
<apex:outputLabel value="They would like to give eligible requirements, etc."/>
<apex:outputField value="{!app.S_Assistance_Requested__c}" />
</apex:pageBlockSection>

I've tried this:
<apex:pageBlockSection title="S Assistance" columns="1">
<apex:outputLabel value="They would like to give <b>eligible</b> requirements, etc."/>
<apex:outputField value="{!app.S_Assistance_Requested__c}" />
</apex:pageBlockSection>

Not sure how to do this.  Please assist.
 
Hi,
I am trying to validate a phone number contains 10 numbers.  Salesforce reformats the number to include the parentheses and hyphen.  Here is what I have so far
if (newCase.NOI_Primary_Contact_Phone_Number__c <> null && newCase.NOI_Primary_Contact_Phone_Number__c <> '')
            {
                String strP = newCase.NOI_Primary_Contact_Phone_Number__c.trim();
                Pattern pceP = Pattern.compile('^(?=.*?[1-9])[0-9()-]+$');
                
                Matcher mceP = pceP.matcher(strP);
                if (mceP.matches() == false)                   
                {
                    isValid = false;
                    chkPhone = true;
                }
            }
It is not working for a phone number format that should work, example- (789) 456-1230
Help!
 
Hello,
I am getting this error when I click on the save button (visualforce page) can any body suggest me with this error.

List has no rows for assignment to SObject 
My Controller code
/**
* Revision History
*
* 05/23/2018  Andie - Created. This class controls the logic for creating Case from a web form for Logo Request.
* 05/25/2018  Sanjeev - Added the Files section and the validations.
*
*/
public with sharing class LogoRequestWebToCaseController {
    
    public Case newCase {get; set;}
    public String strCaseNumber {get; private set;} 
    public String siteurl{get;set;}
    public String Confirm_Email{get; set;}
    public Boolean reqFields = false;
    public Boolean chkEmail = false;
    
    
    public Blob file {get; set;}
    
    public LogoRequestWebToCaseController()
    {
        newCase = new Case();
        siteurl = Url.getSalesforceBaseUrl().toExternalForm();   
        siteurl =  siteurl+'/LogoRequest';
    }
    
    public void saveCase()
    {
        try
        {            
            if(validateFieldsOnSubmit())
            {              
                if(newCase.Id == null)
                {
                    //newCase.RecordTypeId = Schema.SObjectType.Case.getRecordTypeInfosByName().get('Marketing Logo Request').getRecordTypeId();
                    RecordType caseRT = [Select SobjectType, Name, Id From RecordType where SobjectType = :'Case' and Name = :'Marketing Logo Request'];
                    newCase.RecordTypeId = caseRT.Id;
                    //newCase.RecordTypeId = [SELECT Id FROM RecordType WHERE DeveloperName = 'Marketing_Logo_Request' limit 1].Id;
                    newCase.OwnerId = [SELECT Id FROM Group WHERE Type = 'Queue' AND NAME = 'Marketing Logo Request'].Id;
                    //newCase.Status = 'New';
                    System.Debug('if(newCase.Id == null)');
                }
                
                upsert newCase;
                //insert newCase;
                
                if(String.isBlank(strCaseNumber))
                    strCaseNumber = [SELECT CaseNumber FROM Case WHERE Id = :newCase.Id].CaseNumber;
                    System.Debug('if(String.isBlank(strCaseNumber))');
            }
            else
            {
                if(reqFields)                      
                    ApexPages.addMessage(new ApexPages.Message( ApexPages.severity.ERROR,'Please review that you have completed all fields below'));                                         

                else if(chkEmail)
                    ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.ERROR,'Please enter a valid Email Address.'));                         
            }
        }
        
        catch (Exception e) 
        {
            System.Debug('Catch');
            ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.ERROR,e.getMessage()));                    
        }
        
    }
    
    public void submitCase()
    {
        if(validateFieldsOnSubmit())
        {
            Integer intAttachmentCount = (getAttachmentList()).size();
            if((newCase.Logo_Use__c == 'Label (Food Only)' && intAttachmentCount < 2) || (newCase.Logo_Use__c != 'Label (Food Only)' && intAttachmentCount < 1))
            {
                ApexPages.addMessage(new ApexPages.Message( ApexPages.severity.ERROR,'Please attach all necessary attachments before case can be submitted.'));
                return;
            }
                
            newCase.Status = 'Submitted';
            update newCase;
        }
    }
    
    public PageReference cancelCase() 
    {
        siteurl = Url.getSalesforceBaseUrl().toExternalForm();   
        siteurl =  siteurl+'/LogoRequest'; 
        
        PageReference redirect = new PageReference(siteurl); 
        redirect.setRedirect(true);
        return redirect;
    }
    
    private Boolean validateFieldsOnSubmit() // Validates the Required Fields
    {
        file = null;
        Boolean isValid = true;
        reqFields = false;
        chkEmail = false;
        if(newCase.NOI_Primary_Contact_Name__c =='' || newCase.NOI_Primary_Contact_Name__c == null 
            || newCase.Industry__c == '' 
            || newCase.Industry__c == null 
            || Confirm_email == '' || Confirm_email == null 
            || newCase.NOI_Primary_Contact_Phone_Number__c == '' || newCase.NOI_Primary_Contact_Phone_Number__c == null 
            || newCase.NOI_Company_Name__c == '' || newCase.NOI_Company_Name__c == null  
            || newCase.Organization_Website__c == '' || newCase.Organization_Website__c == null 
            || newCase.Logo_Use__c == '' || newCase.Logo_Use__c == null 
            || newCase.Description == '' || newCase.Description == null 
            || newCase.Michigan_Headquarters__c == '' || newCase.Michigan_Headquarters__c == null 
            || newCase.MEDC_Affiliated__c == '' || newCase.MEDC_Affiliated__c == null 
            || newCase.Working_with_MEDC_Employee__c == null || newCase.Working_with_MEDC_Employee__c == null 
            || newCase.Target_Market__c == '' || newCase.Target_Market__c == null 
            || newCase.This_request_is_for__c == '' || newCase.This_request_is_for__c == null 
            || newCase.Hope_to_gain_with_Logo__c == '' || newCase.Hope_to_gain_with_Logo__c == null)
        {
            isValid = false;
            reqFields = true;
        }
        
        else
        {
            if (newCase.NOI_Primary_Contact_E_Mail__c <> null && newCase.NOI_Primary_Contact_E_Mail__c <> '')
            {
                String strE = newCase.NOI_Primary_Contact_E_Mail__c.trim();
                Pattern pce = Pattern.compile('[a-zA-Z0-9\\.\\!\\#\\$\\%\\&\\*\\/\\=\\?\\^\\_\\+\\-\\`\\{\\|\\}\\~\'._%+-]+@[a-zA-Z0-9\\-.-]+\\.[a-zA-Z]+');
                
                Matcher mce = pce.matcher(strE);
                if (mce.matches() == false)                   
                {
                    isValid = false;
                    chkEmail = true;
                }
            }
        }
        if (newCase.Michigan_Headquarters__c != null && newCase.Michigan_Headquarters__c.equalsIgnoreCase('No'))
            {
                if(newCase.Michigan_Connection__c =='' || newCase.Michigan_Connection__c== null)
                {
                    isValid = false;
                    reqFields = true;
                }
            }
        if (newCase.MEDC_Affiliated__c != null && newCase.MEDC_Affiliated__c.equalsIgnoreCase('Yes'))
            {
                if(newCase.MEDC_Program__c =='' || newCase.MEDC_Program__c== null)
                {
                    isValid = false;
                    reqFields = true;
                }
            }
        if (newCase.Working_with_MEDC_Employee__c != null && newCase.Working_with_MEDC_Employee__c.equalsIgnoreCase('Yes'))
            {
                if(newCase.MEDC_Employee__c =='' || newCase.MEDC_Employee__c== null)
                {
                    isValid = false;
                    reqFields = true;
                }
            }
        if (newCase.This_request_is_for__c !=null && newCase.This_request_is_for__c == 'No' )
            {
                ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.ERROR,'Do you agree with the one year license agreement is required.'));
            }
        if (newCase.NOI_Primary_Contact_E_Mail__c != null && newCase.NOI_Primary_Contact_E_Mail__c != Confirm_email )
            {
                ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.ERROR,'Confirm Contact E-mail and Contact E-mail must contain the same e-mail address.'));
            }
        return isValid;
    }
    
    public void upload() 
    {
        if(file != null)
        {
            ContentVersion objCV = new ContentVersion();
            objCV.versionData = file;
            objCV.title = strCaseNumber + '-Logo Request Attachment';
            objCV.pathOnClient = 'file_' + Datetime.now().getTime();
            insert objCV;
            // Linking the file to the case
            insert (new ContentDocumentLink(LinkedEntityId = newCase.Id, ShareType = 'I',
                                            ContentDocumentId = [select ContentDocumentId from ContentVersion where Id =: objCV.Id].ContentDocumentId));
        }
        file = null;
    }
    
    public List<ContentDocumentLink> getAttachmentList()
    {
        return [SELECT ContentDocument.Title FROM ContentDocumentLink WHERE LinkedEntityId = :newCase.Id];
    }
}
 
I am trying to bold the word "eligible".
So far I have this:
<apex:pageBlockSection title="S Assistance" columns="1">
<apex:outputLabel value="They would like to give eligible requirements, etc."/>
<apex:outputField value="{!app.S_Assistance_Requested__c}" />
</apex:pageBlockSection>

I've tried this:
<apex:pageBlockSection title="S Assistance" columns="1">
<apex:outputLabel value="They would like to give <b>eligible</b> requirements, etc."/>
<apex:outputField value="{!app.S_Assistance_Requested__c}" />
</apex:pageBlockSection>

Not sure how to do this.  Please assist.
 
Hello,
I am getting this error when I click on the save button (visualforce page) can any body suggest me with this error.

List has no rows for assignment to SObject 
My Controller code
/**
* Revision History
*
* 05/23/2018  Andie - Created. This class controls the logic for creating Case from a web form for Logo Request.
* 05/25/2018  Sanjeev - Added the Files section and the validations.
*
*/
public with sharing class LogoRequestWebToCaseController {
    
    public Case newCase {get; set;}
    public String strCaseNumber {get; private set;} 
    public String siteurl{get;set;}
    public String Confirm_Email{get; set;}
    public Boolean reqFields = false;
    public Boolean chkEmail = false;
    
    
    public Blob file {get; set;}
    
    public LogoRequestWebToCaseController()
    {
        newCase = new Case();
        siteurl = Url.getSalesforceBaseUrl().toExternalForm();   
        siteurl =  siteurl+'/LogoRequest';
    }
    
    public void saveCase()
    {
        try
        {            
            if(validateFieldsOnSubmit())
            {              
                if(newCase.Id == null)
                {
                    //newCase.RecordTypeId = Schema.SObjectType.Case.getRecordTypeInfosByName().get('Marketing Logo Request').getRecordTypeId();
                    RecordType caseRT = [Select SobjectType, Name, Id From RecordType where SobjectType = :'Case' and Name = :'Marketing Logo Request'];
                    newCase.RecordTypeId = caseRT.Id;
                    //newCase.RecordTypeId = [SELECT Id FROM RecordType WHERE DeveloperName = 'Marketing_Logo_Request' limit 1].Id;
                    newCase.OwnerId = [SELECT Id FROM Group WHERE Type = 'Queue' AND NAME = 'Marketing Logo Request'].Id;
                    //newCase.Status = 'New';
                    System.Debug('if(newCase.Id == null)');
                }
                
                upsert newCase;
                //insert newCase;
                
                if(String.isBlank(strCaseNumber))
                    strCaseNumber = [SELECT CaseNumber FROM Case WHERE Id = :newCase.Id].CaseNumber;
                    System.Debug('if(String.isBlank(strCaseNumber))');
            }
            else
            {
                if(reqFields)                      
                    ApexPages.addMessage(new ApexPages.Message( ApexPages.severity.ERROR,'Please review that you have completed all fields below'));                                         

                else if(chkEmail)
                    ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.ERROR,'Please enter a valid Email Address.'));                         
            }
        }
        
        catch (Exception e) 
        {
            System.Debug('Catch');
            ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.ERROR,e.getMessage()));                    
        }
        
    }
    
    public void submitCase()
    {
        if(validateFieldsOnSubmit())
        {
            Integer intAttachmentCount = (getAttachmentList()).size();
            if((newCase.Logo_Use__c == 'Label (Food Only)' && intAttachmentCount < 2) || (newCase.Logo_Use__c != 'Label (Food Only)' && intAttachmentCount < 1))
            {
                ApexPages.addMessage(new ApexPages.Message( ApexPages.severity.ERROR,'Please attach all necessary attachments before case can be submitted.'));
                return;
            }
                
            newCase.Status = 'Submitted';
            update newCase;
        }
    }
    
    public PageReference cancelCase() 
    {
        siteurl = Url.getSalesforceBaseUrl().toExternalForm();   
        siteurl =  siteurl+'/LogoRequest'; 
        
        PageReference redirect = new PageReference(siteurl); 
        redirect.setRedirect(true);
        return redirect;
    }
    
    private Boolean validateFieldsOnSubmit() // Validates the Required Fields
    {
        file = null;
        Boolean isValid = true;
        reqFields = false;
        chkEmail = false;
        if(newCase.NOI_Primary_Contact_Name__c =='' || newCase.NOI_Primary_Contact_Name__c == null 
            || newCase.Industry__c == '' 
            || newCase.Industry__c == null 
            || Confirm_email == '' || Confirm_email == null 
            || newCase.NOI_Primary_Contact_Phone_Number__c == '' || newCase.NOI_Primary_Contact_Phone_Number__c == null 
            || newCase.NOI_Company_Name__c == '' || newCase.NOI_Company_Name__c == null  
            || newCase.Organization_Website__c == '' || newCase.Organization_Website__c == null 
            || newCase.Logo_Use__c == '' || newCase.Logo_Use__c == null 
            || newCase.Description == '' || newCase.Description == null 
            || newCase.Michigan_Headquarters__c == '' || newCase.Michigan_Headquarters__c == null 
            || newCase.MEDC_Affiliated__c == '' || newCase.MEDC_Affiliated__c == null 
            || newCase.Working_with_MEDC_Employee__c == null || newCase.Working_with_MEDC_Employee__c == null 
            || newCase.Target_Market__c == '' || newCase.Target_Market__c == null 
            || newCase.This_request_is_for__c == '' || newCase.This_request_is_for__c == null 
            || newCase.Hope_to_gain_with_Logo__c == '' || newCase.Hope_to_gain_with_Logo__c == null)
        {
            isValid = false;
            reqFields = true;
        }
        
        else
        {
            if (newCase.NOI_Primary_Contact_E_Mail__c <> null && newCase.NOI_Primary_Contact_E_Mail__c <> '')
            {
                String strE = newCase.NOI_Primary_Contact_E_Mail__c.trim();
                Pattern pce = Pattern.compile('[a-zA-Z0-9\\.\\!\\#\\$\\%\\&\\*\\/\\=\\?\\^\\_\\+\\-\\`\\{\\|\\}\\~\'._%+-]+@[a-zA-Z0-9\\-.-]+\\.[a-zA-Z]+');
                
                Matcher mce = pce.matcher(strE);
                if (mce.matches() == false)                   
                {
                    isValid = false;
                    chkEmail = true;
                }
            }
        }
        if (newCase.Michigan_Headquarters__c != null && newCase.Michigan_Headquarters__c.equalsIgnoreCase('No'))
            {
                if(newCase.Michigan_Connection__c =='' || newCase.Michigan_Connection__c== null)
                {
                    isValid = false;
                    reqFields = true;
                }
            }
        if (newCase.MEDC_Affiliated__c != null && newCase.MEDC_Affiliated__c.equalsIgnoreCase('Yes'))
            {
                if(newCase.MEDC_Program__c =='' || newCase.MEDC_Program__c== null)
                {
                    isValid = false;
                    reqFields = true;
                }
            }
        if (newCase.Working_with_MEDC_Employee__c != null && newCase.Working_with_MEDC_Employee__c.equalsIgnoreCase('Yes'))
            {
                if(newCase.MEDC_Employee__c =='' || newCase.MEDC_Employee__c== null)
                {
                    isValid = false;
                    reqFields = true;
                }
            }
        if (newCase.This_request_is_for__c !=null && newCase.This_request_is_for__c == 'No' )
            {
                ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.ERROR,'Do you agree with the one year license agreement is required.'));
            }
        if (newCase.NOI_Primary_Contact_E_Mail__c != null && newCase.NOI_Primary_Contact_E_Mail__c != Confirm_email )
            {
                ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.ERROR,'Confirm Contact E-mail and Contact E-mail must contain the same e-mail address.'));
            }
        return isValid;
    }
    
    public void upload() 
    {
        if(file != null)
        {
            ContentVersion objCV = new ContentVersion();
            objCV.versionData = file;
            objCV.title = strCaseNumber + '-Logo Request Attachment';
            objCV.pathOnClient = 'file_' + Datetime.now().getTime();
            insert objCV;
            // Linking the file to the case
            insert (new ContentDocumentLink(LinkedEntityId = newCase.Id, ShareType = 'I',
                                            ContentDocumentId = [select ContentDocumentId from ContentVersion where Id =: objCV.Id].ContentDocumentId));
        }
        file = null;
    }
    
    public List<ContentDocumentLink> getAttachmentList()
    {
        return [SELECT ContentDocument.Title FROM ContentDocumentLink WHERE LinkedEntityId = :newCase.Id];
    }
}
 

Hi,

 

I'm having trouble getting the "ApexPages.addMessage" message to display in my VF page when there's an error.  Below is the code in the extensions that validates the input before saving the record.  Any help would be greatly appreciated.  Thank you in advance.

 

"

...
    //
    //Save current record
    //
    public PageReference save(){
        if (validate_save_data()) {                    
            ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Invalid Input.');
            ApexPages.addMessage(myMsg);
            return null;
        } else {
            upsert erma;
            return (new ApexPages.StandardController(erma)).view();       
        }      
    }
 
    //
    // Validate input data before saving  
    //
    public boolean validate_save_data () {
        if (erma.sales_area__c == null) {
            return true;
        } else {
            return false;
        }
    }
...
"

We have Validation Rule on Street Field on Account Object. Below is the Validation Rule

AND(NOT(ISNEW()),ISCHANGED(Street),OR(CONTAINS(UPPER(Street),'P.O'),CONTAINS(UPPER(Street),'P.O.'),CONTAINS(UPPER(Street),'PO BOX'),CONTAINS(UPPER(Street),'POST BOX'),CONTAINS(UPPER(Street),'POST OFFICE'),CONTAINS(UPPER(Street),'PO.'),CONTAINS(UPPER(Street),'POBOX'),CONTAINS(UPPER(Street),'PO')))

Use Case: To Restrict the User to not to enter Any Post Box Number in the Street Field. But the above validation rule is working for all other combinations - except for 'PO'.

It is getting triggered for any Street String which contains 'po' letters in it. It should basically identify the PO word in the Street String.

 

 

  • August 21, 2018
  • Like
  • 1