• IvanWu
  • NEWBIE
  • 30 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 5
    Replies
Hello,everyone

I have a queue and i have set the queue email for the queue,i want to get the queue Email via apex ,can anyone help me to resolve this problem ? any suggestions would be appreciate,thanks 

User-added image
  • February 02, 2018
  • Like
  • 0
Hello everyone ,
I created a email template ,in this email template ,i set some merge fields ,they are reference from two object 
what i want to do is using this emai template  to send email via apex ,i have tried the SingleEmailMessage  class and i know i can set the value of merge field throughout the whatid ,
the problem is that i  can only set the whatid with only one vlaue ,this means the merge fields in email template can only receive the value from one object,which will cause some merge fields without values

so ,can anybody help me to resolve this problem? anys sugguestions would be appreciate, thanks.
  • February 02, 2018
  • Like
  • 0
hello ,everyone  ,i have a batch of records and i have put them into a list ,i used the DML to insert them,i warped up the DML in the try-catch
what i want is whenever there is a exception occured ,i can catch it,  at the same time ,the program can still run and catch  the exception constantly.
is there any method ? any sugguestions would be appreciate!
  • January 26, 2018
  • Like
  • 0
hello ,guys
I have a csv file  and there are some chinese character in it ,I import it by apex code ,after import finished ,i will display the import data on a VF page ,I found that chinese characters can not display correctly ,I want to know why and how to resolve this problem .thanks in advance。
 
public with sharing class SalesforcastExcelController {
    
    public List<Sales_Forecast__c> Sales_ForecastList{get;set;}
    public Blob csvFileBody{get;set;}
    public string csvAsString{get;set;}
    public String[] csvFileLines{get;set;}
    public String operation{get;set;}
    public List<Sales_Forecast__c> Sf_importList{get;set;}
    public List<Sales_Forecast__c> Sf_DelList{get;set;}
    public List<Sales_Forecast__c> Sf_InsertList{get;set;}
    public List<Sales_Forecast__c> Sf_UpdateList{get;set;}
    public SalesforcastExcelController(){
        Sales_ForecastList=New List<Sales_Forecast__c>();
        Sf_importList=New List<Sales_Forecast__c>();
        Sf_DelList=New List<Sales_Forecast__c>();
        Sf_InsertList=New List<Sales_Forecast__c>();
        Sf_UpdateList=New List<Sales_Forecast__c>();
        csvFileLines = new String[]{};
            Date today=system.today();    
        Sales_ForecastList=[select Id,Name,OwnerId,Description__c,Foecast_Date__c,Forecast_Amount__c,IsThisMonth__c,Opportunity__c,Quantity__c,Product_Portfolio_Package_Series__c,Unit_Price__c from Sales_Forecast__c where  Foecast_Date__c<today];
    }
    
    public PageReference  ExportExcel(){
        
        return new PageReference('/apex/MQ_ExportPage');
    }
    public PageReference  ImportExcel(){
        
        return new PageReference('/apex/MQ_ImportPage');
    }
    
    public void importCSVFile(){
        try{
            Sf_importList.clear();
            Sf_DelList.clear();
            Sf_UpdateList.clear();
            HttpRequest request = new HttpRequest();
            request.setBodyAsBlob(csvFileBody);
            csvAsString = request.getBody();
            //csvAsString =csvFileBody.toString();
            csvFileLines = csvAsString.split('\n');             
            for(Integer i=1;i<csvFileLines.size();i++){
                Sales_Forecast__c Sales_Forecast = new Sales_Forecast__c();
                string[] csvRecordData = csvFileLines[i].split(',');
                
                if(String.isNotBlank(csvRecordData[0])){
                    Sales_Forecast.Id=csvRecordData[0];
                }            
                Sales_Forecast.Name__c = csvRecordData[1]; 
                Sales_Forecast.OwnerId=csvRecordData[2];
                Sales_Forecast.Product_Portfolio_Package_Series__c=csvRecordData[4];
                if(String.isNotBlank(csvRecordData[5])){
                    Sales_Forecast.Quantity__c=Decimal.valueOf(csvRecordData[5]);
                }
                
                if(csvRecordData[6].contains('/') ){
                    csvRecordData[6]=csvRecordData[6].replace('/','-');
                }
                Sales_Forecast.Foecast_Date__c =date.parse(csvRecordData[6]);
                Sales_Forecast.Description__c=csvRecordData[7];
                if(String.isNotBlank(csvRecordData[8])){
                    Sales_Forecast.Unit_Price__c=Decimal.valueOf(csvRecordData[8]);
                }
                Sales_Forecast.Opportunity__c = csvRecordData[9]; 
                if(String.isNotBlank(csvRecordData[11])){
                    Sales_Forecast.Forecast_Amount__c = Decimal.valueOf(csvRecordData[11]);
                }
                String tempOperation=csvRecordData[12];
                tempOperation=tempOperation.toUpperCase();  
                if(tempOperation=='DEL'){
                    Sf_DelList.add(Sales_Forecast);
                    operation='删除';                    
                }else{
                    if(tempOperation=='ADD'){
                        operation='新增';
                    }else{
                        operation='修改';
                    }
                    Sf_UpdateList.add(Sales_Forecast);
                    
                }
                Sales_Forecast.Operation__c=operation;
                Sf_importList.add(Sales_Forecast);
            }

        }
        catch (Exception e)
        {
            ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR,e.getMessage());
            ApexPages.addMessage(errorMessage);
        }  
    }
    public void RecordHandle(){
        try{
            delete Sf_DelList;
            upsert Sf_UpdateList;
            Sf_DelList.clear();
            Sf_UpdateList.clear();
            ApexPages.Message SuccessMessage = new ApexPages.Message(ApexPages.severity.CONFIRM,'导入成功!');
            ApexPages.addMessage(SuccessMessage);            
        }
        catch(Exception e)
        {
            ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR,e.getMessage());
            ApexPages.addMessage(errorMessage);
        }
    }
    
}

 
  • January 19, 2018
  • Like
  • 0
How to check whether two users are in the same queue in apex trigger?
  • January 08, 2018
  • Like
  • 0

I am trying to do a OAuth2 login with java to connect salesforce,when i send the post request to this url :https://login.salesforce.com/services/oauth2/token 

an error occured:
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

does anybody meet this problem before? who can help me to solve this problem ,thanks a lot in advance
  • August 08, 2017
  • Like
  • 0
How to check whether two users are in the same queue in apex trigger?
  • January 08, 2018
  • Like
  • 0

I am trying to do a OAuth2 login with java to connect salesforce,when i send the post request to this url :https://login.salesforce.com/services/oauth2/token 

an error occured:
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

does anybody meet this problem before? who can help me to solve this problem ,thanks a lot in advance
  • August 08, 2017
  • Like
  • 0
BLOB is not a valid UTF-8 string' error

Hi to all.

 

I'm trying to build a loader for csv file. As you can see from the code I load my csv file in an attachment. After I take the body of the attachment and insert it into a string using the toString (). I noticed that when in the csv file there is the € symbol I get an exception of type 'BLOB is not a valid UTF-8 string'. Do you have any suggestion?

 

My Controller

public with sharing class DocumentwithEuroController {

	public Attachment document {
			get {
				if (document == null)
					document = new Attachment();
				return document;
			}
			set;
		}
		
		
	public PageReference checkFile() {
		
		
		String fileBody = '';
		
		try{
			fileBody = document.body.toString();
			system.debug(fileBody);
		}catch(exception e){
			if(e.getmessage() == 'BLOB is not a valid UTF-8 string'){
			
				ApexPages.addMessage(new ApexPages.message(ApexPages.severity.WARNING, 'In the csv file there are stressed symbols. The upload is blocked'));	
			
			}
		}
		
		
		
		return null;
	}	

	
	

}

 

My page.

 

<apex:page controller="DocumentwithEuroController" >
 
<apex:form >

<apex:pageMessages id="pms1" />

<label for="ifl"
						style="text-align: left; font-weight: bold; padding-right: 0.69em;">Selezionare
					il file tracciato(.csv):</label>
					<apex:inputFile id="ifl" value="{!document.body}"
						filename="{!document.name}" styleclass="btn" />
						<apex:commandButton value="Load csv" action="{!checkFile}"
				status="loadCsv" />

</apex:form>

</apex:page>

 

For me is very important, i must resolve this proble by tomorrow 


Tanks to all,

 

FP

Hi all

 

when I uplaod csv file Iam getting the above error .

anybody help me

 

System.StringException: BLOB is not a valid UTF-8 string