• Salesforce Test 5
  • NEWBIE
  • 14 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 33
    Questions
  • 40
    Replies
Hi Friends
The following is my Apex class i have written test class for this, i coverd upto 59% i want to make it increase. can you help me to fulfill this.
 
public class FormCurriculumController { 
  

public Purchase_Order__c curriculum {get; set;}
public Boolean privacy {get; set;}
public Boolean saved {get; set;}
public String styleClass {get; set;}
// Allegato
public Transient Blob resume {get; set;}
public String contentType {get; set;}
public String fileName {get; set;}
      
    public boolean showC1RecordType {get;set;}
    public boolean showC2RecordType {get;set;} 
    
    private Id c1RecordTypeId; 
    private Id c2RecordTypeId;


//ublic FormCurriculumController () {
    //curriculum = new Purchase_Order__c();
    //saved = false;
//}

  public FormCurriculumController(ApexPages.StandardController controller) {

        c1RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C1').getRecordTypeId();
        c2RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C2').getRecordTypeId();
        
        curriculum= new Purchase_Order__c();
        curriculum= (Purchase_Order__c)controller.getRecord();
         
        String isButtonClicked = Apexpages.currentPage().getParameters().get('setDefaultValues');
        if(isButtonClicked == 'true'){
            setDefaultValues();
        }
        
        showC1RecordType = false;
        showC2RecordType = false;
       
        if(curriculum.RecordTypeId == c1RecordTypeId){
            showC1RecordType = true;
            showC2RecordType = false;
        }
        else if(curriculum.RecordTypeId == c2RecordTypeId){
            showC1RecordType = false;
            showC2RecordType = true;
        }
        
    }
    
     public void setDefaultValues(){
        String quoteId = Apexpages.currentPage().getParameters().get('quoteId');
        Quote__c quote = [Select o.id, o.name, o.Quantity_formula__c, o.Opportunity_Product_Detail__r.Opportunity__c,
                    o.Opportunity__c, o.Record_type_name__c,o.Company_Name__c,Opportunity_Product_Detail__r.Opportunity__r.Account__c from Quote__c o WHERE O.id=:quoteId];
        //system.assert(false,quote);     
        curriculum.Opportunity__c = quote.Opportunity_Product_Detail__r.Opportunity__c;
        curriculum.Quote__c = quote.id;
        curriculum.Company__c = quote.Opportunity_Product_Detail__r.Opportunity__r.Account__c;
        
        if(quote.Record_type_name__c == 'C1'){
            curriculum.RecordTypeId = c1RecordTypeId;
        }
        else {
            curriculum.RecordTypeId = c2RecordTypeId;
        }
    }

    


public PageReference save() {
    try {
        // Validazione effettuata qui perchè il required sull'inputCheckbox non è utilizzabile
        if (!privacy) {
        
            ApexPages.Message reqMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Please upload recent Purchase Order  before saving the record');
            ApexPages.addMessage(reqMsg);
            return null;
        }

        // Inserisce il record
        
       
        
        
        insert(curriculum);
        // Inserisce l'allegato
        if (resume != null) {
            Attachment attach = new Attachment();
            attach.Body = resume;
            attach.Name = fileName;
            attach.ContentType= contentType;
            attach.ParentId = curriculum.id;                
            try {
                insert(attach);
                return new PageReference('/'+curriculum.id);

            } catch (Exception ex) {
                // TODO fare il roolback dell'inserimento del curriculum?

                ApexPages.addMessages(ex);
                return null;
            }                    
        }

        //Papagni 03/09/2013 - update curriculum per fare scattare il trigger di after che invia la mail
        update curriculum;

        saved = true;

    } 
    catch(Exception ex) {
        ApexPages.addMessages(ex);  
    }
    return null;   
}
}
@IsTest
public class TestFormCurriculumController  
{
static testMethod void TestMethodFormCurriculumController  ()
{

        account a=new account(name='test',Region__c='East');
        insert a;
        
        Master_Product__c mp=new Master_Product__c(name='test name',Product_Code__c='c2');
        insert mp;
        
        contact c=new contact(firstname='Meenakshmi',lastname='Goswami',Designation__c='Developer',Accountid=a.id);
        insert c;


        Opportunity2__c op=new Opportunity2__c(Name='test1',Account__c=a.id,Master_Product__c=mp.id,Technical_Bid_date__c=date.Today(),Type_of_Business__c='Regular',Contact_Person__c=c.id);
        insert op;
     
        Opportunity_Product_Detail__c opd=new Opportunity_Product_Detail__c(Opportunity__c=op.id,Company__c=a.id,Quantity__c=10,Make__c='Datalogic-Barcode Scanner', Model__c='S4M 203 Dpi');
        insert opd;
        
        Quote__c qt=new Quote__c(Opportunity_Product_Detail__c=opd.id,Basic_Price_per_1000__c=100,Basic_Price_Each_item__c=200,Purpose_of_Sales__c='SEZ',Declaration_form_be_provided__c='No');
        insert qt;
        
        Quote__c qt1=[select Quantity_formula__c from Quote__c where id=:qt.id];
        system.debug('--------Quote quantity--------'+qt1.Quantity_formula__c );
        
        RecordType rt = [Select id,name from RecordType where SobjectType='Purchase_Order__c' and Name='C1'];
        
        Purchase_Order__c sco=new Purchase_Order__c(RecordTypeId=rt.id,Quote__c=qt.id,Opportunity__c=op.id,Sale_Confirmation_Order_Date__c=date.Today());
        sco.Sale_Confirmation_Order_Number__c='100';
      
       
        insert sco;
    
         test.startTest();
         PageReference pageRef = Page.FormCurriculumController ;
         Test.setCurrentPage(pageRef);
         ApexPages.Standardcontroller sc = new ApexPages.Standardcontroller(sco);
         
         ApexPages.currentPage().getParameters().put('Id',sco.id);
         FormCurriculumController  objMyController= new FormCurriculumController  (sc);
         
         
         
         
         
         
         /*ApexPages.currentPage().getParameters().put('Id',emp.id);
            ApexPages.currentPage().getParameters().put('setDefaultValues','true');
            ApexPages.currentPage().getParameters().put('id',sco.id);
           
            ApexPages.StandardController stdLead = new ApexPages.StandardController(sco);
            NewSalesConfirmationExtension objMyController  = new NewSalesConfirmationExtension (stdLead);*/
            objMyController.save();
            
         
        test.stopTest();
        
        
        }
static testMethod void TestMethodFormCurriculumController1()
{

 account a=new account(name='test',Region__c='East');
        insert a;
        
        Master_Product__c mp=new Master_Product__c(name='test name',Product_Code__c='c2');
        insert mp;
        
        contact c=new contact(firstname='Meenakshmi',lastname='Goswami',Designation__c='Developer',Accountid=a.id);
        insert c;


        Opportunity2__c op=new Opportunity2__c(Name='test1',Account__c=a.id,Master_Product__c=mp.id,Technical_Bid_date__c=date.Today(),Type_of_Business__c='Regular',Contact_Person__c=c.id);
        insert op;
     
        Opportunity_Product_Detail__c opd=new Opportunity_Product_Detail__c(Opportunity__c=op.id,Company__c=a.id,Quantity__c=10,Make__c='Datalogic-Barcode Scanner', Model__c='S4M 203 Dpi');
        insert opd;
        
        RecordType quoteRt = [Select id,name from RecordType where SobjectType='Quote__c' and Name='C2'];
        
        Quote__c qt=new Quote__c(RecordTypeId=quoteRt.id,Opportunity_Product_Detail__c=opd.id,Basic_Price_per_1000__c=100,Basic_Price_Each_item__c=200,Purpose_of_Sales__c='SEZ',Declaration_form_be_provided__c='No');
        insert qt;
        
        Quote__c qt1=[select Quantity_formula__c from Quote__c where id=:qt.id];
        system.debug('--------Quote quantity--------'+qt1.Quantity_formula__c );
        
        RecordType rt = [Select id,name from RecordType where SobjectType='Purchase_Order__c' and Name='C2'];
        
        Purchase_Order__c sco=new Purchase_Order__c(RecordTypeId=rt.id,Quote__c=qt.id,Opportunity__c=op.id,Sale_Confirmation_Order_Date__c=date.Today());
        sco.Sale_Confirmation_Order_Number__c='100';
        insert sco;
        
         test.startTest();
            //ApexPages.currentPage().getParameters().put('id',sco.id);
            ApexPages.currentPage().getParameters().put('setDefaultValues','true');
            ApexPages.currentPage().getParameters().put('quoteId',qt.id);
            ApexPages.StandardController stdLead = new ApexPages.StandardController(sco);
            FormCurriculumController  objMyController  = new FormCurriculumController (stdLead);
           
            objMyController.attach.body=bodyBlob ;
           
            
            objMyController.save();
            
          
        
        test.stopTest();
        
        }
}


 
I have a custom button which is supposed to create a new page , but I'm getting the following error when I click it:

"A problem with the OnClick JavaScript for this button or link was encountered: missing ; before statement"

My button executes the following OnClick Javascript:
 
if({!Quote__c.Approved_Artwork_Attached__c} == 0)
{
alert('Approved Artwork has not been uploaded');
}
else
{
window.location.href ='/apex/Testing?CF00N9000000810yt={!Quote__c.Opportunity__c}&CF00N9000000810yu={!Quote__c.Id}&CF00N9000000810yx={!Quote__c.Company_Name__c}&recordTypeName={!Quote__c.Record_type_name__c}';
}

if({!Quote__c.Approved_Artwork_Attached__c} == 0)
{
alert('Approved Artwork has not been uploaded');
}
else
{
window.location.href ='/apex/Testing?quoteId={!Quote__c.Id}&setDefaultValues=true';
}

 
Error Message
System.NullPointerException: Attempt to de-reference a null object
Error is in expression '{!doUploadFile}' in component <apex:commandButton> in page testing: Class.CCW_UploadFileController.doUploadFile: line 69, column 1
Class.CCW_UploadFileController.doUploadFile: line 69, column 1
 
public with sharing class CCW_UploadFileController {

    public Purchase_Order__c purchaseOrder{get;set;}
    public  Attachment tAttachment{get;set;}
                                        
                                    
    
    public boolean showC1RecordType {get;set;}
    public boolean showC2RecordType {get;set;} 
    
    private Id c1RecordTypeId; 
    private Id c2RecordTypeId;
    
 
    public CCW_UploadFileController(ApexPages.StandardController controller)
    {
 
       
        this.tAttachment = new Attachment();
        c1RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C1').getRecordTypeId();
        c2RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C2').getRecordTypeId();
        
        purchaseOrder = new Purchase_Order__c();
        purchaseOrder = (Purchase_Order__c)controller.getRecord();
         
        String isButtonClicked = Apexpages.currentPage().getParameters().get('setDefaultValues');
        if(isButtonClicked == 'true'){
            setDefaultValues();
        }
        
        showC1RecordType = false;
        showC2RecordType = false;
        tAttachment= new Attachment();
        
        
        if(purchaseOrder.RecordTypeId == c1RecordTypeId){
            showC1RecordType = true;
            showC2RecordType = false;
        }
        else if(purchaseOrder.RecordTypeId == c2RecordTypeId){
            showC1RecordType = false;
            showC2RecordType = true;
        }
        
    }
    
     public void setDefaultValues(){
        String quoteId = Apexpages.currentPage().getParameters().get('quoteId');
        Quote__c quote = [Select o.id, o.name, o.Quantity_formula__c, o.Opportunity_Product_Detail__r.Opportunity__c,
                    o.Opportunity__c, o.Record_type_name__c,o.Company_Name__c,Opportunity_Product_Detail__r.Opportunity__r.Account__c from Quote__c o WHERE O.id=:quoteId];
        //system.assert(false,quote);     
        purchaseOrder.Opportunity__c = quote.Opportunity_Product_Detail__r.Opportunity__c;
        purchaseOrder.Quote__c = quote.id;
        purchaseOrder.Company__c = quote.Opportunity_Product_Detail__r.Opportunity__r.Account__c;
        
        if(quote.Record_type_name__c == 'C1'){
            purchaseOrder.RecordTypeId = c1RecordTypeId;
        }
        else {
            purchaseOrder.RecordTypeId = c2RecordTypeId;
        }
    }
 
    
 
   
    public PageReference doUploadFile(){
 
        if(tAttachment.Body == null){
            Apexpages.addMessage(new Apexpages.Message(Apexpages.Severity.ERROR, 'Please upload recent Purchase Order  before saving the record'));
            return null;
        }
        else{
            try{
                insert purchaseOrder;
                
              tAttachment.OwnerId = UserInfo.getUserId();
               tAttachment.ParentId = purchaseOrder.id;
              insert tAttachment;
                
                
                return new PageReference('/'+purchaseOrder.id);
            }
            catch(DMLException e){
                ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,e.getMessage()));
                return null;
            }
        }
    }
}
<apex:page standardController="Purchase_Order__c" extensions="CCW_UploadFileController">
    <apex:sectionHeader title="Sale Confirmation Orders" subtitle="{!purchaseOrder.Name}" />
      <apex:form enctype="multipart/form-data">
        <apex:pageMessages ></apex:pageMessages>
        <apex:pageBlock title="Sale Confirmation Order Edit">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!doUploadFile}" value="Save"/>
                <apex:commandButton action="{!cancel}" value="Cancel"/>
            </apex:pageBlockButtons>
            
            <apex:pageBlockSection title="Information" columns="2" collapsible="false" rendered="{!showC1RecordType}">
                <apex:inputField value="{!purchaseOrder.Opportunity__c}"/>
                <apex:inputField value="{!purchaseOrder.Sale_Confirmation_Order_Number__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.GRN_needed_for_Bill_Processing__c}"/>
                <apex:inputField value="{!purchaseOrder.Sale_Confirmation_Order_Date__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.No_of_Days_for_collecting_GRN__c}"/>
                <apex:inputField value="{!purchaseOrder.Pre_shipment_Inspection_required__c}" required="true" />
              
                <apex:inputField value="{!purchaseOrder.Purchase_Frequency__c}" required="true" />
                <apex:inputField value="{!purchaseOrder.Customer_Ordered_Quantity__c}" required="true" />
                <apex:inputField value="{!purchaseOrder.Credit_Limit__c}"/>
                   
                    <apex:inputField value="{!purchaseOrder.Customer_Price__c}"/>
                     <apex:inputField value="{!purchaseOrder.CurrencyIsoCode}"/>
                <apex:inputField value="{!purchaseOrder.Bill_Submission_Period__c}"/>
               
                <!---<apex:inputField value="{!purchaseOrder.New_Flash_Aidc_Email_sent__c}"/>--->
               
               
               <!--- <apex:inputField value="{!purchaseOrder.New_Flash_Email_sent__c}"/>--->
                <apex:inputField value="{!purchaseOrder.Committed_Dispatch_Date__c}" required="true"/>
              
               <!-- <apex:inputField value="{!purchaseOrder.PO_Uploaded__c}"/>
                <apex:inputField value="{!purchaseOrder.Try__c}"/>
                <apex:inputField value="{!purchaseOrder.CountAttachment__c}"/>--->
            </apex:PageBlockSection>
            
            <apex:pageBlockSection title="Information" columns="2" collapsible="false" rendered="{!showC2RecordType}">
                <apex:inputField value="{!purchaseOrder.Opportunity__c}"/>
                <apex:inputField value="{!purchaseOrder.Sale_Confirmation_Order_Number__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.GRN_needed_for_Bill_Processing__c}"/>
                <apex:inputField value="{!purchaseOrder.Sale_Confirmation_Order_Date__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.No_of_Days_for_collecting_GRN__c}"/>
                <apex:inputField value="{!purchaseOrder.Committed_Dispatch_Date__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.Credit_Limit__c}"/>
                <apex:inputField value="{!purchaseOrder.Customer_Ordered_Quantity__c}"/>
                <apex:inputField value="{!purchaseOrder.CurrencyIsoCode}"/>
                <apex:inputField value="{!purchaseOrder.Customer_Price__c}"/>
                <apex:inputField value="{!purchaseOrder.Purchase_Frequency__c}" required="true" />
                <apex:inputField value="{!purchaseOrder.Bill_Submission_Period__c}"/>
                <apex:inputField value="{!purchaseOrder.Application_Area__c}"/>
               
                <!---<apex:inputField value="{!purchaseOrder.CountAttachment__c}"/>
                <apex:inputField value="{!purchaseOrder.Try__c}"/>
                <apex:inputField value="{!purchaseOrder.New_Flash_Email_sent__c}"/>
                 <apex:inputField value="{!purchaseOrder.New_Flash_Aidc_Email_sent__c}"/>---->
            </apex:PageBlockSection>
            
            <apex:pageBlockSection title="Quote Details" columns="1" collapsible="false">
                <apex:inputField value="{!purchaseOrder.Quote__c}"/>
                <apex:inputField value="{!purchaseOrder.Company__c}"/>
                 <apex:inputField value="{!purchaseOrder.Delivery_Address__c}" required="true" />
            </apex:PageBlockSection>
            
            <apex:pageBlockSection title="New Flash Details" columns="2" collapsible="false">
                <apex:inputField value="{!purchaseOrder.Application_Area__c}"  rendered="{!showC1RecordType}"/>
                <apex:inputField value="{!purchaseOrder.Remarks__c}"/>
            </apex:PageBlockSection>
            
            <apex:pageBlockSection title="Upload Purchase Order" columns="2" collapsible="false">
                <apex:pageBlockSectionItem >
                <apex:outputLabel value="File" for="file" />
                
            <apex:inputFile value="{!tAttachment.Body}" filename="{!tAttachment.Name}" filesize="{!tAttachment.BodyLength}" contentType="{!tAttachment.ContentType}" />
          
                </apex:pageBlockSectionItem>
            </apex:PageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>


 
Hi Friends

I have created a vf page which uplaod file its working fine ,but i am facing problem when file is more than 135KB.i have used transient variable also
but facing same..Is there any other way to achieve this challenge.
public with sharing class CCW_UploadFileController {

    public Purchase_Order__c purchaseOrder{get;set;}
    public  Attachment tAttachment{get{
                                        if(tAttachment== null)
                                          tAttachment= new Attachment();
                                        return tAttachment;
                                     }set;}
    
    public boolean showC1RecordType {get;set;}
    public boolean showC2RecordType {get;set;} 
    
    private Id c1RecordTypeId; 
    private Id c2RecordTypeId;
    
 
    public CCW_UploadFileController(ApexPages.StandardController controller)
    {
 
       
        this.tAttachment = new Attachment();
        c1RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C1').getRecordTypeId();
        c2RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C2').getRecordTypeId();
        
        purchaseOrder = new Purchase_Order__c();
        purchaseOrder = (Purchase_Order__c)controller.getRecord();
         
        String isButtonClicked = Apexpages.currentPage().getParameters().get('setDefaultValues');
        if(isButtonClicked == 'true'){
            setDefaultValues();
        }
        
        showC1RecordType = false;
        showC2RecordType = false;
        tAttachment= new Attachment();
        
        
        if(purchaseOrder.RecordTypeId == c1RecordTypeId){
            showC1RecordType = true;
            showC2RecordType = false;
        }
        else if(purchaseOrder.RecordTypeId == c2RecordTypeId){
            showC1RecordType = false;
            showC2RecordType = true;
        }
        
    }
    
     public void setDefaultValues(){
        String quoteId = Apexpages.currentPage().getParameters().get('quoteId');
        Quote__c quote = [Select o.id, o.name, o.Quantity_formula__c, o.Opportunity_Product_Detail__r.Opportunity__c,
                    o.Opportunity__c, o.Record_type_name__c,o.Company_Name__c,Opportunity_Product_Detail__r.Opportunity__r.Account__c from Quote__c o WHERE O.id=:quoteId];
        //system.assert(false,quote);     
        purchaseOrder.Opportunity__c = quote.Opportunity_Product_Detail__r.Opportunity__c;
        purchaseOrder.Quote__c = quote.id;
        purchaseOrder.Company__c = quote.Opportunity_Product_Detail__r.Opportunity__r.Account__c;
        
        if(quote.Record_type_name__c == 'C1'){
            purchaseOrder.RecordTypeId = c1RecordTypeId;
        }
        else {
            purchaseOrder.RecordTypeId = c2RecordTypeId;
        }
    }
 
    
 
   
    public PageReference doUploadFile(){
 
        if(tAttachment.Body == null){
            Apexpages.addMessage(new Apexpages.Message(Apexpages.Severity.ERROR, 'Please upload recent Purchase Order  before saving the record'));
            return null;
        }
        else{
            try{
                insert purchaseOrder;
                
              tAttachment.OwnerId = UserInfo.getUserId();
               tAttachment.ParentId = purchaseOrder.id;
              insert tAttachment;
                
                
                return new PageReference('/'+purchaseOrder.id);
            }
            catch(DMLException e){
                ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,e.getMessage()));
                return null;
            }
        }
    }
}

 
Hi

I have created a currency field but my requirment is format should be 4 decimal after point(12.98765).i have set (14,4),but it is showing 2 decimal when record saved.
Hi Guys

I am facing issue on commandline data loader when i run my script.how to achieve this ?
C:\Program Files (x86)\salesforce.com\Data Loader\bin>process.bat "D:\test1" Inv
oiceUpsert
2016-03-31 13:08:48,286 INFO  [main] controller.Controller initLog (Controller.j
ava:389) - Using built-in logging configuration, no log-conf.xml in C:\Program F
iles (x86)\salesforce.com\Data Loader\bin\log-conf.xml
2016-03-31 13:08:48,298 INFO  [main] controller.Controller initLog (Controller.j
ava:391) - The log has been initialized
2016-03-31 13:08:48,304 INFO  [main] process.ProcessConfig getBeanFactory (Proce
ssConfig.java:103) - Loading process configuration from config file: D:\test1\pr
ocess-conf.xml
2016-03-31 13:08:48,501 INFO  [main] xml.XmlBeanDefinitionReader loadBeanDefinit
ions (XmlBeanDefinitionReader.java:315) - Loading XML bean definitions from file
 [D:\test1\process-conf.xml]
2016-03-31 13:08:48,635 INFO  [InvoiceUpsert] controller.Controller initConfig (
Controller.java:327) - config dir created at D:\test1
2016-03-31 13:08:48,654 INFO  [InvoiceUpsert] controller.Controller initConfig (
Controller.java:355) - The controller config has been initialized
2016-03-31 13:08:48,656 INFO  [InvoiceUpsert] process.ProcessRunner run (Process
Runner.java:116) - Initializing process engine
2016-03-31 13:08:48,658 INFO  [InvoiceUpsert] process.ProcessRunner run (Process
Runner.java:119) - Loading parameters
2016-03-31 13:08:49,679 ERROR [InvoiceUpsert] config.Config decryptProperty (Con
fig.java:692) - Error loading parameter: sfdc.password of type: java.lang.String

javax.crypto.BadPaddingException: Given final block not properly padded
        at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
        at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
        at com.sun.crypto.provider.DESCipher.engineDoFinal(DashoA13*..)
        at javax.crypto.Cipher.doFinal(DashoA13*..)
        at com.salesforce.dataloader.security.EncryptionUtil.decryptString(Encry
ptionUtil.java:210)
        at com.salesforce.dataloader.config.Config.decryptProperty(Config.java:6
86)
        at com.salesforce.dataloader.config.Config.postLoad(Config.java:638)
        at com.salesforce.dataloader.config.Config.loadParameterOverrides(Config
.java:664)
        at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.jav
a:120)
        at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.jav
a:100)
        at com.salesforce.dataloader.process.ProcessRunner.main(ProcessRunner.ja
va:253)
2016-03-31 13:08:49,692 FATAL [main] process.ProcessRunner topLevelError (Proces
sRunner.java:238) - Unable to run process InvoiceUpsert
java.lang.RuntimeException: com.salesforce.dataloader.exception.ParameterLoadExc
eption: Error loading parameter: sfdc.password of type: java.lang.String
        at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.jav
a:162)
        at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.jav
a:100)
        at com.salesforce.dataloader.process.ProcessRunner.main(ProcessRunner.ja
va:253)
Caused by: com.salesforce.dataloader.exception.ParameterLoadException: Error loa
ding parameter: sfdc.password of type: java.lang.String
        at com.salesforce.dataloader.config.Config.decryptProperty(Config.java:6
93)
        at com.salesforce.dataloader.config.Config.postLoad(Config.java:638)
        at com.salesforce.dataloader.config.Config.loadParameterOverrides(Config
.java:664)
        at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.jav
a:120)
        ... 2 more
Caused by: javax.crypto.BadPaddingException: Given final block not properly padd
ed
        at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
        at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
        at com.sun.crypto.provider.DESCipher.engineDoFinal(DashoA13*..)
        at javax.crypto.Cipher.doFinal(DashoA13*..)
        at com.salesforce.dataloader.security.EncryptionUtil.decryptString(Encry
ptionUtil.java:210)
        at com.salesforce.dataloader.config.Config.decryptProperty(Config.java:6
86)
        ... 5 more
C:\Program Files (x86)\salesforce.com\Data Loader\bin>^A

 
Hi Friends

I have one issue facing a big challenge.i have two object Account and Object__c which have lookup relationship.i have one picklist in account object with value ABC and XYZ.my requirment is want two convert all existing picklist value XYZ to ABC in account object which have Object__c record .


Thanks
Trigger addtrigger on Quote__c(before insert, before update)
{
  if(Trigger.isBefore) 
  {
    if (Trigger.isInsert || Trigger.isUpdate)
     {
       for(Quote__c cob : trigger.new)
         {
            cob.Total_Job_Value_Updated__c= cob.H_Total_Job_Value__c+cob.Delivery_Charges_n__c; 
           }
       }
    }
}

 
Hi
I have created a apex class for uploading file.but i am uplaoding any files its showing this error.how to achieve this error ?


System.NullPointerException: Attempt to de-reference a null object
Error is in expression '{!doUploadFile}' in component <apex:commandButton> in page scoupload: Class.SCOUpload.doUploadFile: line 74, column 1
Class.SCOUpload.doUploadFile: line 74, column 1
 
public with sharing class SCOUpload {
 
    /*
    *   attachment
    */
    public Purchase_Order__c purchaseOrder{get;set;}
 Public  Transient Attachment tAttachment{get;set;}
    public boolean showC1RecordType {get;set;}
    public boolean showC2RecordType {get;set;} 
    
    private Id c1RecordTypeId; 
    private Id c2RecordTypeId;
    
 
    /*
    *   constructor
    */
    public SCOUpload(ApexPages.StandardController controller)
    {
 
        //initialize attachment container
        this.tAttachment = new Attachment();
        c1RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C1').getRecordTypeId();
        c2RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C2').getRecordTypeId();
        
        purchaseOrder = new Purchase_Order__c();
        purchaseOrder = (Purchase_Order__c)controller.getRecord();
         
        String isButtonClicked = Apexpages.currentPage().getParameters().get('setDefaultValues');
        if(isButtonClicked == 'true'){
            setDefaultValues();
        }
        
        showC1RecordType = false;
        showC2RecordType = false;
        tAttachment= new Attachment();
        
        
        if(purchaseOrder.RecordTypeId == c1RecordTypeId){
            showC1RecordType = true;
            showC2RecordType = false;
        }
        else if(purchaseOrder.RecordTypeId == c2RecordTypeId){
            showC1RecordType = false;
            showC2RecordType = true;
        }
        
    }
    
     public void setDefaultValues(){
        String quoteId = Apexpages.currentPage().getParameters().get('quoteId');
        Quote__c quote = [Select o.id, o.name, o.Quantity_formula__c, o.Opportunity_Product_Detail__r.Opportunity__c,
                    o.Opportunity__c, o.Record_type_name__c,o.Company_Name__c,Opportunity_Product_Detail__r.Opportunity__r.Account__c from Quote__c o WHERE O.id=:quoteId];
        //system.assert(false,quote);     
        purchaseOrder.Opportunity__c = quote.Opportunity_Product_Detail__r.Opportunity__c;
        purchaseOrder.Quote__c = quote.id;
        purchaseOrder.Company__c = quote.Opportunity_Product_Detail__r.Opportunity__r.Account__c;
        
        if(quote.Record_type_name__c == 'C1'){
            purchaseOrder.RecordTypeId = c1RecordTypeId;
        }
        else {
            purchaseOrder.RecordTypeId = c2RecordTypeId;
        }
    }
 
    
 
    /*
    *   upload file
    */
    public PageReference doUploadFile(){
 
        if(tAttachment.Body == null){
            Apexpages.addMessage(new Apexpages.Message(Apexpages.Severity.ERROR, 'Please upload recent Purchase Order  before saving the record'));
            return null;
        }
        else{
            try{
                insert purchaseOrder;
                
              tAttachment.OwnerId = UserInfo.getUserId();
               tAttachment.ParentId = purchaseOrder.id;
              insert tAttachment;
                
                
                return new PageReference('/'+purchaseOrder.id);
            }
            catch(DMLException e){
                ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,e.getMessage()));
                return null;
            }
        }
    }
}

 
Hi all

I have created a class for uplaoding file and its working fine.but when i am uploading more than 135KB file its throwing error like Maximum view state size limit (128K) exceeded.Problem is when system admin uplaod more than 135 KB file it has been uploaded but on other profile it is showing this type of error.how to achieve this ...
public with sharing class CCW_UploadFileController {
 
    /*
    *   attachment
    */
    public Purchase_Order__c purchaseOrder{get;set;}
    public Attachment tAttachment{get;set;}
    public boolean showC1RecordType {get;set;}
    public boolean showC2RecordType {get;set;} 
    
    private Id c1RecordTypeId; 
    private Id c2RecordTypeId;
    
 
    /*
    *   constructor
    */
    public CCW_UploadFileController(ApexPages.StandardController controller)
    {
 
        //initialize attachment container
        this.tAttachment = new Attachment();
        c1RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C1').getRecordTypeId();
        c2RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C2').getRecordTypeId();
        
        purchaseOrder = new Purchase_Order__c();
        purchaseOrder = (Purchase_Order__c)controller.getRecord();
         
        String isButtonClicked = Apexpages.currentPage().getParameters().get('setDefaultValues');
        if(isButtonClicked == 'true'){
            setDefaultValues();
        }
        
        showC1RecordType = false;
        showC2RecordType = false;
        tAttachment= new Attachment();
        
        
        if(purchaseOrder.RecordTypeId == c1RecordTypeId){
            showC1RecordType = true;
            showC2RecordType = false;
        }
        else if(purchaseOrder.RecordTypeId == c2RecordTypeId){
            showC1RecordType = false;
            showC2RecordType = true;
        }
        
    }
    
     public void setDefaultValues(){
        String quoteId = Apexpages.currentPage().getParameters().get('quoteId');
        Quote__c quote = [Select o.id, o.name, o.Quantity_formula__c, o.Opportunity_Product_Detail__r.Opportunity__c,
                    o.Opportunity__c, o.Record_type_name__c,o.Company_Name__c,Opportunity_Product_Detail__r.Opportunity__r.Account__c from Quote__c o WHERE O.id=:quoteId];
        //system.assert(false,quote);     
        purchaseOrder.Opportunity__c = quote.Opportunity_Product_Detail__r.Opportunity__c;
        purchaseOrder.Quote__c = quote.id;
        purchaseOrder.Company__c = quote.Opportunity_Product_Detail__r.Opportunity__r.Account__c;
        
        if(quote.Record_type_name__c == 'C1'){
            purchaseOrder.RecordTypeId = c1RecordTypeId;
        }
        else {
            purchaseOrder.RecordTypeId = c2RecordTypeId;
        }
    }
 
    
 
    /*
    *   upload file
    */
    public PageReference doUploadFile(){
 
        if(tAttachment.Body == null){
            Apexpages.addMessage(new Apexpages.Message(Apexpages.Severity.ERROR, 'Please upload recent Purchase Order  before saving the record'));
            return null;
        }
        else{
            try{
                insert purchaseOrder;
                
              tAttachment.OwnerId = UserInfo.getUserId();
               tAttachment.ParentId = purchaseOrder.id;
              insert tAttachment;
                
                
                return new PageReference('/'+purchaseOrder.id);
            }
            catch(DMLException e){
                ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,e.getMessage()));
                return null;
            }
        }
    }
}
<apex:page standardController="Purchase_Order__c" extensions="CCW_UploadFileController">
    <apex:sectionHeader title="Sale Confirmation Orders" subtitle="{!purchaseOrder.Name}" />
      <apex:form enctype="multipart/form-data">
        <apex:pageMessages ></apex:pageMessages>
        <apex:pageBlock title="Sale Confirmation Order Edit">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!doUploadFile}" value="Save"/>
                <apex:commandButton action="{!cancel}" value="Cancel"/>
            </apex:pageBlockButtons>
            
            <apex:pageBlockSection title="Information" columns="2" collapsible="false" rendered="{!showC1RecordType}">
                <apex:inputField value="{!purchaseOrder.Opportunity__c}"/>
                <apex:inputField value="{!purchaseOrder.Sale_Confirmation_Order_Number__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.GRN_needed_for_Bill_Processing__c}"/>
                <apex:inputField value="{!purchaseOrder.Sale_Confirmation_Order_Date__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.No_of_Days_for_collecting_GRN__c}"/>
                <apex:inputField value="{!purchaseOrder.Committed_Dispatch_Date__c}" required="true"/>
               
              
                <apex:inputField value="{!purchaseOrder.Purchase_Frequency__c}" required="true" />
                <apex:inputField value="{!purchaseOrder.Customer_Ordered_Quantity__c}" required="true" />
                 <apex:inputField value="{!purchaseOrder.Pre_shipment_Inspection_required__c}" required="true" />
                
                   
                    <apex:inputField value="{!purchaseOrder.Customer_Price__c}"/>
                    
                     <apex:inputField value="{!purchaseOrder.Credit_Limit__c}"/>
                    <apex:inputField value="{!purchaseOrder.Bill_Submission_Period__c}"/> 
               <apex:inputField value="{!purchaseOrder.CurrencyIsoCode}"/>
                
               
                <!---<apex:inputField value="{!purchaseOrder.New_Flash_Aidc_Email_sent__c}"/>--->
               
               
               <!--- <apex:inputField value="{!purchaseOrder.New_Flash_Email_sent__c}"/>--->
                
              
               <!-- <apex:inputField value="{!purchaseOrder.PO_Uploaded__c}"/>
                <apex:inputField value="{!purchaseOrder.Try__c}"/>
                <apex:inputField value="{!purchaseOrder.CountAttachment__c}"/>--->
            </apex:PageBlockSection>
            
            <apex:pageBlockSection title="Information" columns="2" collapsible="false" rendered="{!showC2RecordType}">
                <!---<apex:inputField value="{!purchaseOrder.Opportunity__c}"/>
                <apex:inputField value="{!purchaseOrder.Sale_Confirmation_Order_Number__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.GRN_needed_for_Bill_Processing__c}"/>
                <apex:inputField value="{!purchaseOrder.Sale_Confirmation_Order_Date__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.No_of_Days_for_collecting_GRN__c}"/>
                <apex:inputField value="{!purchaseOrder.Committed_Dispatch_Date__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.Credit_Limit__c}"/>
                <apex:inputField value="{!purchaseOrder.Customer_Ordered_Quantity__c}"/>
                <apex:inputField value="{!purchaseOrder.CurrencyIsoCode}"/>
                <apex:inputField value="{!purchaseOrder.Customer_Price__c}"/>
                <apex:inputField value="{!purchaseOrder.Purchase_Frequency__c}" required="true" />
                <apex:inputField value="{!purchaseOrder.Bill_Submission_Period__c}"/>--->
                   <!---<apex:inputField value="{!purchaseOrder.Application_Area__c}"/>
               
            <apex:inputField value="{!purchaseOrder.CountAttachment__c}"/>
                <apex:inputField value="{!purchaseOrder.Try__c}"/>
                <apex:inputField value="{!purchaseOrder.New_Flash_Email_sent__c}"/>
                 <apex:inputField value="{!purchaseOrder.New_Flash_Aidc_Email_sent__c}"/>---->
                 
                 
                 <apex:inputField value="{!purchaseOrder.Opportunity__c}"/>
                <apex:inputField value="{!purchaseOrder.Sale_Confirmation_Order_Number__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.GRN_needed_for_Bill_Processing__c}"/>
                <apex:inputField value="{!purchaseOrder.Sale_Confirmation_Order_Date__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.No_of_Days_for_collecting_GRN__c}"/>
                <apex:inputField value="{!purchaseOrder.Committed_Dispatch_Date__c}" required="true"/>
               
              <!--- <apex:inputField value="{!purchaseOrder.Sale_Confirmation_Order_Number__c}"  required="true"/>--->
                <apex:inputField value="{!purchaseOrder.Purchase_Frequency__c}" required="true" />
                <apex:inputField value="{!purchaseOrder.Customer_Ordered_Quantity__c}" required="true" />
                 <apex:inputField value="{!purchaseOrder.Pre_shipment_Inspection_required__c}" required="true" />
                
                   
                    <apex:inputField value="{!purchaseOrder.Customer_Price__c}"/>
                    
                     <apex:inputField value="{!purchaseOrder.Credit_Limit__c}"/>
                    <apex:inputField value="{!purchaseOrder.Bill_Submission_Period__c}"/> 
               <apex:inputField value="{!purchaseOrder.CurrencyIsoCode}"/>
                
            </apex:PageBlockSection>
            
            <apex:pageBlockSection title="Quote Details" columns="1" collapsible="false">
                <apex:inputField value="{!purchaseOrder.Quote__c}"/>
                <apex:inputField value="{!purchaseOrder.Company__c}"/>
                 <apex:inputField value="{!purchaseOrder.Delivery_Address__c}" required="true" />
            </apex:PageBlockSection>
            
            <apex:pageBlockSection title="New Flash Details" columns="2" collapsible="false" >
            
            
            
        <apex:inputField value="{!purchaseOrder.Application_Area__c}"   />
                       
              
                <apex:inputField value="{!purchaseOrder.Remarks__c}"/>
      

                                        
            </apex:PageBlockSection>
            
            <apex:pageBlockSection title="Upload Purchase Order" columns="2" collapsible="false">
                <apex:pageBlockSectionItem >
                <apex:outputLabel value="File" for="file" />
                
            <apex:inputFile value="{!tAttachment.Body}" filename="{!tAttachment.Name}" filesize="{!tAttachment.BodyLength}" contentType="{!tAttachment.ContentType}" />
          
                </apex:pageBlockSectionItem>
            </apex:PageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>


 
Hi all

I am facing one problem like i have created a vf page for record saving.when i am saving one record it is saving
but when i am saving more than one record at a time it is not saving.can any one help me..


User-added image
public class BankBookTestPage {

    public String message = System.CurrentPagereference().getParameters().get('msg');
    public List<AccountWrapper> wrappers {get; set;}
    public List<AccountWrapper> wrappers1 {get; set;}
    public List<MasterTest__c> master {get; set;}
    public List<BankBookTest__c> bankbook {get; set;}    
    public static Integer toDelIdent {get; set;}
    public static Integer addCount {get; set;}
    private Integer nextIdent=1;    
    
    public BankBookTestPage(){
        init();
    }
    
    private void init(){
        wrappers=new List<AccountWrapper>();
        Wrappers1=new List<AccountWrapper>();
        for (Integer idx=0; idx<1; idx++){
            wrappers.add(new AccountWrapper(nextIdent++));
            wrappers1.add(new AccountWrapper(nextIdent++));
                    
        }
    }
    public void delWrapper(){
        Integer toDelPos=-1;
        for (Integer idx=0; idx<wrappers.size(); idx++){
           if (wrappers[idx].ident==toDelIdent){
                toDelPos=idx;
            }
        }        
        if (-1!=toDelPos){
            wrappers.remove(toDelPos);
            
        }
        
  
  }
  
  
  
 /* public void delWrapper()
{
    Integer toDelPos = -1;
    for( Integer idx = 0; idx < wrappers.size(); idx++ )
    {
        if( wrappers[idx].ident == toDelIdent )
        {
            toDelPos = idx;
        }
    }       

    if( toDelPos != -1 )
    {
        BankBookTest__c bk = wrappers.get( toDelPos ).acc;
        wrappers.remove( toDelPos );
        
        delete bk;
    }
}*/
    

    public void addRows(){
    
    List<BankBookTest__c> accs=new List<BankBookTest__c>();
        for (AccountWrapper wrap : wrappers){
            accs.add(wrap.acc);
        }        
       // Upsert accs;
    
    
        AccountWrapper objAccWrapper;
        for (Integer idx=0; idx<addCount; idx++){
            objAccWrapper = new AccountWrapper(nextIdent++);
            if(!wrappers.isEmpty()){
                objAccWrapper.acc.BankAccount__c= wrappers[0].acc.BankAccount__c;
                objAccWrapper.acc.Date__c= wrappers[0].acc.Date__c;
                objAccWrapper.acc.Transaction_Type__c= wrappers[0].acc.Transaction_Type__c;
                
            }
            wrappers.add(objAccWrapper);
        }
    }
    public PageReference save(){
    try{
        List<BankBookTest__c> accs=new List<BankBookTest__c>();
        for (AccountWrapper wrap : wrappers){
            accs.add(wrap.acc);
        }        
        Upsert accs;
        
        //return new PageReference('/' + Schema.getGlobalDescribe().get('BankBookTest__c').getDescribe().getKeyPrefix() + '/o');
       init();
        }
        catch(Exception e)
        {  
        //ApexPages.Message myMsg = new  ApexPages.Message(ApexPages.Severity.ERROR,'Sorry...... You have entered DUPLICATE MASTER CODE' );
           // ApexPages.addMessage(myMsg); 
         
           Apexpages.addMessage(new Apexpages.message(ApexPages.Severity.Error,'Please enter the field value'));
       } 
        return null; 
  
 
 
   
    }
    
    public class AccountWrapper{
        public BankBookTest__c acc {get; private set;}
        public Integer ident {get; private set;}
        public AccountWrapper(Integer inIdent){
            ident=inIdent;
            acc=new BankBookTest__c();
        }
    }
}

 
Hi Friends

I have one sound challenge in my job like i have 10 group with record .i want to design a report uisng vf page which is gruoping the record ..User-added image
Hi all

I have a issue on my goal which is making problem .I have two object(Account and Object__c) both are in realtionship
In account object i have a picklist field with value(NEW and OLD).for example i have created a record in account object with picklist value NEW.
my rerquirment is when i will be create record on Object__c ,after creation of record the picklist value on Account object automatically changed to OLD.How it is possible.anybody have idea?
Hi All
How to design this of vf page..

User-added image
Hi All
I have more than 10000 record in my custom object ,so how to delete all record automatically uisng custom bottom

 
Hi all

How to upsert csv file using command line data loder if dont have any external id
Hi

I have created a custom button for vf page using javascript.but its showing error like ....
A problem with the OnClick JavaScript for this button or link was encountered:

missing ; before statement
Hi Guys

I am facing one standard limitation issue long time.i have created a page for file uploading which is working fine for me,but problem is when i am uploading more 135 KB file its showing 135KB exceed limitation.I have go through some blogspot and finaly used Transient key word but its showing same.....How to achieve this issue any idea....
 
public class NewSalesConfirmationExtension {
    public Purchase_Order__c purchaseOrder{get;set;}
    public Attachment attachment {get;set;}
    public boolean showC1RecordType {get;set;}
    public boolean showC2RecordType {get;set;} 
    
    private Id c1RecordTypeId; 
    private Id c2RecordTypeId;
    
    public NewSalesConfirmationExtension(ApexPages.StandardController controller) {
        c1RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C1').getRecordTypeId();
        c2RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C2').getRecordTypeId();
        
        purchaseOrder = new Purchase_Order__c();
        purchaseOrder = (Purchase_Order__c)controller.getRecord();
        
        String isButtonClicked = Apexpages.currentPage().getParameters().get('setDefaultValues');
        if(isButtonClicked == 'true'){
            setDefaultValues();
        }
        
        showC1RecordType = false;
        showC2RecordType = false;
        attachment = new Attachment();
        
        
        if(purchaseOrder.RecordTypeId == c1RecordTypeId){
            showC1RecordType = true;
            showC2RecordType = false;
        }
        else if(purchaseOrder.RecordTypeId == c2RecordTypeId){
            showC1RecordType = false;
            showC2RecordType = true;
        }
        
    }
    
     public void setDefaultValues(){
        String quoteId = Apexpages.currentPage().getParameters().get('quoteId');
        Quote__c quote = [Select o.id, o.name, o.Quantity_formula__c, o.Opportunity_Product_Detail__r.Opportunity__c,
                    o.Opportunity__c, o.Record_type_name__c,o.Company_Name__c,Opportunity_Product_Detail__r.Opportunity__r.Account__c from Quote__c o WHERE O.id=:quoteId];
        //system.assert(false,quote);     
        purchaseOrder.Opportunity__c = quote.Opportunity_Product_Detail__r.Opportunity__c;
        purchaseOrder.Quote__c = quote.id;
        purchaseOrder.Company__c = quote.Opportunity_Product_Detail__r.Opportunity__r.Account__c;
        
        if(quote.Record_type_name__c == 'C1'){
            purchaseOrder.RecordTypeId = c1RecordTypeId;
        }
        else {
            purchaseOrder.RecordTypeId = c2RecordTypeId;
        }
    }
    public PageReference save(){
        if(attachment.Body == null){
            Apexpages.addMessage(new Apexpages.Message(Apexpages.Severity.ERROR, 'Please upload recent Purchase Order  before saving the record'));
            return null;
        }
        else{
            try{
                insert purchaseOrder;
                
                attachment.OwnerId = UserInfo.getUserId();
                attachment.ParentId = purchaseOrder.id;
                insert attachment;
                
                return new PageReference('/'+purchaseOrder.id);
            }
            catch(DMLException e){
                ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,e.getMessage()));
                return null;
            }
        }
    }
}

 
Hi all
I have created a Vf Page for file uploading.when i am uploading file and going to save the record its showing error

Visualforce ErrorHelp for this Page
System.NullPointerException: Attempt to de-reference a null object
Error is in expression '{!save}' in component <apex:commandButton> in page newsalesconfirmation: Class.NewSalesConfirmationExtension.save: line 55, column 1

 
public class NewSalesConfirmationExtension {
    public Purchase_Order__c purchaseOrder{get;set;}
    public Transient Attachment attachment {get;set;}
    public boolean showC1RecordType {get;set;}
    public boolean showC2RecordType {get;set;} 
    
    private Id c1RecordTypeId; 
    private Id c2RecordTypeId;
    
    public NewSalesConfirmationExtension(ApexPages.StandardController controller) {
        c1RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C1').getRecordTypeId();
        c2RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C2').getRecordTypeId();
        
        purchaseOrder = new Purchase_Order__c();
        purchaseOrder = (Purchase_Order__c)controller.getRecord();
        
        String isButtonClicked = Apexpages.currentPage().getParameters().get('setDefaultValues');
        if(isButtonClicked == 'true'){
            setDefaultValues();
        }
        
        showC1RecordType = false;
        showC2RecordType = false;
        attachment = new Attachment();
        
        
        if(purchaseOrder.RecordTypeId == c1RecordTypeId){
            showC1RecordType = true;
            showC2RecordType = false;
        }
        else if(purchaseOrder.RecordTypeId == c2RecordTypeId){
            showC1RecordType = false;
            showC2RecordType = true;
        }
        
    }
    
     public void setDefaultValues(){
        String quoteId = Apexpages.currentPage().getParameters().get('quoteId');
        Quote__c quote = [Select o.id, o.name, o.Quantity_formula__c, o.Opportunity_Product_Detail__r.Opportunity__c,
                    o.Opportunity__c, o.Record_type_name__c,o.Company_Name__c,Opportunity_Product_Detail__r.Opportunity__r.Account__c from Quote__c o WHERE O.id=:quoteId];
        //system.assert(false,quote);     
        purchaseOrder.Opportunity__c = quote.Opportunity_Product_Detail__r.Opportunity__c;
        purchaseOrder.Quote__c = quote.id;
        purchaseOrder.Company__c = quote.Opportunity_Product_Detail__r.Opportunity__r.Account__c;
        
        if(quote.Record_type_name__c == 'C1'){
            purchaseOrder.RecordTypeId = c1RecordTypeId;
        }
        else {
            purchaseOrder.RecordTypeId = c2RecordTypeId;
        }
    }
    public PageReference save(){
        if(attachment.Body == null){
            Apexpages.addMessage(new Apexpages.Message(Apexpages.Severity.ERROR, 'Please upload recent Purchase Order  before saving the record'));
            return null;
        }
        else{
            try{
                insert purchaseOrder;
                
                attachment.OwnerId = UserInfo.getUserId();
                attachment.ParentId = purchaseOrder.id;
                insert attachment;
                
                return new PageReference('/'+purchaseOrder.id);
            }
            catch(DMLException e){
                ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,e.getMessage()));
                return null;
            }
        }
    }
}
----------------------------------------------------------------------------------------------

<apex:page standardController="Purchase_Order__c" extensions="NewSalesConfirmationExtension">
    <apex:sectionHeader title="Sale Confirmation Orders" subtitle="{!purchaseOrder.Name}" />
      <apex:form enctype="multipart/form-data">
        <apex:pageMessages ></apex:pageMessages>
        <apex:pageBlock title="Sale Confirmation Order Edit">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
                <apex:commandButton action="{!cancel}" value="Cancel"/>
            </apex:pageBlockButtons>
            
            <apex:pageBlockSection title="Information" columns="2" collapsible="false" rendered="{!showC1RecordType}">
                <apex:inputField value="{!purchaseOrder.Opportunity__c}"/>
                <apex:inputField value="{!purchaseOrder.Sale_Confirmation_Order_Number__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.GRN_needed_for_Bill_Processing__c}"/>
                <apex:inputField value="{!purchaseOrder.Sale_Confirmation_Order_Date__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.No_of_Days_for_collecting_GRN__c}"/>
                <apex:inputField value="{!purchaseOrder.Pre_shipment_Inspection_required__c}" required="true" />
              
                <apex:inputField value="{!purchaseOrder.Purchase_Frequency__c}" required="true" />
                <apex:inputField value="{!purchaseOrder.Customer_Ordered_Quantity__c}" required="true" />
                <apex:inputField value="{!purchaseOrder.Credit_Limit__c}"/>
                   
                    <apex:inputField value="{!purchaseOrder.Customer_Price__c}"/>
                     <apex:inputField value="{!purchaseOrder.CurrencyIsoCode}"/>
                <apex:inputField value="{!purchaseOrder.Bill_Submission_Period__c}"/>
               
                <!---<apex:inputField value="{!purchaseOrder.New_Flash_Aidc_Email_sent__c}"/>--->
               
               
               <!--- <apex:inputField value="{!purchaseOrder.New_Flash_Email_sent__c}"/>--->
                <apex:inputField value="{!purchaseOrder.Committed_Dispatch_Date__c}" required="true"/>
              
               <!-- <apex:inputField value="{!purchaseOrder.PO_Uploaded__c}"/>
                <apex:inputField value="{!purchaseOrder.Try__c}"/>
                <apex:inputField value="{!purchaseOrder.CountAttachment__c}"/>--->
            </apex:PageBlockSection>
            
            <apex:pageBlockSection title="Information" columns="2" collapsible="false" rendered="{!showC2RecordType}">
                <apex:inputField value="{!purchaseOrder.Opportunity__c}"/>
                <apex:inputField value="{!purchaseOrder.Sale_Confirmation_Order_Number__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.GRN_needed_for_Bill_Processing__c}"/>
                <apex:inputField value="{!purchaseOrder.Sale_Confirmation_Order_Date__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.No_of_Days_for_collecting_GRN__c}"/>
                <apex:inputField value="{!purchaseOrder.Committed_Dispatch_Date__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.Credit_Limit__c}"/>
                <apex:inputField value="{!purchaseOrder.Customer_Ordered_Quantity__c}"/>
                <apex:inputField value="{!purchaseOrder.CurrencyIsoCode}"/>
                <apex:inputField value="{!purchaseOrder.Customer_Price__c}"/>
                <apex:inputField value="{!purchaseOrder.Purchase_Frequency__c}" required="true" />
                <apex:inputField value="{!purchaseOrder.Bill_Submission_Period__c}"/>
                <apex:inputField value="{!purchaseOrder.Application_Area__c}"/>
               
                <!---<apex:inputField value="{!purchaseOrder.CountAttachment__c}"/>
                <apex:inputField value="{!purchaseOrder.Try__c}"/>
                <apex:inputField value="{!purchaseOrder.New_Flash_Email_sent__c}"/>
                 <apex:inputField value="{!purchaseOrder.New_Flash_Aidc_Email_sent__c}"/>---->
            </apex:PageBlockSection>
            
            <apex:pageBlockSection title="Quote Details" columns="1" collapsible="false">
                <apex:inputField value="{!purchaseOrder.Quote__c}"/>
                <apex:inputField value="{!purchaseOrder.Company__c}"/>
                 <apex:inputField value="{!purchaseOrder.Delivery_Address__c}" required="true" />
            </apex:PageBlockSection>
            
            <apex:pageBlockSection title="New Flash Details" columns="2" collapsible="false">
                <apex:inputField value="{!purchaseOrder.Application_Area__c}"  rendered="{!showC1RecordType}"/>
                <apex:inputField value="{!purchaseOrder.Remarks__c}"/>
            </apex:PageBlockSection>
            
            <apex:pageBlockSection title="Upload Purchase Order" columns="2" collapsible="false">
                <apex:pageBlockSectionItem >
                <apex:outputLabel value="File" for="file" />
                <apex:inputFile value="{!attachment.body}" filename="{!attachment.name}" id="file"/>
                </apex:pageBlockSectionItem>
            </apex:PageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>


Class.NewSalesConfirmationExtension.save: line 55, column 1
Hi All
I have created a vf page  for file uploading.its working fine,but when i am uploading more than 135KB file its throwing error
Maximum view state size limit (135KB) exceeded
 
<apex:page standardController="Purchase_Order__c" extensions="NewSalesConfirmationExtension">
    <apex:sectionHeader title="Sale Confirmation Orders" subtitle="{!purchaseOrder.Name}" />
    <apex:form >
        <apex:pageMessages ></apex:pageMessages>
        <apex:pageBlock title="Sale Confirmation Order Edit">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
                <apex:commandButton action="{!cancel}" value="Cancel"/>
            </apex:pageBlockButtons>
            
            <apex:pageBlockSection title="Information" columns="2" collapsible="false" rendered="{!showC1RecordType}">
                <apex:inputField value="{!purchaseOrder.Opportunity__c}"/>
                <apex:inputField value="{!purchaseOrder.Sale_Confirmation_Order_Number__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.GRN_needed_for_Bill_Processing__c}"/>
                <apex:inputField value="{!purchaseOrder.Sale_Confirmation_Order_Date__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.No_of_Days_for_collecting_GRN__c}"/>
                <apex:inputField value="{!purchaseOrder.Pre_shipment_Inspection_required__c}" required="true" />
              
                <apex:inputField value="{!purchaseOrder.Purchase_Frequency__c}" required="true" />
                <apex:inputField value="{!purchaseOrder.Customer_Ordered_Quantity__c}" required="true" />
                <apex:inputField value="{!purchaseOrder.Credit_Limit__c}"/>
                   
                    <apex:inputField value="{!purchaseOrder.Customer_Price__c}"/>
                     <apex:inputField value="{!purchaseOrder.CurrencyIsoCode}"/>
                <apex:inputField value="{!purchaseOrder.Bill_Submission_Period__c}"/>
               
                <!---<apex:inputField value="{!purchaseOrder.New_Flash_Aidc_Email_sent__c}"/>--->
               
               
               <!--- <apex:inputField value="{!purchaseOrder.New_Flash_Email_sent__c}"/>--->
                <apex:inputField value="{!purchaseOrder.Committed_Dispatch_Date__c}" required="true"/>
              
               <!-- <apex:inputField value="{!purchaseOrder.PO_Uploaded__c}"/>
                <apex:inputField value="{!purchaseOrder.Try__c}"/>
                <apex:inputField value="{!purchaseOrder.CountAttachment__c}"/>--->
            </apex:PageBlockSection>
            
            <apex:pageBlockSection title="Information" columns="2" collapsible="false" rendered="{!showC2RecordType}">
                <apex:inputField value="{!purchaseOrder.Opportunity__c}"/>
                <apex:inputField value="{!purchaseOrder.Sale_Confirmation_Order_Number__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.GRN_needed_for_Bill_Processing__c}"/>
                <apex:inputField value="{!purchaseOrder.Sale_Confirmation_Order_Date__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.No_of_Days_for_collecting_GRN__c}"/>
                <apex:inputField value="{!purchaseOrder.Committed_Dispatch_Date__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.Credit_Limit__c}"/>
                <apex:inputField value="{!purchaseOrder.Customer_Ordered_Quantity__c}"/>
                <apex:inputField value="{!purchaseOrder.CurrencyIsoCode}"/>
                <apex:inputField value="{!purchaseOrder.Customer_Price__c}"/>
                <apex:inputField value="{!purchaseOrder.Purchase_Frequency__c}" required="true" />
                <apex:inputField value="{!purchaseOrder.Bill_Submission_Period__c}"/>
                <apex:inputField value="{!purchaseOrder.Application_Area__c}"/>
               
                <!---<apex:inputField value="{!purchaseOrder.CountAttachment__c}"/>
                <apex:inputField value="{!purchaseOrder.Try__c}"/>
                <apex:inputField value="{!purchaseOrder.New_Flash_Email_sent__c}"/>
                 <apex:inputField value="{!purchaseOrder.New_Flash_Aidc_Email_sent__c}"/>---->
            </apex:PageBlockSection>
            
            <apex:pageBlockSection title="Quote Details" columns="1" collapsible="false">
                <apex:inputField value="{!purchaseOrder.Quote__c}"/>
                <apex:inputField value="{!purchaseOrder.Company__c}"/>
                 <apex:inputField value="{!purchaseOrder.Delivery_Address__c}" required="true" />
            </apex:PageBlockSection>
            
            <apex:pageBlockSection title="New Flash Details" columns="2" collapsible="false">
                <apex:inputField value="{!purchaseOrder.Application_Area__c}"  rendered="{!showC1RecordType}"/>
                <apex:inputField value="{!purchaseOrder.Remarks__c}"/>
            </apex:PageBlockSection>
            
            <apex:pageBlockSection title="Upload Purchase Order" columns="2" collapsible="false">
                <apex:pageBlockSectionItem >
                <apex:outputLabel value="File" for="file" />
                <apex:inputFile value="{!attachment.body}" filename="{!attachment.name}" id="file"/>
                </apex:pageBlockSectionItem>
            </apex:PageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>


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


public class NewSalesConfirmationExtension {
    public Purchase_Order__c purchaseOrder{get;set;}
    public Attachment attachment {get;set;}
    public boolean showC1RecordType {get;set;}
    public boolean showC2RecordType {get;set;} 
    
    private Id c1RecordTypeId; 
    private Id c2RecordTypeId;
    
    public NewSalesConfirmationExtension(ApexPages.StandardController controller) {
        c1RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C1').getRecordTypeId();
        c2RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C2').getRecordTypeId();
        
        purchaseOrder = new Purchase_Order__c();
        purchaseOrder = (Purchase_Order__c)controller.getRecord();
        
        String isButtonClicked = Apexpages.currentPage().getParameters().get('setDefaultValues');
        if(isButtonClicked == 'true'){
            setDefaultValues();
        }
        
        showC1RecordType = false;
        showC2RecordType = false;
        attachment = new Attachment();
        
        
        if(purchaseOrder.RecordTypeId == c1RecordTypeId){
            showC1RecordType = true;
            showC2RecordType = false;
        }
        else if(purchaseOrder.RecordTypeId == c2RecordTypeId){
            showC1RecordType = false;
            showC2RecordType = true;
        }
        
    }
    
     public void setDefaultValues(){
        String quoteId = Apexpages.currentPage().getParameters().get('quoteId');
        Quote__c quote = [Select o.id, o.name, o.Quantity_formula__c, o.Opportunity_Product_Detail__r.Opportunity__c,
                    o.Opportunity__c, o.Record_type_name__c,o.Company_Name__c,Opportunity_Product_Detail__r.Opportunity__r.Account__c from Quote__c o WHERE O.id=:quoteId];
        //system.assert(false,quote);     
        purchaseOrder.Opportunity__c = quote.Opportunity_Product_Detail__r.Opportunity__c;
        purchaseOrder.Quote__c = quote.id;
        purchaseOrder.Company__c = quote.Opportunity_Product_Detail__r.Opportunity__r.Account__c;
        
        if(quote.Record_type_name__c == 'C1'){
            purchaseOrder.RecordTypeId = c1RecordTypeId;
        }
        else {
            purchaseOrder.RecordTypeId = c2RecordTypeId;
        }
    }
    public PageReference save(){
        if(attachment.Body == null){
            Apexpages.addMessage(new Apexpages.Message(Apexpages.Severity.ERROR, 'Please upload recent Purchase Order  before saving the record'));
            return null;
        }
        else{
            try{
                insert purchaseOrder;
                
                attachment.OwnerId = UserInfo.getUserId();
                attachment.ParentId = purchaseOrder.id;
                insert attachment;
                
                return new PageReference('/'+purchaseOrder.id);
            }
            catch(DMLException e){
                ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,e.getMessage()));
                return null;
            }
        }
    }
}

 
Hi Guys

I am facing issue on commandline data loader when i run my script.how to achieve this ?
C:\Program Files (x86)\salesforce.com\Data Loader\bin>process.bat "D:\test1" Inv
oiceUpsert
2016-03-31 13:08:48,286 INFO  [main] controller.Controller initLog (Controller.j
ava:389) - Using built-in logging configuration, no log-conf.xml in C:\Program F
iles (x86)\salesforce.com\Data Loader\bin\log-conf.xml
2016-03-31 13:08:48,298 INFO  [main] controller.Controller initLog (Controller.j
ava:391) - The log has been initialized
2016-03-31 13:08:48,304 INFO  [main] process.ProcessConfig getBeanFactory (Proce
ssConfig.java:103) - Loading process configuration from config file: D:\test1\pr
ocess-conf.xml
2016-03-31 13:08:48,501 INFO  [main] xml.XmlBeanDefinitionReader loadBeanDefinit
ions (XmlBeanDefinitionReader.java:315) - Loading XML bean definitions from file
 [D:\test1\process-conf.xml]
2016-03-31 13:08:48,635 INFO  [InvoiceUpsert] controller.Controller initConfig (
Controller.java:327) - config dir created at D:\test1
2016-03-31 13:08:48,654 INFO  [InvoiceUpsert] controller.Controller initConfig (
Controller.java:355) - The controller config has been initialized
2016-03-31 13:08:48,656 INFO  [InvoiceUpsert] process.ProcessRunner run (Process
Runner.java:116) - Initializing process engine
2016-03-31 13:08:48,658 INFO  [InvoiceUpsert] process.ProcessRunner run (Process
Runner.java:119) - Loading parameters
2016-03-31 13:08:49,679 ERROR [InvoiceUpsert] config.Config decryptProperty (Con
fig.java:692) - Error loading parameter: sfdc.password of type: java.lang.String

javax.crypto.BadPaddingException: Given final block not properly padded
        at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
        at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
        at com.sun.crypto.provider.DESCipher.engineDoFinal(DashoA13*..)
        at javax.crypto.Cipher.doFinal(DashoA13*..)
        at com.salesforce.dataloader.security.EncryptionUtil.decryptString(Encry
ptionUtil.java:210)
        at com.salesforce.dataloader.config.Config.decryptProperty(Config.java:6
86)
        at com.salesforce.dataloader.config.Config.postLoad(Config.java:638)
        at com.salesforce.dataloader.config.Config.loadParameterOverrides(Config
.java:664)
        at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.jav
a:120)
        at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.jav
a:100)
        at com.salesforce.dataloader.process.ProcessRunner.main(ProcessRunner.ja
va:253)
2016-03-31 13:08:49,692 FATAL [main] process.ProcessRunner topLevelError (Proces
sRunner.java:238) - Unable to run process InvoiceUpsert
java.lang.RuntimeException: com.salesforce.dataloader.exception.ParameterLoadExc
eption: Error loading parameter: sfdc.password of type: java.lang.String
        at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.jav
a:162)
        at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.jav
a:100)
        at com.salesforce.dataloader.process.ProcessRunner.main(ProcessRunner.ja
va:253)
Caused by: com.salesforce.dataloader.exception.ParameterLoadException: Error loa
ding parameter: sfdc.password of type: java.lang.String
        at com.salesforce.dataloader.config.Config.decryptProperty(Config.java:6
93)
        at com.salesforce.dataloader.config.Config.postLoad(Config.java:638)
        at com.salesforce.dataloader.config.Config.loadParameterOverrides(Config
.java:664)
        at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.jav
a:120)
        ... 2 more
Caused by: javax.crypto.BadPaddingException: Given final block not properly padd
ed
        at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
        at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
        at com.sun.crypto.provider.DESCipher.engineDoFinal(DashoA13*..)
        at javax.crypto.Cipher.doFinal(DashoA13*..)
        at com.salesforce.dataloader.security.EncryptionUtil.decryptString(Encry
ptionUtil.java:210)
        at com.salesforce.dataloader.config.Config.decryptProperty(Config.java:6
86)
        ... 5 more
C:\Program Files (x86)\salesforce.com\Data Loader\bin>^A

 
Hi Friends
The following is my Apex class i have written test class for this, i coverd upto 59% i want to make it increase. can you help me to fulfill this.
 
public class FormCurriculumController { 
  

public Purchase_Order__c curriculum {get; set;}
public Boolean privacy {get; set;}
public Boolean saved {get; set;}
public String styleClass {get; set;}
// Allegato
public Transient Blob resume {get; set;}
public String contentType {get; set;}
public String fileName {get; set;}
      
    public boolean showC1RecordType {get;set;}
    public boolean showC2RecordType {get;set;} 
    
    private Id c1RecordTypeId; 
    private Id c2RecordTypeId;


//ublic FormCurriculumController () {
    //curriculum = new Purchase_Order__c();
    //saved = false;
//}

  public FormCurriculumController(ApexPages.StandardController controller) {

        c1RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C1').getRecordTypeId();
        c2RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C2').getRecordTypeId();
        
        curriculum= new Purchase_Order__c();
        curriculum= (Purchase_Order__c)controller.getRecord();
         
        String isButtonClicked = Apexpages.currentPage().getParameters().get('setDefaultValues');
        if(isButtonClicked == 'true'){
            setDefaultValues();
        }
        
        showC1RecordType = false;
        showC2RecordType = false;
       
        if(curriculum.RecordTypeId == c1RecordTypeId){
            showC1RecordType = true;
            showC2RecordType = false;
        }
        else if(curriculum.RecordTypeId == c2RecordTypeId){
            showC1RecordType = false;
            showC2RecordType = true;
        }
        
    }
    
     public void setDefaultValues(){
        String quoteId = Apexpages.currentPage().getParameters().get('quoteId');
        Quote__c quote = [Select o.id, o.name, o.Quantity_formula__c, o.Opportunity_Product_Detail__r.Opportunity__c,
                    o.Opportunity__c, o.Record_type_name__c,o.Company_Name__c,Opportunity_Product_Detail__r.Opportunity__r.Account__c from Quote__c o WHERE O.id=:quoteId];
        //system.assert(false,quote);     
        curriculum.Opportunity__c = quote.Opportunity_Product_Detail__r.Opportunity__c;
        curriculum.Quote__c = quote.id;
        curriculum.Company__c = quote.Opportunity_Product_Detail__r.Opportunity__r.Account__c;
        
        if(quote.Record_type_name__c == 'C1'){
            curriculum.RecordTypeId = c1RecordTypeId;
        }
        else {
            curriculum.RecordTypeId = c2RecordTypeId;
        }
    }

    


public PageReference save() {
    try {
        // Validazione effettuata qui perchè il required sull'inputCheckbox non è utilizzabile
        if (!privacy) {
        
            ApexPages.Message reqMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Please upload recent Purchase Order  before saving the record');
            ApexPages.addMessage(reqMsg);
            return null;
        }

        // Inserisce il record
        
       
        
        
        insert(curriculum);
        // Inserisce l'allegato
        if (resume != null) {
            Attachment attach = new Attachment();
            attach.Body = resume;
            attach.Name = fileName;
            attach.ContentType= contentType;
            attach.ParentId = curriculum.id;                
            try {
                insert(attach);
                return new PageReference('/'+curriculum.id);

            } catch (Exception ex) {
                // TODO fare il roolback dell'inserimento del curriculum?

                ApexPages.addMessages(ex);
                return null;
            }                    
        }

        //Papagni 03/09/2013 - update curriculum per fare scattare il trigger di after che invia la mail
        update curriculum;

        saved = true;

    } 
    catch(Exception ex) {
        ApexPages.addMessages(ex);  
    }
    return null;   
}
}
@IsTest
public class TestFormCurriculumController  
{
static testMethod void TestMethodFormCurriculumController  ()
{

        account a=new account(name='test',Region__c='East');
        insert a;
        
        Master_Product__c mp=new Master_Product__c(name='test name',Product_Code__c='c2');
        insert mp;
        
        contact c=new contact(firstname='Meenakshmi',lastname='Goswami',Designation__c='Developer',Accountid=a.id);
        insert c;


        Opportunity2__c op=new Opportunity2__c(Name='test1',Account__c=a.id,Master_Product__c=mp.id,Technical_Bid_date__c=date.Today(),Type_of_Business__c='Regular',Contact_Person__c=c.id);
        insert op;
     
        Opportunity_Product_Detail__c opd=new Opportunity_Product_Detail__c(Opportunity__c=op.id,Company__c=a.id,Quantity__c=10,Make__c='Datalogic-Barcode Scanner', Model__c='S4M 203 Dpi');
        insert opd;
        
        Quote__c qt=new Quote__c(Opportunity_Product_Detail__c=opd.id,Basic_Price_per_1000__c=100,Basic_Price_Each_item__c=200,Purpose_of_Sales__c='SEZ',Declaration_form_be_provided__c='No');
        insert qt;
        
        Quote__c qt1=[select Quantity_formula__c from Quote__c where id=:qt.id];
        system.debug('--------Quote quantity--------'+qt1.Quantity_formula__c );
        
        RecordType rt = [Select id,name from RecordType where SobjectType='Purchase_Order__c' and Name='C1'];
        
        Purchase_Order__c sco=new Purchase_Order__c(RecordTypeId=rt.id,Quote__c=qt.id,Opportunity__c=op.id,Sale_Confirmation_Order_Date__c=date.Today());
        sco.Sale_Confirmation_Order_Number__c='100';
      
       
        insert sco;
    
         test.startTest();
         PageReference pageRef = Page.FormCurriculumController ;
         Test.setCurrentPage(pageRef);
         ApexPages.Standardcontroller sc = new ApexPages.Standardcontroller(sco);
         
         ApexPages.currentPage().getParameters().put('Id',sco.id);
         FormCurriculumController  objMyController= new FormCurriculumController  (sc);
         
         
         
         
         
         
         /*ApexPages.currentPage().getParameters().put('Id',emp.id);
            ApexPages.currentPage().getParameters().put('setDefaultValues','true');
            ApexPages.currentPage().getParameters().put('id',sco.id);
           
            ApexPages.StandardController stdLead = new ApexPages.StandardController(sco);
            NewSalesConfirmationExtension objMyController  = new NewSalesConfirmationExtension (stdLead);*/
            objMyController.save();
            
         
        test.stopTest();
        
        
        }
static testMethod void TestMethodFormCurriculumController1()
{

 account a=new account(name='test',Region__c='East');
        insert a;
        
        Master_Product__c mp=new Master_Product__c(name='test name',Product_Code__c='c2');
        insert mp;
        
        contact c=new contact(firstname='Meenakshmi',lastname='Goswami',Designation__c='Developer',Accountid=a.id);
        insert c;


        Opportunity2__c op=new Opportunity2__c(Name='test1',Account__c=a.id,Master_Product__c=mp.id,Technical_Bid_date__c=date.Today(),Type_of_Business__c='Regular',Contact_Person__c=c.id);
        insert op;
     
        Opportunity_Product_Detail__c opd=new Opportunity_Product_Detail__c(Opportunity__c=op.id,Company__c=a.id,Quantity__c=10,Make__c='Datalogic-Barcode Scanner', Model__c='S4M 203 Dpi');
        insert opd;
        
        RecordType quoteRt = [Select id,name from RecordType where SobjectType='Quote__c' and Name='C2'];
        
        Quote__c qt=new Quote__c(RecordTypeId=quoteRt.id,Opportunity_Product_Detail__c=opd.id,Basic_Price_per_1000__c=100,Basic_Price_Each_item__c=200,Purpose_of_Sales__c='SEZ',Declaration_form_be_provided__c='No');
        insert qt;
        
        Quote__c qt1=[select Quantity_formula__c from Quote__c where id=:qt.id];
        system.debug('--------Quote quantity--------'+qt1.Quantity_formula__c );
        
        RecordType rt = [Select id,name from RecordType where SobjectType='Purchase_Order__c' and Name='C2'];
        
        Purchase_Order__c sco=new Purchase_Order__c(RecordTypeId=rt.id,Quote__c=qt.id,Opportunity__c=op.id,Sale_Confirmation_Order_Date__c=date.Today());
        sco.Sale_Confirmation_Order_Number__c='100';
        insert sco;
        
         test.startTest();
            //ApexPages.currentPage().getParameters().put('id',sco.id);
            ApexPages.currentPage().getParameters().put('setDefaultValues','true');
            ApexPages.currentPage().getParameters().put('quoteId',qt.id);
            ApexPages.StandardController stdLead = new ApexPages.StandardController(sco);
            FormCurriculumController  objMyController  = new FormCurriculumController (stdLead);
           
            objMyController.attach.body=bodyBlob ;
           
            
            objMyController.save();
            
          
        
        test.stopTest();
        
        }
}


 
Error Message
System.NullPointerException: Attempt to de-reference a null object
Error is in expression '{!doUploadFile}' in component <apex:commandButton> in page testing: Class.CCW_UploadFileController.doUploadFile: line 69, column 1
Class.CCW_UploadFileController.doUploadFile: line 69, column 1
 
public with sharing class CCW_UploadFileController {

    public Purchase_Order__c purchaseOrder{get;set;}
    public  Attachment tAttachment{get;set;}
                                        
                                    
    
    public boolean showC1RecordType {get;set;}
    public boolean showC2RecordType {get;set;} 
    
    private Id c1RecordTypeId; 
    private Id c2RecordTypeId;
    
 
    public CCW_UploadFileController(ApexPages.StandardController controller)
    {
 
       
        this.tAttachment = new Attachment();
        c1RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C1').getRecordTypeId();
        c2RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C2').getRecordTypeId();
        
        purchaseOrder = new Purchase_Order__c();
        purchaseOrder = (Purchase_Order__c)controller.getRecord();
         
        String isButtonClicked = Apexpages.currentPage().getParameters().get('setDefaultValues');
        if(isButtonClicked == 'true'){
            setDefaultValues();
        }
        
        showC1RecordType = false;
        showC2RecordType = false;
        tAttachment= new Attachment();
        
        
        if(purchaseOrder.RecordTypeId == c1RecordTypeId){
            showC1RecordType = true;
            showC2RecordType = false;
        }
        else if(purchaseOrder.RecordTypeId == c2RecordTypeId){
            showC1RecordType = false;
            showC2RecordType = true;
        }
        
    }
    
     public void setDefaultValues(){
        String quoteId = Apexpages.currentPage().getParameters().get('quoteId');
        Quote__c quote = [Select o.id, o.name, o.Quantity_formula__c, o.Opportunity_Product_Detail__r.Opportunity__c,
                    o.Opportunity__c, o.Record_type_name__c,o.Company_Name__c,Opportunity_Product_Detail__r.Opportunity__r.Account__c from Quote__c o WHERE O.id=:quoteId];
        //system.assert(false,quote);     
        purchaseOrder.Opportunity__c = quote.Opportunity_Product_Detail__r.Opportunity__c;
        purchaseOrder.Quote__c = quote.id;
        purchaseOrder.Company__c = quote.Opportunity_Product_Detail__r.Opportunity__r.Account__c;
        
        if(quote.Record_type_name__c == 'C1'){
            purchaseOrder.RecordTypeId = c1RecordTypeId;
        }
        else {
            purchaseOrder.RecordTypeId = c2RecordTypeId;
        }
    }
 
    
 
   
    public PageReference doUploadFile(){
 
        if(tAttachment.Body == null){
            Apexpages.addMessage(new Apexpages.Message(Apexpages.Severity.ERROR, 'Please upload recent Purchase Order  before saving the record'));
            return null;
        }
        else{
            try{
                insert purchaseOrder;
                
              tAttachment.OwnerId = UserInfo.getUserId();
               tAttachment.ParentId = purchaseOrder.id;
              insert tAttachment;
                
                
                return new PageReference('/'+purchaseOrder.id);
            }
            catch(DMLException e){
                ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,e.getMessage()));
                return null;
            }
        }
    }
}
<apex:page standardController="Purchase_Order__c" extensions="CCW_UploadFileController">
    <apex:sectionHeader title="Sale Confirmation Orders" subtitle="{!purchaseOrder.Name}" />
      <apex:form enctype="multipart/form-data">
        <apex:pageMessages ></apex:pageMessages>
        <apex:pageBlock title="Sale Confirmation Order Edit">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!doUploadFile}" value="Save"/>
                <apex:commandButton action="{!cancel}" value="Cancel"/>
            </apex:pageBlockButtons>
            
            <apex:pageBlockSection title="Information" columns="2" collapsible="false" rendered="{!showC1RecordType}">
                <apex:inputField value="{!purchaseOrder.Opportunity__c}"/>
                <apex:inputField value="{!purchaseOrder.Sale_Confirmation_Order_Number__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.GRN_needed_for_Bill_Processing__c}"/>
                <apex:inputField value="{!purchaseOrder.Sale_Confirmation_Order_Date__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.No_of_Days_for_collecting_GRN__c}"/>
                <apex:inputField value="{!purchaseOrder.Pre_shipment_Inspection_required__c}" required="true" />
              
                <apex:inputField value="{!purchaseOrder.Purchase_Frequency__c}" required="true" />
                <apex:inputField value="{!purchaseOrder.Customer_Ordered_Quantity__c}" required="true" />
                <apex:inputField value="{!purchaseOrder.Credit_Limit__c}"/>
                   
                    <apex:inputField value="{!purchaseOrder.Customer_Price__c}"/>
                     <apex:inputField value="{!purchaseOrder.CurrencyIsoCode}"/>
                <apex:inputField value="{!purchaseOrder.Bill_Submission_Period__c}"/>
               
                <!---<apex:inputField value="{!purchaseOrder.New_Flash_Aidc_Email_sent__c}"/>--->
               
               
               <!--- <apex:inputField value="{!purchaseOrder.New_Flash_Email_sent__c}"/>--->
                <apex:inputField value="{!purchaseOrder.Committed_Dispatch_Date__c}" required="true"/>
              
               <!-- <apex:inputField value="{!purchaseOrder.PO_Uploaded__c}"/>
                <apex:inputField value="{!purchaseOrder.Try__c}"/>
                <apex:inputField value="{!purchaseOrder.CountAttachment__c}"/>--->
            </apex:PageBlockSection>
            
            <apex:pageBlockSection title="Information" columns="2" collapsible="false" rendered="{!showC2RecordType}">
                <apex:inputField value="{!purchaseOrder.Opportunity__c}"/>
                <apex:inputField value="{!purchaseOrder.Sale_Confirmation_Order_Number__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.GRN_needed_for_Bill_Processing__c}"/>
                <apex:inputField value="{!purchaseOrder.Sale_Confirmation_Order_Date__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.No_of_Days_for_collecting_GRN__c}"/>
                <apex:inputField value="{!purchaseOrder.Committed_Dispatch_Date__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.Credit_Limit__c}"/>
                <apex:inputField value="{!purchaseOrder.Customer_Ordered_Quantity__c}"/>
                <apex:inputField value="{!purchaseOrder.CurrencyIsoCode}"/>
                <apex:inputField value="{!purchaseOrder.Customer_Price__c}"/>
                <apex:inputField value="{!purchaseOrder.Purchase_Frequency__c}" required="true" />
                <apex:inputField value="{!purchaseOrder.Bill_Submission_Period__c}"/>
                <apex:inputField value="{!purchaseOrder.Application_Area__c}"/>
               
                <!---<apex:inputField value="{!purchaseOrder.CountAttachment__c}"/>
                <apex:inputField value="{!purchaseOrder.Try__c}"/>
                <apex:inputField value="{!purchaseOrder.New_Flash_Email_sent__c}"/>
                 <apex:inputField value="{!purchaseOrder.New_Flash_Aidc_Email_sent__c}"/>---->
            </apex:PageBlockSection>
            
            <apex:pageBlockSection title="Quote Details" columns="1" collapsible="false">
                <apex:inputField value="{!purchaseOrder.Quote__c}"/>
                <apex:inputField value="{!purchaseOrder.Company__c}"/>
                 <apex:inputField value="{!purchaseOrder.Delivery_Address__c}" required="true" />
            </apex:PageBlockSection>
            
            <apex:pageBlockSection title="New Flash Details" columns="2" collapsible="false">
                <apex:inputField value="{!purchaseOrder.Application_Area__c}"  rendered="{!showC1RecordType}"/>
                <apex:inputField value="{!purchaseOrder.Remarks__c}"/>
            </apex:PageBlockSection>
            
            <apex:pageBlockSection title="Upload Purchase Order" columns="2" collapsible="false">
                <apex:pageBlockSectionItem >
                <apex:outputLabel value="File" for="file" />
                
            <apex:inputFile value="{!tAttachment.Body}" filename="{!tAttachment.Name}" filesize="{!tAttachment.BodyLength}" contentType="{!tAttachment.ContentType}" />
          
                </apex:pageBlockSectionItem>
            </apex:PageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>


 
Hi Friends

I have created a vf page which uplaod file its working fine ,but i am facing problem when file is more than 135KB.i have used transient variable also
but facing same..Is there any other way to achieve this challenge.
public with sharing class CCW_UploadFileController {

    public Purchase_Order__c purchaseOrder{get;set;}
    public  Attachment tAttachment{get{
                                        if(tAttachment== null)
                                          tAttachment= new Attachment();
                                        return tAttachment;
                                     }set;}
    
    public boolean showC1RecordType {get;set;}
    public boolean showC2RecordType {get;set;} 
    
    private Id c1RecordTypeId; 
    private Id c2RecordTypeId;
    
 
    public CCW_UploadFileController(ApexPages.StandardController controller)
    {
 
       
        this.tAttachment = new Attachment();
        c1RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C1').getRecordTypeId();
        c2RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C2').getRecordTypeId();
        
        purchaseOrder = new Purchase_Order__c();
        purchaseOrder = (Purchase_Order__c)controller.getRecord();
         
        String isButtonClicked = Apexpages.currentPage().getParameters().get('setDefaultValues');
        if(isButtonClicked == 'true'){
            setDefaultValues();
        }
        
        showC1RecordType = false;
        showC2RecordType = false;
        tAttachment= new Attachment();
        
        
        if(purchaseOrder.RecordTypeId == c1RecordTypeId){
            showC1RecordType = true;
            showC2RecordType = false;
        }
        else if(purchaseOrder.RecordTypeId == c2RecordTypeId){
            showC1RecordType = false;
            showC2RecordType = true;
        }
        
    }
    
     public void setDefaultValues(){
        String quoteId = Apexpages.currentPage().getParameters().get('quoteId');
        Quote__c quote = [Select o.id, o.name, o.Quantity_formula__c, o.Opportunity_Product_Detail__r.Opportunity__c,
                    o.Opportunity__c, o.Record_type_name__c,o.Company_Name__c,Opportunity_Product_Detail__r.Opportunity__r.Account__c from Quote__c o WHERE O.id=:quoteId];
        //system.assert(false,quote);     
        purchaseOrder.Opportunity__c = quote.Opportunity_Product_Detail__r.Opportunity__c;
        purchaseOrder.Quote__c = quote.id;
        purchaseOrder.Company__c = quote.Opportunity_Product_Detail__r.Opportunity__r.Account__c;
        
        if(quote.Record_type_name__c == 'C1'){
            purchaseOrder.RecordTypeId = c1RecordTypeId;
        }
        else {
            purchaseOrder.RecordTypeId = c2RecordTypeId;
        }
    }
 
    
 
   
    public PageReference doUploadFile(){
 
        if(tAttachment.Body == null){
            Apexpages.addMessage(new Apexpages.Message(Apexpages.Severity.ERROR, 'Please upload recent Purchase Order  before saving the record'));
            return null;
        }
        else{
            try{
                insert purchaseOrder;
                
              tAttachment.OwnerId = UserInfo.getUserId();
               tAttachment.ParentId = purchaseOrder.id;
              insert tAttachment;
                
                
                return new PageReference('/'+purchaseOrder.id);
            }
            catch(DMLException e){
                ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,e.getMessage()));
                return null;
            }
        }
    }
}

 
Hi Guys

I am facing issue on commandline data loader when i run my script.how to achieve this ?
C:\Program Files (x86)\salesforce.com\Data Loader\bin>process.bat "D:\test1" Inv
oiceUpsert
2016-03-31 13:08:48,286 INFO  [main] controller.Controller initLog (Controller.j
ava:389) - Using built-in logging configuration, no log-conf.xml in C:\Program F
iles (x86)\salesforce.com\Data Loader\bin\log-conf.xml
2016-03-31 13:08:48,298 INFO  [main] controller.Controller initLog (Controller.j
ava:391) - The log has been initialized
2016-03-31 13:08:48,304 INFO  [main] process.ProcessConfig getBeanFactory (Proce
ssConfig.java:103) - Loading process configuration from config file: D:\test1\pr
ocess-conf.xml
2016-03-31 13:08:48,501 INFO  [main] xml.XmlBeanDefinitionReader loadBeanDefinit
ions (XmlBeanDefinitionReader.java:315) - Loading XML bean definitions from file
 [D:\test1\process-conf.xml]
2016-03-31 13:08:48,635 INFO  [InvoiceUpsert] controller.Controller initConfig (
Controller.java:327) - config dir created at D:\test1
2016-03-31 13:08:48,654 INFO  [InvoiceUpsert] controller.Controller initConfig (
Controller.java:355) - The controller config has been initialized
2016-03-31 13:08:48,656 INFO  [InvoiceUpsert] process.ProcessRunner run (Process
Runner.java:116) - Initializing process engine
2016-03-31 13:08:48,658 INFO  [InvoiceUpsert] process.ProcessRunner run (Process
Runner.java:119) - Loading parameters
2016-03-31 13:08:49,679 ERROR [InvoiceUpsert] config.Config decryptProperty (Con
fig.java:692) - Error loading parameter: sfdc.password of type: java.lang.String

javax.crypto.BadPaddingException: Given final block not properly padded
        at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
        at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
        at com.sun.crypto.provider.DESCipher.engineDoFinal(DashoA13*..)
        at javax.crypto.Cipher.doFinal(DashoA13*..)
        at com.salesforce.dataloader.security.EncryptionUtil.decryptString(Encry
ptionUtil.java:210)
        at com.salesforce.dataloader.config.Config.decryptProperty(Config.java:6
86)
        at com.salesforce.dataloader.config.Config.postLoad(Config.java:638)
        at com.salesforce.dataloader.config.Config.loadParameterOverrides(Config
.java:664)
        at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.jav
a:120)
        at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.jav
a:100)
        at com.salesforce.dataloader.process.ProcessRunner.main(ProcessRunner.ja
va:253)
2016-03-31 13:08:49,692 FATAL [main] process.ProcessRunner topLevelError (Proces
sRunner.java:238) - Unable to run process InvoiceUpsert
java.lang.RuntimeException: com.salesforce.dataloader.exception.ParameterLoadExc
eption: Error loading parameter: sfdc.password of type: java.lang.String
        at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.jav
a:162)
        at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.jav
a:100)
        at com.salesforce.dataloader.process.ProcessRunner.main(ProcessRunner.ja
va:253)
Caused by: com.salesforce.dataloader.exception.ParameterLoadException: Error loa
ding parameter: sfdc.password of type: java.lang.String
        at com.salesforce.dataloader.config.Config.decryptProperty(Config.java:6
93)
        at com.salesforce.dataloader.config.Config.postLoad(Config.java:638)
        at com.salesforce.dataloader.config.Config.loadParameterOverrides(Config
.java:664)
        at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.jav
a:120)
        ... 2 more
Caused by: javax.crypto.BadPaddingException: Given final block not properly padd
ed
        at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
        at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
        at com.sun.crypto.provider.DESCipher.engineDoFinal(DashoA13*..)
        at javax.crypto.Cipher.doFinal(DashoA13*..)
        at com.salesforce.dataloader.security.EncryptionUtil.decryptString(Encry
ptionUtil.java:210)
        at com.salesforce.dataloader.config.Config.decryptProperty(Config.java:6
86)
        ... 5 more
C:\Program Files (x86)\salesforce.com\Data Loader\bin>^A

 
Hi Friends

I have one issue facing a big challenge.i have two object Account and Object__c which have lookup relationship.i have one picklist in account object with value ABC and XYZ.my requirment is want two convert all existing picklist value XYZ to ABC in account object which have Object__c record .


Thanks
Hi
I have created a apex class for uploading file.but i am uplaoding any files its showing this error.how to achieve this error ?


System.NullPointerException: Attempt to de-reference a null object
Error is in expression '{!doUploadFile}' in component <apex:commandButton> in page scoupload: Class.SCOUpload.doUploadFile: line 74, column 1
Class.SCOUpload.doUploadFile: line 74, column 1
 
public with sharing class SCOUpload {
 
    /*
    *   attachment
    */
    public Purchase_Order__c purchaseOrder{get;set;}
 Public  Transient Attachment tAttachment{get;set;}
    public boolean showC1RecordType {get;set;}
    public boolean showC2RecordType {get;set;} 
    
    private Id c1RecordTypeId; 
    private Id c2RecordTypeId;
    
 
    /*
    *   constructor
    */
    public SCOUpload(ApexPages.StandardController controller)
    {
 
        //initialize attachment container
        this.tAttachment = new Attachment();
        c1RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C1').getRecordTypeId();
        c2RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C2').getRecordTypeId();
        
        purchaseOrder = new Purchase_Order__c();
        purchaseOrder = (Purchase_Order__c)controller.getRecord();
         
        String isButtonClicked = Apexpages.currentPage().getParameters().get('setDefaultValues');
        if(isButtonClicked == 'true'){
            setDefaultValues();
        }
        
        showC1RecordType = false;
        showC2RecordType = false;
        tAttachment= new Attachment();
        
        
        if(purchaseOrder.RecordTypeId == c1RecordTypeId){
            showC1RecordType = true;
            showC2RecordType = false;
        }
        else if(purchaseOrder.RecordTypeId == c2RecordTypeId){
            showC1RecordType = false;
            showC2RecordType = true;
        }
        
    }
    
     public void setDefaultValues(){
        String quoteId = Apexpages.currentPage().getParameters().get('quoteId');
        Quote__c quote = [Select o.id, o.name, o.Quantity_formula__c, o.Opportunity_Product_Detail__r.Opportunity__c,
                    o.Opportunity__c, o.Record_type_name__c,o.Company_Name__c,Opportunity_Product_Detail__r.Opportunity__r.Account__c from Quote__c o WHERE O.id=:quoteId];
        //system.assert(false,quote);     
        purchaseOrder.Opportunity__c = quote.Opportunity_Product_Detail__r.Opportunity__c;
        purchaseOrder.Quote__c = quote.id;
        purchaseOrder.Company__c = quote.Opportunity_Product_Detail__r.Opportunity__r.Account__c;
        
        if(quote.Record_type_name__c == 'C1'){
            purchaseOrder.RecordTypeId = c1RecordTypeId;
        }
        else {
            purchaseOrder.RecordTypeId = c2RecordTypeId;
        }
    }
 
    
 
    /*
    *   upload file
    */
    public PageReference doUploadFile(){
 
        if(tAttachment.Body == null){
            Apexpages.addMessage(new Apexpages.Message(Apexpages.Severity.ERROR, 'Please upload recent Purchase Order  before saving the record'));
            return null;
        }
        else{
            try{
                insert purchaseOrder;
                
              tAttachment.OwnerId = UserInfo.getUserId();
               tAttachment.ParentId = purchaseOrder.id;
              insert tAttachment;
                
                
                return new PageReference('/'+purchaseOrder.id);
            }
            catch(DMLException e){
                ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,e.getMessage()));
                return null;
            }
        }
    }
}

 
Hi Friends

I have one sound challenge in my job like i have 10 group with record .i want to design a report uisng vf page which is gruoping the record ..User-added image
Hi All
I have more than 10000 record in my custom object ,so how to delete all record automatically uisng custom bottom

 
Hi all

How to upsert csv file using command line data loder if dont have any external id
Hi

I have created a custom button for vf page using javascript.but its showing error like ....
A problem with the OnClick JavaScript for this button or link was encountered:

missing ; before statement
Hi Guys

I am facing one standard limitation issue long time.i have created a page for file uploading which is working fine for me,but problem is when i am uploading more 135 KB file its showing 135KB exceed limitation.I have go through some blogspot and finaly used Transient key word but its showing same.....How to achieve this issue any idea....
 
public class NewSalesConfirmationExtension {
    public Purchase_Order__c purchaseOrder{get;set;}
    public Attachment attachment {get;set;}
    public boolean showC1RecordType {get;set;}
    public boolean showC2RecordType {get;set;} 
    
    private Id c1RecordTypeId; 
    private Id c2RecordTypeId;
    
    public NewSalesConfirmationExtension(ApexPages.StandardController controller) {
        c1RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C1').getRecordTypeId();
        c2RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C2').getRecordTypeId();
        
        purchaseOrder = new Purchase_Order__c();
        purchaseOrder = (Purchase_Order__c)controller.getRecord();
        
        String isButtonClicked = Apexpages.currentPage().getParameters().get('setDefaultValues');
        if(isButtonClicked == 'true'){
            setDefaultValues();
        }
        
        showC1RecordType = false;
        showC2RecordType = false;
        attachment = new Attachment();
        
        
        if(purchaseOrder.RecordTypeId == c1RecordTypeId){
            showC1RecordType = true;
            showC2RecordType = false;
        }
        else if(purchaseOrder.RecordTypeId == c2RecordTypeId){
            showC1RecordType = false;
            showC2RecordType = true;
        }
        
    }
    
     public void setDefaultValues(){
        String quoteId = Apexpages.currentPage().getParameters().get('quoteId');
        Quote__c quote = [Select o.id, o.name, o.Quantity_formula__c, o.Opportunity_Product_Detail__r.Opportunity__c,
                    o.Opportunity__c, o.Record_type_name__c,o.Company_Name__c,Opportunity_Product_Detail__r.Opportunity__r.Account__c from Quote__c o WHERE O.id=:quoteId];
        //system.assert(false,quote);     
        purchaseOrder.Opportunity__c = quote.Opportunity_Product_Detail__r.Opportunity__c;
        purchaseOrder.Quote__c = quote.id;
        purchaseOrder.Company__c = quote.Opportunity_Product_Detail__r.Opportunity__r.Account__c;
        
        if(quote.Record_type_name__c == 'C1'){
            purchaseOrder.RecordTypeId = c1RecordTypeId;
        }
        else {
            purchaseOrder.RecordTypeId = c2RecordTypeId;
        }
    }
    public PageReference save(){
        if(attachment.Body == null){
            Apexpages.addMessage(new Apexpages.Message(Apexpages.Severity.ERROR, 'Please upload recent Purchase Order  before saving the record'));
            return null;
        }
        else{
            try{
                insert purchaseOrder;
                
                attachment.OwnerId = UserInfo.getUserId();
                attachment.ParentId = purchaseOrder.id;
                insert attachment;
                
                return new PageReference('/'+purchaseOrder.id);
            }
            catch(DMLException e){
                ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,e.getMessage()));
                return null;
            }
        }
    }
}

 
Hi all
I have created a Vf Page for file uploading.when i am uploading file and going to save the record its showing error

Visualforce ErrorHelp for this Page
System.NullPointerException: Attempt to de-reference a null object
Error is in expression '{!save}' in component <apex:commandButton> in page newsalesconfirmation: Class.NewSalesConfirmationExtension.save: line 55, column 1

 
public class NewSalesConfirmationExtension {
    public Purchase_Order__c purchaseOrder{get;set;}
    public Transient Attachment attachment {get;set;}
    public boolean showC1RecordType {get;set;}
    public boolean showC2RecordType {get;set;} 
    
    private Id c1RecordTypeId; 
    private Id c2RecordTypeId;
    
    public NewSalesConfirmationExtension(ApexPages.StandardController controller) {
        c1RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C1').getRecordTypeId();
        c2RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C2').getRecordTypeId();
        
        purchaseOrder = new Purchase_Order__c();
        purchaseOrder = (Purchase_Order__c)controller.getRecord();
        
        String isButtonClicked = Apexpages.currentPage().getParameters().get('setDefaultValues');
        if(isButtonClicked == 'true'){
            setDefaultValues();
        }
        
        showC1RecordType = false;
        showC2RecordType = false;
        attachment = new Attachment();
        
        
        if(purchaseOrder.RecordTypeId == c1RecordTypeId){
            showC1RecordType = true;
            showC2RecordType = false;
        }
        else if(purchaseOrder.RecordTypeId == c2RecordTypeId){
            showC1RecordType = false;
            showC2RecordType = true;
        }
        
    }
    
     public void setDefaultValues(){
        String quoteId = Apexpages.currentPage().getParameters().get('quoteId');
        Quote__c quote = [Select o.id, o.name, o.Quantity_formula__c, o.Opportunity_Product_Detail__r.Opportunity__c,
                    o.Opportunity__c, o.Record_type_name__c,o.Company_Name__c,Opportunity_Product_Detail__r.Opportunity__r.Account__c from Quote__c o WHERE O.id=:quoteId];
        //system.assert(false,quote);     
        purchaseOrder.Opportunity__c = quote.Opportunity_Product_Detail__r.Opportunity__c;
        purchaseOrder.Quote__c = quote.id;
        purchaseOrder.Company__c = quote.Opportunity_Product_Detail__r.Opportunity__r.Account__c;
        
        if(quote.Record_type_name__c == 'C1'){
            purchaseOrder.RecordTypeId = c1RecordTypeId;
        }
        else {
            purchaseOrder.RecordTypeId = c2RecordTypeId;
        }
    }
    public PageReference save(){
        if(attachment.Body == null){
            Apexpages.addMessage(new Apexpages.Message(Apexpages.Severity.ERROR, 'Please upload recent Purchase Order  before saving the record'));
            return null;
        }
        else{
            try{
                insert purchaseOrder;
                
                attachment.OwnerId = UserInfo.getUserId();
                attachment.ParentId = purchaseOrder.id;
                insert attachment;
                
                return new PageReference('/'+purchaseOrder.id);
            }
            catch(DMLException e){
                ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,e.getMessage()));
                return null;
            }
        }
    }
}
----------------------------------------------------------------------------------------------

<apex:page standardController="Purchase_Order__c" extensions="NewSalesConfirmationExtension">
    <apex:sectionHeader title="Sale Confirmation Orders" subtitle="{!purchaseOrder.Name}" />
      <apex:form enctype="multipart/form-data">
        <apex:pageMessages ></apex:pageMessages>
        <apex:pageBlock title="Sale Confirmation Order Edit">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
                <apex:commandButton action="{!cancel}" value="Cancel"/>
            </apex:pageBlockButtons>
            
            <apex:pageBlockSection title="Information" columns="2" collapsible="false" rendered="{!showC1RecordType}">
                <apex:inputField value="{!purchaseOrder.Opportunity__c}"/>
                <apex:inputField value="{!purchaseOrder.Sale_Confirmation_Order_Number__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.GRN_needed_for_Bill_Processing__c}"/>
                <apex:inputField value="{!purchaseOrder.Sale_Confirmation_Order_Date__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.No_of_Days_for_collecting_GRN__c}"/>
                <apex:inputField value="{!purchaseOrder.Pre_shipment_Inspection_required__c}" required="true" />
              
                <apex:inputField value="{!purchaseOrder.Purchase_Frequency__c}" required="true" />
                <apex:inputField value="{!purchaseOrder.Customer_Ordered_Quantity__c}" required="true" />
                <apex:inputField value="{!purchaseOrder.Credit_Limit__c}"/>
                   
                    <apex:inputField value="{!purchaseOrder.Customer_Price__c}"/>
                     <apex:inputField value="{!purchaseOrder.CurrencyIsoCode}"/>
                <apex:inputField value="{!purchaseOrder.Bill_Submission_Period__c}"/>
               
                <!---<apex:inputField value="{!purchaseOrder.New_Flash_Aidc_Email_sent__c}"/>--->
               
               
               <!--- <apex:inputField value="{!purchaseOrder.New_Flash_Email_sent__c}"/>--->
                <apex:inputField value="{!purchaseOrder.Committed_Dispatch_Date__c}" required="true"/>
              
               <!-- <apex:inputField value="{!purchaseOrder.PO_Uploaded__c}"/>
                <apex:inputField value="{!purchaseOrder.Try__c}"/>
                <apex:inputField value="{!purchaseOrder.CountAttachment__c}"/>--->
            </apex:PageBlockSection>
            
            <apex:pageBlockSection title="Information" columns="2" collapsible="false" rendered="{!showC2RecordType}">
                <apex:inputField value="{!purchaseOrder.Opportunity__c}"/>
                <apex:inputField value="{!purchaseOrder.Sale_Confirmation_Order_Number__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.GRN_needed_for_Bill_Processing__c}"/>
                <apex:inputField value="{!purchaseOrder.Sale_Confirmation_Order_Date__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.No_of_Days_for_collecting_GRN__c}"/>
                <apex:inputField value="{!purchaseOrder.Committed_Dispatch_Date__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.Credit_Limit__c}"/>
                <apex:inputField value="{!purchaseOrder.Customer_Ordered_Quantity__c}"/>
                <apex:inputField value="{!purchaseOrder.CurrencyIsoCode}"/>
                <apex:inputField value="{!purchaseOrder.Customer_Price__c}"/>
                <apex:inputField value="{!purchaseOrder.Purchase_Frequency__c}" required="true" />
                <apex:inputField value="{!purchaseOrder.Bill_Submission_Period__c}"/>
                <apex:inputField value="{!purchaseOrder.Application_Area__c}"/>
               
                <!---<apex:inputField value="{!purchaseOrder.CountAttachment__c}"/>
                <apex:inputField value="{!purchaseOrder.Try__c}"/>
                <apex:inputField value="{!purchaseOrder.New_Flash_Email_sent__c}"/>
                 <apex:inputField value="{!purchaseOrder.New_Flash_Aidc_Email_sent__c}"/>---->
            </apex:PageBlockSection>
            
            <apex:pageBlockSection title="Quote Details" columns="1" collapsible="false">
                <apex:inputField value="{!purchaseOrder.Quote__c}"/>
                <apex:inputField value="{!purchaseOrder.Company__c}"/>
                 <apex:inputField value="{!purchaseOrder.Delivery_Address__c}" required="true" />
            </apex:PageBlockSection>
            
            <apex:pageBlockSection title="New Flash Details" columns="2" collapsible="false">
                <apex:inputField value="{!purchaseOrder.Application_Area__c}"  rendered="{!showC1RecordType}"/>
                <apex:inputField value="{!purchaseOrder.Remarks__c}"/>
            </apex:PageBlockSection>
            
            <apex:pageBlockSection title="Upload Purchase Order" columns="2" collapsible="false">
                <apex:pageBlockSectionItem >
                <apex:outputLabel value="File" for="file" />
                <apex:inputFile value="{!attachment.body}" filename="{!attachment.name}" id="file"/>
                </apex:pageBlockSectionItem>
            </apex:PageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>


Class.NewSalesConfirmationExtension.save: line 55, column 1
Hi All
I have created a vf page  for file uploading.its working fine,but when i am uploading more than 135KB file its throwing error
Maximum view state size limit (135KB) exceeded
 
<apex:page standardController="Purchase_Order__c" extensions="NewSalesConfirmationExtension">
    <apex:sectionHeader title="Sale Confirmation Orders" subtitle="{!purchaseOrder.Name}" />
    <apex:form >
        <apex:pageMessages ></apex:pageMessages>
        <apex:pageBlock title="Sale Confirmation Order Edit">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
                <apex:commandButton action="{!cancel}" value="Cancel"/>
            </apex:pageBlockButtons>
            
            <apex:pageBlockSection title="Information" columns="2" collapsible="false" rendered="{!showC1RecordType}">
                <apex:inputField value="{!purchaseOrder.Opportunity__c}"/>
                <apex:inputField value="{!purchaseOrder.Sale_Confirmation_Order_Number__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.GRN_needed_for_Bill_Processing__c}"/>
                <apex:inputField value="{!purchaseOrder.Sale_Confirmation_Order_Date__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.No_of_Days_for_collecting_GRN__c}"/>
                <apex:inputField value="{!purchaseOrder.Pre_shipment_Inspection_required__c}" required="true" />
              
                <apex:inputField value="{!purchaseOrder.Purchase_Frequency__c}" required="true" />
                <apex:inputField value="{!purchaseOrder.Customer_Ordered_Quantity__c}" required="true" />
                <apex:inputField value="{!purchaseOrder.Credit_Limit__c}"/>
                   
                    <apex:inputField value="{!purchaseOrder.Customer_Price__c}"/>
                     <apex:inputField value="{!purchaseOrder.CurrencyIsoCode}"/>
                <apex:inputField value="{!purchaseOrder.Bill_Submission_Period__c}"/>
               
                <!---<apex:inputField value="{!purchaseOrder.New_Flash_Aidc_Email_sent__c}"/>--->
               
               
               <!--- <apex:inputField value="{!purchaseOrder.New_Flash_Email_sent__c}"/>--->
                <apex:inputField value="{!purchaseOrder.Committed_Dispatch_Date__c}" required="true"/>
              
               <!-- <apex:inputField value="{!purchaseOrder.PO_Uploaded__c}"/>
                <apex:inputField value="{!purchaseOrder.Try__c}"/>
                <apex:inputField value="{!purchaseOrder.CountAttachment__c}"/>--->
            </apex:PageBlockSection>
            
            <apex:pageBlockSection title="Information" columns="2" collapsible="false" rendered="{!showC2RecordType}">
                <apex:inputField value="{!purchaseOrder.Opportunity__c}"/>
                <apex:inputField value="{!purchaseOrder.Sale_Confirmation_Order_Number__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.GRN_needed_for_Bill_Processing__c}"/>
                <apex:inputField value="{!purchaseOrder.Sale_Confirmation_Order_Date__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.No_of_Days_for_collecting_GRN__c}"/>
                <apex:inputField value="{!purchaseOrder.Committed_Dispatch_Date__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.Credit_Limit__c}"/>
                <apex:inputField value="{!purchaseOrder.Customer_Ordered_Quantity__c}"/>
                <apex:inputField value="{!purchaseOrder.CurrencyIsoCode}"/>
                <apex:inputField value="{!purchaseOrder.Customer_Price__c}"/>
                <apex:inputField value="{!purchaseOrder.Purchase_Frequency__c}" required="true" />
                <apex:inputField value="{!purchaseOrder.Bill_Submission_Period__c}"/>
                <apex:inputField value="{!purchaseOrder.Application_Area__c}"/>
               
                <!---<apex:inputField value="{!purchaseOrder.CountAttachment__c}"/>
                <apex:inputField value="{!purchaseOrder.Try__c}"/>
                <apex:inputField value="{!purchaseOrder.New_Flash_Email_sent__c}"/>
                 <apex:inputField value="{!purchaseOrder.New_Flash_Aidc_Email_sent__c}"/>---->
            </apex:PageBlockSection>
            
            <apex:pageBlockSection title="Quote Details" columns="1" collapsible="false">
                <apex:inputField value="{!purchaseOrder.Quote__c}"/>
                <apex:inputField value="{!purchaseOrder.Company__c}"/>
                 <apex:inputField value="{!purchaseOrder.Delivery_Address__c}" required="true" />
            </apex:PageBlockSection>
            
            <apex:pageBlockSection title="New Flash Details" columns="2" collapsible="false">
                <apex:inputField value="{!purchaseOrder.Application_Area__c}"  rendered="{!showC1RecordType}"/>
                <apex:inputField value="{!purchaseOrder.Remarks__c}"/>
            </apex:PageBlockSection>
            
            <apex:pageBlockSection title="Upload Purchase Order" columns="2" collapsible="false">
                <apex:pageBlockSectionItem >
                <apex:outputLabel value="File" for="file" />
                <apex:inputFile value="{!attachment.body}" filename="{!attachment.name}" id="file"/>
                </apex:pageBlockSectionItem>
            </apex:PageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>


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


public class NewSalesConfirmationExtension {
    public Purchase_Order__c purchaseOrder{get;set;}
    public Attachment attachment {get;set;}
    public boolean showC1RecordType {get;set;}
    public boolean showC2RecordType {get;set;} 
    
    private Id c1RecordTypeId; 
    private Id c2RecordTypeId;
    
    public NewSalesConfirmationExtension(ApexPages.StandardController controller) {
        c1RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C1').getRecordTypeId();
        c2RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C2').getRecordTypeId();
        
        purchaseOrder = new Purchase_Order__c();
        purchaseOrder = (Purchase_Order__c)controller.getRecord();
        
        String isButtonClicked = Apexpages.currentPage().getParameters().get('setDefaultValues');
        if(isButtonClicked == 'true'){
            setDefaultValues();
        }
        
        showC1RecordType = false;
        showC2RecordType = false;
        attachment = new Attachment();
        
        
        if(purchaseOrder.RecordTypeId == c1RecordTypeId){
            showC1RecordType = true;
            showC2RecordType = false;
        }
        else if(purchaseOrder.RecordTypeId == c2RecordTypeId){
            showC1RecordType = false;
            showC2RecordType = true;
        }
        
    }
    
     public void setDefaultValues(){
        String quoteId = Apexpages.currentPage().getParameters().get('quoteId');
        Quote__c quote = [Select o.id, o.name, o.Quantity_formula__c, o.Opportunity_Product_Detail__r.Opportunity__c,
                    o.Opportunity__c, o.Record_type_name__c,o.Company_Name__c,Opportunity_Product_Detail__r.Opportunity__r.Account__c from Quote__c o WHERE O.id=:quoteId];
        //system.assert(false,quote);     
        purchaseOrder.Opportunity__c = quote.Opportunity_Product_Detail__r.Opportunity__c;
        purchaseOrder.Quote__c = quote.id;
        purchaseOrder.Company__c = quote.Opportunity_Product_Detail__r.Opportunity__r.Account__c;
        
        if(quote.Record_type_name__c == 'C1'){
            purchaseOrder.RecordTypeId = c1RecordTypeId;
        }
        else {
            purchaseOrder.RecordTypeId = c2RecordTypeId;
        }
    }
    public PageReference save(){
        if(attachment.Body == null){
            Apexpages.addMessage(new Apexpages.Message(Apexpages.Severity.ERROR, 'Please upload recent Purchase Order  before saving the record'));
            return null;
        }
        else{
            try{
                insert purchaseOrder;
                
                attachment.OwnerId = UserInfo.getUserId();
                attachment.ParentId = purchaseOrder.id;
                insert attachment;
                
                return new PageReference('/'+purchaseOrder.id);
            }
            catch(DMLException e){
                ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,e.getMessage()));
                return null;
            }
        }
    }
}