• hemantgarg
  • NEWBIE
  • 445 Points
  • Member since 2010

  • Chatter
    Feed
  • 14
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 198
    Replies

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

I am getting error while running Tests 

 

  /**
      * Method that creates the test estimate object
      */
     public static Services_Estimate__c createTestEstimate(){
         Product2 prod = [SELECT ID, NAME FROM Product2 WHERE NAME = 'BASE24-eps'];
        
        Services_Demand_Management__c dm= new Services_Demand_Management__c (Name = 'MyTestEstimate',
                                  Request_Status__c = DemandManagementHelper.STATUS_NEW,
                                  Request_State__c = DemandManagementHelper.STATE_OPEN,
                                  Comments__c = 'My Desc',
                                  ACI_Product1__c = prod.Id,
                                  Request_Type__c = 'Services',
                                  Oracle_Project_Number__c = 'TP00001',
                                  Oracle_Project_Name__c = 'Test Project',                                  
                                  Request_Sub_Type__c = ServicesEstimateHelper.IAE_FULL,
                                  Request_Submitter__c = UserInfo.getUserId());
         insert dm;

         Services_Estimate__c est= new Services_Estimate__c(Name = 'MyTestEstimate',
                                        Estimate_Status__c = DemandManagementHelper.STATUS_NEW,
                                        Request_Description__c = 'My Desc',
                                        Demand_Management_Request__c = dm.Id);
                                        
         
         insert est;
         
         Services_Review_Meeting__c meeting = new Services_Review_Meeting__c(Estimate_In_Review__c = est.Id,
                                        Meeting_Date__c = Date.today(),
                                        Meeting_Description__c = 'Review IA',
                                        Meeting_Goal__c = 'Reach Agreement',
                                        AD_Comments__c = 'Done',
                                        AD_Review_Disposition__c = 'Agree',
                                        Product_Review_Disposition__c = 'Agree',
                                        Sales_Review_Disposition__c = 'Agree',
                                        Services_Review_Disposition__c = 'Agree');
         insert meeting;
         return est;
        
     }
     
     public static testMethod void testReadEstimate(){
         
         Services_Estimate__c est= createTestEstimate();                                   
         
         readEstimates(est.Demand_Management_Request__c);
         readEstimate(est.Id);
         readEstimateItems(est.Id);         
         readReviewMeetings(est.Id);
         readEstimateFunctionalFeatureMappings(est.Id);
      
     }


}

 Message shows that error occurs at Line 252 which is line below , but this query is returning a single result ,I am not sure why this error is appearing. Can some one pls. help me ? 

Product2 prod = [SELECT ID, NAME FROM Product2 WHERE NAME = 'BASE24-eps'];

Hi

I am getting the response has below when i send an http request .

am getting response has text data andin that url also .now i want to get the url from the response. only please can u help me

I am sendng an example of response

 

string response='the report has generated to sai and  and ready to access the data  ..etc.after this amgetting an url   http://www.abcadef.com/abc.asp?id=1  after these url am getting thanking you';

 

In these above response i want get only url from the response.please can u say me,

thanks in advance

 

 

From a best practice perspective, should the test class have any Try...Catch blocks or are all of these in the production classes and Triggers?

 

It seemed to me like the test class should not have Try...Catch blocks but I keep seeing these in examples.  Isn't purpose of these so the code catches them?

 

Thanks!

We have a quote template (a visual force page that renders as a PDF). This page currently uses the MessageFormat class from Java to format the currency fields on the quote. 

 

Here is the Visualforce example of how the Unit price on a product line item is formatted:

 

     <apex:column headerValue="Unit Price">

             <apex:outputText value="{0, number, $###,###,##0.00}">

                    <apex:param value="{!item.ListPrice}"/>

             </apex:outputText>

     </apex:column>

 

Note that <apex:outputText value="{0, number, $###,###,##0.00}"> gives back a USA currency format of $1,000.00. However, I need to have this be €###.###.##0,00 where the value comes out as €1.000,00. Note the position of the comma and period in the string.  It has been determined that the Java MessageFormat class will not work with other locations outside of the US. So I need another solution.

 

I have found some code in the Force.com Cookbook that will work to convert the decimal string into a Euro format:

 

     Decimal Amount = 199850010.28;
     Decimal dollars;
     Decimal cents;
     dollars = Amount.intValue();
     system.debug('Dollars is set to:' + dollars);
     cents = Amount - dollars;

     cents = cents.setScale(2);
     system.debug('cents is set to:' + cents);
     String AmtText = dollars.format()+','+ cents.toPlainString().substring(2) + ‘€’ ;
     System.debug(AmtText);

 

     199.850.010,28 €

 

 

I need help converting this code into a method inside of my Visualforce page controller. Also, I don’t know how link the output of this method to the appropriate line item values on the quote page.  It has been suggested by Salesforce Support that a wrapper class would do the dirty work. However, I have no experience with how to make a wrapper class work, nor how to use the above code within the wrapper class to format all of the currency fields (List Price, Discount Price, Discount Amount, Subtotal Amount, etc.) on our quote. 

 

Does anyone have a custom code example, or techniques for formatting currency in a Visualforce page so that Euros display properly?  I’m sure someone, somewhere has run into this requirement before since Salesforce is an international company.  Please share how you resolved this issue when using a Visualforce page template.

Hi,

 

How to use something like this..

 

<td >

          <apex:outputText value="{0, number, $###,###,###,##0.00}">
                    <apex:param value="{!IF(list.size>1,list[1].FieldValue,'$0.00')}"/>
          </apex:outputText>

</td>

 

Thanks

I wrote some code but unable to display in vf

 

vf:

-------------------------------------------

<apex:pageBlockTable value="{!get}" var="get_var" rendered="{!get_ren}">
             <apex:column value="{!get_var.name}"/>
            
            </apex:pageBlockTable>

 

class:

-------------------------------------------

list<SObject> selrec= new list<SObject>();

 accrec=[select id,name,check__c from account limit 10];

 conrec=[select id,lastname,check__c from contact limit 10];

 public PageReference Addtoselectedlist() {
       get_ren=true;
       for(account a:accrec){
         if(a.check__c==true){
         selrec.add(a);
         }
       }
       for(contact c:conrec){
         if(c.check__c==true){
         selrec.add(c);
         }
        
    }
 
return null;
}
     public sobject[] getGet() {
        return selrec;
    }

the goal:

Collect website visitors contact information (first name, email)  and store it in force.com custom object (consumers).

 

There are multiple different websites and the visitors contact information would have to be associated with the website they were visiting and submitting the form from.

 

Is there a declaritive way to do this on Force.com or is this only accomplished through code?

 

Thanks

 

Chris

 

 

 

 

interview Question:What  is Version controller and what version controler we used in Salesforce?

Hello everyone,

 

I have created a JavaScript button which is creating a curious effect. Upon clicking the button, it should create a task alerting another user that a lead is ready for their review. The fields should auto populate with the other users Name and Lead info through the use of a URL hack.

 

Instead, when the task is created, it notifies the creator of the task and attaches to a Contact of the same name as the lead. I find that if I click the magnifying glass next to the Assigned to User Field and the Name Lead field it works correctly. Any idea what might cause this or how to correct it?

 

Below is the button code. Thank you for your help,

 

if ({!Lead.Description} == "ceuenrollment") {
window.location = "/00T/e?tsk1=Certifications%20User&tsk2={!Lead.Name}&RetURL={!Lead.Id}&email=1&tsk2_mlktp=00Q&IsReminderSet=0&tsk5=CEU%20Order";
}

else if ({!Lead.Description} == "certrenew") {
window.location = "/00T/e?tsk1=Certifications%20User&tsk2={!Lead.Name}&RetURL={!Lead.Id}&email=1&tsk2_mlktp=00Q&IsReminderSet=0&tsk5=Cert%20Renewal";
}

else if ({!Lead.Description} == "certreplace") {
window.location = "/00T/e?tsk1=Certifications%20User&tsk2={!Lead.Name}&RetURL={!Lead.Id}&email=1&tsk2_mlktp=00Q&IsReminderSet=0&tsk5=Replacement%20Display%20Certificate%20Request";
}

else {
alert("This lead can not be marked as paid.");
}

 

Hi all,

 

I'm trying to build a custom button on a page layout for a custom object  that calls javascript that updates other fields on the page.  I defined the behavior as "execute javascript" and the Content Behavior as "OnClick Javascript".  The source is simple;

 

<script language="JavaScript">
try { {!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")} {!Appointment__c.Confirmed_Date__c}={!Appointment__c.ApptDate__c} ; {!Appointment__c.Confirmed_Time__c}={!Appointment__c.ApptTime__c} ; } catch(err){ alert(err); }
</script>

 

...But I keep on getting a popup that says "syntax error"  - help?

 

 

 

Hi,

    i am doing standered salesforce functionality of Merge ,that time can i find any call in controller or trigger ? if it is posible ple tell me

 

thanks&regards.

Bondi

Hi,

 

is there a way to authenticate an application for using the salesforce rest api with just the normal username / password credentials from

the basic http authentication?

I know thats not safe but its just for testing the functionality of my application.

 

best regards

Elmar

Hi,

 

I have a wrapper list which contains an integer value, a product record and a boolean value. 

my requirement is to sort that list according to the product name..

 

please help...its urgent.

 

 

 

 

 

Thanks in advanced

Hi,

We are planning to implement custom interface to open incident for our client. For that we are going to follow claim based authentication.

 

So I want to know is sales force support claim based authentication .

 

Thanks,

Pramod

Hi all anyone see what stupid mistake im making here?

 

Ive got a map:

 

map<string, Consultant__c> ConsultantMap = new map<string, Consultant__c>([select name, id from Consultant__c]); //this seems to work fine.


and all i want to do is use the value from a pick list as the key, so if i select 'Darth Vader' it uses that as the key and gets me the id.

 

now i've tried:

 

UsersId = ConsultantMap.get(pa.Login_As__c).id;

 

and even

 

Consultant__c X = ConsultantMap.get('Darth Vader');

system.debug('X' + X.Id);

 

but every time it fails and the id is null. yet the map is populated ok. I dont get what im going wrong.

 

Thanks All


Hi We have an tricky situation my all the apex class are covered more then 85% except one class use an StandardSetController Class  .Here is my sample code how i can cover the code. Somebody can help me to cover the line in test coverage.

List<Custom Object> variable1 = (List<Custom Object>)xyz.getSelected(); I am getting the p_stdSetController from my constructor here is the code ApexPages.StandardSetController xyz. List<Custom Object> variable1 = (List<Custom Object>)xyz.getSelected(); this line is hitting the code coverage .

 

 

Hi,
I'm new to Apex development. 
I used the "Generate From WSDL" option to create an Apex class to access our WebService.
The WebService is fairly large, the generated class came in just under the limit at 95k characters.
When I went to deploy this class from my Sandbox to our production environment (using Apache Ant),
I received an error saying 0% of my class was covered by Unit Tests.
Now, I wrote a test, but it gave a warning saying:
"Testmethods do not support webservice callouts".
So essentially Unit Tests for this class are just fillers to get past the 75% restriction.
At 95k characters, I'm looking at a lot of empty Unit Tests to get this code deployed on our production environment.
Is there currently any way to deploy an auto-generated apex class w/o writing Unit Tests?
Thanks in advance.