• garfer
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 3
    Replies



I need to connect each of my Salesforce opportunities with my payment and billing system.

My system works in client / server mode is not clud and handle my database is Firebird.


I have to do is validate my every opportunity closed won, with the payments recorded on my system. automatically want to see in the salesforce payment if the customer has the opportunity.



Can you tell me where to start, since I have little programming with apex.


Thanks for your help

 
  • April 28, 2012
  • Like
  • 0

Hello
Can you help me with this class, I can not cover 100%.

The strange thing is that this code is already in production, the only thing that was done was change the Object FACTURA__C appends a date field,

Below is the code and error mnesaje


I hope I can help

Greetings.

 

CODE

globalclass BatchLeadPhones implementsDatabase.Batchable<sObject>{

 

publicString query, query1;

 

globaldatabase.querylocator start(Database.BatchableContext BC){

query='Select Id, Name, Nombre_del_Cliente__c, Proceso__c, Fecha_de_Pago__c From Factura__c Where Proceso__c = "no validado"';

 

//query1='Select Id, StageName, Status_de_Oportunidad__c, Numero_de_la_Factura__c From Opportunity Where Numero_de_la_Factura__c="Cerrada Ganada"';returnDatabase.getQueryLocator(query);

 

//return Database.getQueryLocator(query1);

}

globalvoidexecute(Database.BatchableContext BC, List<sObject> scope){

List<Factura__c> Leads = new List<Factura__c>();

 

//List<Opportunity> st = new List<Opportunity>(); for(sObject s : scope){

 

Factura__c l = (Factura__c)s;

 

for(List<Opportunity> st : [SELECT Id, Numero_de_la_Factura__c, Status_de_Oportunidad__c, Status_Factura__c FROMOpportunityWHERE Numero_de_la_Factura__c =: l.Name]){

 

    for(Opportunityopor:st){

 

       if (opor.Numero_de_la_Factura__c == l.Name){

              opor.Status_Factura__c ='Pagada';

               l.Proceso__c ='Terminado';

              opor.Fecha_confirmacion_de_Pago__c = l.Fecha_de_Pago__c;

 

}

}

updatest;

}

//Opportunity f = (Opportunity)ac;//If (ac.Numero_de_la_Factura__c==l.Name){//ac.Status_de_Oportunidad__c ='Pagada';//l.Nombre_del_Cliente__c = 'Validada';

Leads.Add(l);

//}

}

update

Leads;

//update f;

}

globalvoidfinish(Database.BatchableContext BC){

}

// test method

statictestMethodvoidtest_BatchLeadPhones() {

 

//Lead l = new lead(LastName='lead test 123', phone_cti__c='+1 (555)123-4567', company='test company 456'); //insert l;

Test.StartTest();

BatchLeadPhones Blp =

newBatchLeadPhones();

 

//Blp.query = 'Select phone_cti__c From lead Where ID=\''+l.Id+'\'';

ID batchprocessid = Database.executeBatch(Blp);

Test.StopTest();

 

}

 

}

 

 

Debug Log:

18.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;VALIDATION,INFO;WORKFLOW,INFO
14:51:47.776 (776858000)|EXECUTION_STARTED
14:51:47.776 (776922000)|CODE_UNIT_STARTED|[EXTERNAL]|01pA00000034QEg|BatchLeadPhones.test_BatchLeadPhones
14:51:47.776 (776986000)|METHOD_ENTRY|[1]|01pA00000034QEg|BatchLeadPhones.BatchLeadPhones()
14:51:47.777 (777029000)|METHOD_EXIT|[1]|BatchLeadPhones
14:51:47.777 (777078000)|SYSTEM_METHOD_ENTRY|[1]|Test.Test()
14:51:47.777 (777108000)|SYSTEM_METHOD_EXIT|[1]|Test
14:51:47.777 (777250000)|CONSTRUCTOR_ENTRY|[43]|01pA00000034QEg|<init>()
14:51:47.777 (777321000)|CONSTRUCTOR_EXIT|[43]|01pA00000034QEg|<init>()
14:51:47.816 (816347000)|CODE_UNIT_STARTED|[EXTERNAL]|01pA00000034QEg|BatchLeadPhones
14:51:47.829 (829443000)|SYSTEM_METHOD_ENTRY|[15]|BatchableContextImpl.BatchableContextImpl()
14:51:47.829 (829485000)|SYSTEM_METHOD_EXIT|[15]|BatchableContextImpl
14:51:47.830 (830040000)|EXCEPTION_THROWN|[6]|System.QueryException: line 1:104 no viable alternative at character '"'
14:51:47.850 (850630000)|FATAL_ERROR|System.QueryException: line 1:104 no viable alternative at character '"'

Class.BatchLeadPhones.start: line 6, column 13
External entry point
14:51:47.977 (850656000)|CUMULATIVE_LIMIT_USAGE
14:51:47.977|LIMIT_USAGE_FOR_NS|(default)|
  Number of SOQL queries: 0 out of 200
  Number of query rows: 0 out of 50000
  Number of SOSL queries: 0 out of 20
  Number of DML statements: 0 out of 150
  Number of DML rows: 0 out of 10000
  Number of script statements: 2 out of 1000000
  Maximum heap size: 0 out of 6000000
  Number of callouts: 0 out of 1
  Number of Email Invocations: 0 out of 10
  Number of fields describes: 0 out of 100
  Number of record type describes: 0 out of 100
  Number of child relationships describes: 0 out of 100
  Number of picklist describes: 0 out of 100
  Number of future calls: 0 out of 0

14:51:47.977 (850656000)|CUMULATIVE_LIMIT_USAGE_END

14:51:47.850 (850701000)|CODE_UNIT_FINISHED|BatchLeadPhones
14:51:47.977 (850758000)|CUMULATIVE_LIMIT_USAGE
14:51:47.977|LIMIT_USAGE_FOR_NS|(default)|
  Number of SOQL queries: 0 out of 100
  Number of query rows: 0 out of 50000
  Number of SOSL queries: 0 out of 20
  Number of DML statements: 0 out of 150
  Number of DML rows: 0 out of 10000
  Number of script statements: 6 out of 200000
  Maximum heap size: 0 out of 3000000
  Number of callouts: 0 out of 10
  Number of Email Invocations: 0 out of 10
  Number of fields describes: 0 out of 100
  Number of record type describes: 0 out of 100
  Number of child relationships describes: 0 out of 100
  Number of picklist describes: 0 out of 100
  Number of future calls: 0 out of 10

14:51:47.977|TESTING_LIMITS
14:51:47.977 (850758000)|CUMULATIVE_LIMIT_USAGE_END

14:51:47.850 (850789000)|CODE_UNIT_FINISHED|BatchLeadPhones.test_BatchLeadPhones
14:51:47.850 (850795000)|EXECUTION_FINISHED

  • December 05, 2011
  • Like
  • 0

Hello,

I have a problem, I created a class in eclipse that runs correctly in production. When I want more code appends, I class covers only 23%. I add the code that's just an assignment of values ​​to a new field of the object.


The strange thing is that I leave the class as it was running in production, and covers me 100%, in theory should cover, as this same code is running currently in production.

In order opportunity to add some custom field
 
Someone can help me solve this problem ...


thanks

 
  • November 24, 2011
  • Like
  • 0

I have a class called Sheduledfactura BatchLeadPhones and another call, I run the class with the second to run each month.

BatchLeadPhones class, is covered at 100%, but the Sheduledfactura not, how I can do to cover this class and you can run the scheduler.

Annex the code here

 

 

global class BatchLeadPhones implements Database.Batchable<sObject>{ 
   public String query; 
   global database.querylocator start(Database.BatchableContext BC){ 
     query='Select Id, Name, Nombre_del_Cliente__c From Factura__c'; 
     return Database.getQueryLocator(query);
       } 
    global void execute(Database.BatchableContext BC, List<sObject> scope){ 
     List<Factura__c> Leads = new List<Factura__c>();
       for(sObject s : scope){ 
       Factura__c l = (Factura__c)s;
         l.Nombre_del_Cliente__c = 'Validada'; 
   } 
update Leads;
   } 
  global void finish(Database.BatchableContext BC){ 
    } 
  // test method 
   static testMethod void test_BatchLeadPhones() { 
    Test.StartTest(); 
    BatchLeadPhones Blp = new BatchLeadPhones(); 
    ID batchprocessid = Database.executeBatch(Blp); 
    Test.StopTest();  

   } 

}

 

 

Sheduledfactura class

 

 

global class Sheduledfact implementsSchedulable{

 

global void execute(SchedulableContext SC){

BatchLeadPhones M =

newBatchLeadPhones();

database.executebatch(M);

String sch =

'0 0 5 * * ?';

 

system.schedule('Schedule TEST', sch, sh);

}

public

statictestMethodvoidtestschedule() {

Test.StartTest();

Sheduledfact sh =

newSheduledfact();

String sch =

'0 0 5 * * ?';

system

.schedule('Schedule TEST', sch, sh);

Test.stopTest();

}

}

 

 

I hope I can help with this

thanks

 

  • October 18, 2011
  • Like
  • 0

Hello,

I have a problem, I created a class in eclipse that runs correctly in production. When I want more code appends, I class covers only 23%. I add the code that's just an assignment of values ​​to a new field of the object.


The strange thing is that I leave the class as it was running in production, and covers me 100%, in theory should cover, as this same code is running currently in production.

In order opportunity to add some custom field
 
Someone can help me solve this problem ...


thanks

 
  • November 24, 2011
  • Like
  • 0

I have a class called Sheduledfactura BatchLeadPhones and another call, I run the class with the second to run each month.

BatchLeadPhones class, is covered at 100%, but the Sheduledfactura not, how I can do to cover this class and you can run the scheduler.

Annex the code here

 

 

global class BatchLeadPhones implements Database.Batchable<sObject>{ 
   public String query; 
   global database.querylocator start(Database.BatchableContext BC){ 
     query='Select Id, Name, Nombre_del_Cliente__c From Factura__c'; 
     return Database.getQueryLocator(query);
       } 
    global void execute(Database.BatchableContext BC, List<sObject> scope){ 
     List<Factura__c> Leads = new List<Factura__c>();
       for(sObject s : scope){ 
       Factura__c l = (Factura__c)s;
         l.Nombre_del_Cliente__c = 'Validada'; 
   } 
update Leads;
   } 
  global void finish(Database.BatchableContext BC){ 
    } 
  // test method 
   static testMethod void test_BatchLeadPhones() { 
    Test.StartTest(); 
    BatchLeadPhones Blp = new BatchLeadPhones(); 
    ID batchprocessid = Database.executeBatch(Blp); 
    Test.StopTest();  

   } 

}

 

 

Sheduledfactura class

 

 

global class Sheduledfact implementsSchedulable{

 

global void execute(SchedulableContext SC){

BatchLeadPhones M =

newBatchLeadPhones();

database.executebatch(M);

String sch =

'0 0 5 * * ?';

 

system.schedule('Schedule TEST', sch, sh);

}

public

statictestMethodvoidtestschedule() {

Test.StartTest();

Sheduledfact sh =

newSheduledfact();

String sch =

'0 0 5 * * ?';

system

.schedule('Schedule TEST', sch, sh);

Test.stopTest();

}

}

 

 

I hope I can help with this

thanks

 

  • October 18, 2011
  • Like
  • 0