• Vianney Bancillon 8
  • NEWBIE
  • 50 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 14
    Replies
Hi everyone, I try to write a code to import QuoteLineItems into Quote from csv file.
My code generate no error but it does not work: my quote is still empty : no QuoteLine appear.
Could you please help me to solve it?
Here is the code of my VF page:
<apex:page standardController="Quote" extensions="importQuoteLineItemFromCSVController">
    
       <apex:form >
           <apex:pagemessages />
            <apex:pageBlock title="QuoteLineItems" id="QuoteLineItems">
                <apex:pageBlockSection >
                    <p>
                        Hi {!$User.FirstName}  You're workin on {!Quote.Name}
                    </p>                
                </apex:pageBlockSection>
                <apex:pageBlockSection columns="2">
                    <apex:inputFile value="{!csvFileBody}" filename="{!csvAsString}"/>&nbsp;
                    <apex:commandButton value="Import" action="{!importCSVFile}"/>
                </apex:pageBlockSection>
                
                <apex:pageBlockTable value="{!qlilist}" var="qli">
                    <apex:column value="{!qli.Quantity}"/>
                    <apex:column value="{!qli.Code_produit__c}"/>
                    <apex:column value="{!qli.id}"/>                
                </apex:pageBlockTable> 
                
           </apex:pageBlock>
        </apex:form>   
</apex:page>
and my controller...
public class importQuoteLineItemFromCSVController {
public Blob csvFileBody{get;set;}
public string csvAsString{get;set;}
public String[] csvFileLines{get;set;}
public Quote q {get;set;}

public PricebookEntry pbe;

public List<QuoteLineItem> qlilist{get;set;}
public importQuoteLineItemFromCSVController(ApexPages.StandardController stdController){
    this.q=(Quote)stdController.getRecord();
    csvFileLines = new String[]{};
    qlilist = new List<QuoteLineItem>(); 
  }  
  public void importCSVFile(){       
       try
       {
           csvAsString = csvFileBody.toString();
           csvFileLines = csvAsString.split('\n'); 
            
           for(Integer i=1;i<csvFileLines.size();i++)
           {
               QuoteLineItem qli = new QuoteLineItem() ;
               string[] csvRecordData = csvFileLines[i].split(',');
               qli.Product2.ProductCode = csvRecordData[0];
               qli.Quantity = decimal.valueOf(csvRecordData[1]);
               qli.QuoteId = q.Id;
               qli.UnitPrice = pbe.UnitPrice;
               qlilist.add(qli);        
              
           }
           INSERT qlilist;                  	
        }
      
        catch (Exception e)
        {
            ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR,'An error has occured while importin data Please make sure input csv file is correct');
            ApexPages.addMessage(errorMessage);
        }  
  }
}

Many thanks...
Vianney

 
Hello everyone,
I'm unable to execute this Batch test successfully.
I'm facing the following error ;:

Date de début30/11/2017 18:18
ClassebatchTaskRayTaskUpdateTest
Nom de méthodebatchTaskRayTaskUpdateTest
Réussite/ÉchecFail
Message d'erreurSystem.QueryException: line 1:105 no viable alternative at character '"'
Trace de pileClass.batchTaskRayTaskUpdate.start: line 4, column 1

I don't see any double quote at line 4!
I tried to delete and retype all of single quote, as said in existing posts but it does not solve the issue.

Here is the code:
@isTest(seeAllData=false)
public class batchTaskRayTaskUpdateTest {
    static testmethod void batchTaskRayTaskUpdateTest(){
    Test.startTest();
        TASKRAY__Project__c TRP1 = new TASKRAY__Project__c();
        TRP1.Name ='PlanningVianney';
        TRP1.RecordTypeId = '012b0000000UZYp';
        insert TRP1;
        
        Date oppDate = Date.newInstance(2018,01,8);        
        Opportunity Opp1 = new Opportunity();
        Opp1.Name ='OppVianneyTst';
        Opp1.StageName ='Devis en cours';
        Opp1.CloseDate=oppDate;
        insert Opp1;
                       
        TASKRAY__Project_Task__c taskR1= new TASKRAY__Project_Task__c();
        TASKRAY__Project_Task__c taskR2= new TASKRAY__Project_Task__c();
        TASKRAY__Project_Task__c taskR3= new TASKRAY__Project_Task__c();       
        
        
        
        Date taskRayDate = Date.newInstance(2017,12,6);
                
        taskR1.Name='testTask1';        
        taskR2.Name='testTask2';
        taskR3.Name='testTask3';
        taskR1.TASKRAY__Deadline__c = taskRayDate;
        taskR2.TASKRAY__Deadline__c = taskRayDate;
        taskR3.TASKRAY__Deadline__c = taskRayDate;
        taskR2.RecordTypeID = '012b0000000UZUs';
        taskR3.RecordTypeId = '012b0000000UZUs';
        taskR1.RecordTypeId = '012b0000000UZUs';
        
        taskR1.TASKRAY__Project__c = TRP1.Id;
        taskR2.TASKRAY__Project__c = TRP1.Id;
        taskR3.TASKRAY__Project__c = TRP1.Id;
       
        taskR1.Opportunity__c = Opp1.Id;
        taskR2.Opportunity__c = Opp1.Id;
        taskR3.Opportunity__c = Opp1.Id;
        
        List<TASKRAY__Project_Task__c> taskRList = new List<TASKRAY__Project_Task__c>();
        taskRList.add(taskR1);
        taskRList.add(taskR2);
        taskRList.add(taskR3);
        insert taskRList;
              
               
        batchTaskRayTaskUpdate b = new batchTaskRayTaskUpdate();
        database.executeBatch(b);
        TASKRAY__Project_Task__c newTaskR1 =[SELECT Name, TASKRAY__Project__c, TASKRAY__Deadline__c from TASKRAY__Project_Task__c where Id=:taskRList[0].Id];
        TASKRAY__Project_Task__c newTaskR2 =[SELECT Name, TASKRAY__Project__c, TASKRAY__Deadline__c from TASKRAY__Project_Task__c where Id=:taskRList[1].Id];
        TASKRAY__Project_Task__c newTaskR3 =[SELECT Name, TASKRAY__Project__c, TASKRAY__Deadline__c from TASKRAY__Project_Task__c where Id=:taskRList[2].Id];
        
        
        
    Test.stopTest();
    } 
}
Thanks for the help!

Vianney

 
Hello everyone,

I recently set up a workflow that works in the following way :

 - Opportunity’ object that has a field ‘‘Number of days before finalisation’’. This is a formula field that calculates automatically based on the date field ‘‘Commitment to order finalisation’’. This is the formula: Number of days before finalisation= Commitment to order finalisation – TODAY()
- When Number of days before finalisation = -1, the workflow sends an email to the opportunity owner

I thought my test were Ok because:
When the field is not blank and contains -1 , it works correctly (the mail is sent)
When the field is not blank and contains another value than -1, it works correctly (the mail is not sent)
But most of time, when the Opportunity object is just created, the field is blank (this is not a requiered field). In this case, the workflow always send the e-mail.
What is wrong in my workflow rule?

Thanks for your help!

Vianney BANCILLON


 
Hi all,

I have a problem with all my workflow in Sandbox: when the "Immediate Workflow Action" is an "E-Mail alert", it doesn't work in SandBox, even if I click on the test button: "Send test and verify merge fields" in the HTML Email template.
It works in Production Environnment.

Could you please help me to solve it?

Thanks

Vianney Bancillon




 
Hi everyone!

I read in a previous post that it is possible to implement both in a single class, but the post didn't give any exemples.
Could you explain  how to do that to me (with exemples if possible)
Thanks!
Vianney Bancillon
Hi Everyone,

I'm trying to write a simple test class.
My code gives the said error.
In my mind, at the line 21, I don't write an update on the CloseDate field but just a condition (boolean).
What is wrong in the following code?
 
@istest

public class batchOppBisTest {
    static testMethod void validateBatch(){
    
    //création d'une nouvelle opportunité qui répond aux critères du workflow
    
    Opportunity opp1 = new Opportunity (Name = 'opptyDeTest', CloseDate = date.TODAY()+45, Engagement_date_finalisation_commande__c = date.TODAY()-1, StageName='Au planning de livraison');
    
    insert opp1;
        
    //vérification que Nbre de jours avant finalisation a été calculé
    System.debug ('$$$ Nbre de jours avant finalisation' + opp1.Nbre_Jours_Avant_Finalisation__c);
    
    //requête sur opportunités
    
    Opportunity [] tabOpp = [SELECT StageName, CreatedDate FROM Opportunity WHERE StageName = 'Au planning de livraison'];
    Opportunity [] oppCreated = new Opportunity []{};
       for (Opportunity o : tabOpp){
            if (o.CreatedDate = date.Today()){
            oppCreated.add(o);
            System.debug(o);
            }//if
       }//for    
          
    }//validateBatch
    
}//class

Thanks for your help!



 
Hello everybody !
I recently set up a workflow that works in the following way :
  •  ‘Opportunity’ object that has a field ‘‘Number of days before finalisation’’. This is a formula field that calculates automatically based on the date field ‘‘Commitment to order finalisation’’. This is the formula: Number of days before finalisation= Commitment to order finalisation – TODAY()
  • When Number of days before finalisation = -1, the workflow sends an email to the opportunity owner
 
My tests are OK ; however, a colleague has told me that this is the case because I changed the ‘‘Commitment to order finalisation’’ field.
In my mind , the following will happen: Number of days before finalisation is updated automatically everyday by the formula , which will at some point return ‘‘-1’’. In this case: FIRE! The WF is set off and sends an email.
In my colleague’s opinion, the modification of the Number of days before finalisation field is not interpreted by SalesForce as an object update, and therefore won’t set off the WF.
It seems that an Apex class that updates my record is necessary.
Could you explain me why? I can't understand the logic.
Thanks a lot.

Have a good day.

Vianney BANCILLON
 
Hi all!
The idea is to allow the user to create a new contact directly from this page, instead of dropping the quote creation, creating the new contact, and returning to the quotation creation page.
I know how to do in the page layout of the quote (or any object), but not in the creation page...

A screenshot to be understood:

User-added image

Thanks!
Vianney
Hi All!
I encounter an issue with Conga composer in my SandBox.
I have a license in my production environnment.
Does Conga Composer works in a SandBox? What settings should I use?

Thanks

Vianney BANCILLON
 
Hello everyone,
I'm unable to execute this Batch test successfully.
I'm facing the following error ;:

Date de début30/11/2017 18:18
ClassebatchTaskRayTaskUpdateTest
Nom de méthodebatchTaskRayTaskUpdateTest
Réussite/ÉchecFail
Message d'erreurSystem.QueryException: line 1:105 no viable alternative at character '"'
Trace de pileClass.batchTaskRayTaskUpdate.start: line 4, column 1

I don't see any double quote at line 4!
I tried to delete and retype all of single quote, as said in existing posts but it does not solve the issue.

Here is the code:
@isTest(seeAllData=false)
public class batchTaskRayTaskUpdateTest {
    static testmethod void batchTaskRayTaskUpdateTest(){
    Test.startTest();
        TASKRAY__Project__c TRP1 = new TASKRAY__Project__c();
        TRP1.Name ='PlanningVianney';
        TRP1.RecordTypeId = '012b0000000UZYp';
        insert TRP1;
        
        Date oppDate = Date.newInstance(2018,01,8);        
        Opportunity Opp1 = new Opportunity();
        Opp1.Name ='OppVianneyTst';
        Opp1.StageName ='Devis en cours';
        Opp1.CloseDate=oppDate;
        insert Opp1;
                       
        TASKRAY__Project_Task__c taskR1= new TASKRAY__Project_Task__c();
        TASKRAY__Project_Task__c taskR2= new TASKRAY__Project_Task__c();
        TASKRAY__Project_Task__c taskR3= new TASKRAY__Project_Task__c();       
        
        
        
        Date taskRayDate = Date.newInstance(2017,12,6);
                
        taskR1.Name='testTask1';        
        taskR2.Name='testTask2';
        taskR3.Name='testTask3';
        taskR1.TASKRAY__Deadline__c = taskRayDate;
        taskR2.TASKRAY__Deadline__c = taskRayDate;
        taskR3.TASKRAY__Deadline__c = taskRayDate;
        taskR2.RecordTypeID = '012b0000000UZUs';
        taskR3.RecordTypeId = '012b0000000UZUs';
        taskR1.RecordTypeId = '012b0000000UZUs';
        
        taskR1.TASKRAY__Project__c = TRP1.Id;
        taskR2.TASKRAY__Project__c = TRP1.Id;
        taskR3.TASKRAY__Project__c = TRP1.Id;
       
        taskR1.Opportunity__c = Opp1.Id;
        taskR2.Opportunity__c = Opp1.Id;
        taskR3.Opportunity__c = Opp1.Id;
        
        List<TASKRAY__Project_Task__c> taskRList = new List<TASKRAY__Project_Task__c>();
        taskRList.add(taskR1);
        taskRList.add(taskR2);
        taskRList.add(taskR3);
        insert taskRList;
              
               
        batchTaskRayTaskUpdate b = new batchTaskRayTaskUpdate();
        database.executeBatch(b);
        TASKRAY__Project_Task__c newTaskR1 =[SELECT Name, TASKRAY__Project__c, TASKRAY__Deadline__c from TASKRAY__Project_Task__c where Id=:taskRList[0].Id];
        TASKRAY__Project_Task__c newTaskR2 =[SELECT Name, TASKRAY__Project__c, TASKRAY__Deadline__c from TASKRAY__Project_Task__c where Id=:taskRList[1].Id];
        TASKRAY__Project_Task__c newTaskR3 =[SELECT Name, TASKRAY__Project__c, TASKRAY__Deadline__c from TASKRAY__Project_Task__c where Id=:taskRList[2].Id];
        
        
        
    Test.stopTest();
    } 
}
Thanks for the help!

Vianney

 
Hi all,

I have a problem with all my workflow in Sandbox: when the "Immediate Workflow Action" is an "E-Mail alert", it doesn't work in SandBox, even if I click on the test button: "Send test and verify merge fields" in the HTML Email template.
It works in Production Environnment.

Could you please help me to solve it?

Thanks

Vianney Bancillon




 
Hi everyone!

I read in a previous post that it is possible to implement both in a single class, but the post didn't give any exemples.
Could you explain  how to do that to me (with exemples if possible)
Thanks!
Vianney Bancillon
Hi Everyone,

I'm trying to write a simple test class.
My code gives the said error.
In my mind, at the line 21, I don't write an update on the CloseDate field but just a condition (boolean).
What is wrong in the following code?
 
@istest

public class batchOppBisTest {
    static testMethod void validateBatch(){
    
    //création d'une nouvelle opportunité qui répond aux critères du workflow
    
    Opportunity opp1 = new Opportunity (Name = 'opptyDeTest', CloseDate = date.TODAY()+45, Engagement_date_finalisation_commande__c = date.TODAY()-1, StageName='Au planning de livraison');
    
    insert opp1;
        
    //vérification que Nbre de jours avant finalisation a été calculé
    System.debug ('$$$ Nbre de jours avant finalisation' + opp1.Nbre_Jours_Avant_Finalisation__c);
    
    //requête sur opportunités
    
    Opportunity [] tabOpp = [SELECT StageName, CreatedDate FROM Opportunity WHERE StageName = 'Au planning de livraison'];
    Opportunity [] oppCreated = new Opportunity []{};
       for (Opportunity o : tabOpp){
            if (o.CreatedDate = date.Today()){
            oppCreated.add(o);
            System.debug(o);
            }//if
       }//for    
          
    }//validateBatch
    
}//class

Thanks for your help!



 
Hello everybody !
I recently set up a workflow that works in the following way :
  •  ‘Opportunity’ object that has a field ‘‘Number of days before finalisation’’. This is a formula field that calculates automatically based on the date field ‘‘Commitment to order finalisation’’. This is the formula: Number of days before finalisation= Commitment to order finalisation – TODAY()
  • When Number of days before finalisation = -1, the workflow sends an email to the opportunity owner
 
My tests are OK ; however, a colleague has told me that this is the case because I changed the ‘‘Commitment to order finalisation’’ field.
In my mind , the following will happen: Number of days before finalisation is updated automatically everyday by the formula , which will at some point return ‘‘-1’’. In this case: FIRE! The WF is set off and sends an email.
In my colleague’s opinion, the modification of the Number of days before finalisation field is not interpreted by SalesForce as an object update, and therefore won’t set off the WF.
It seems that an Apex class that updates my record is necessary.
Could you explain me why? I can't understand the logic.
Thanks a lot.

Have a good day.

Vianney BANCILLON
 
Hi All!
I encounter an issue with Conga composer in my SandBox.
I have a license in my production environnment.
Does Conga Composer works in a SandBox? What settings should I use?

Thanks

Vianney BANCILLON