• sales4s.com
  • NEWBIE
  • 0 Points
  • Member since 2012

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

To write an effective apex code,triggers,classes, batches and unit tests ,do  I need to learn any language apart from OOPs...! Like C#,Java,PHP,etc? What I should know to master in writing apex coding, and in Web services,Integrations in salesrooms ?Should I know any programming language before learning it or making an effective CRM application?

 

Any suggestions will be of great help! Thank you! 

Hi all,

I am newbie to apex Batch classes. I need to understand how Apex batches execute(the process).

I know how to write apex classes and trigeers. but totally confused in following Apex batch code. Kindly give me some tips/knowledge/information on how easily I can write apex batches.

==========================================================

  1. global class Beautification's implements Database.Batchable<sObject>{
  2. global final String Query;
  3. global final String Entity;
  4. global final String Field;
  5. global final String Value;
  6. global UpdateAccountFields(String q, String e, String f, String v){
  7. Query=q; Entity=e; Field=f;Value=v;
  8. }
  9. global Database.QueryLocator start(Database.BatchableContext BC){
  10. return Database.getQueryLocator(query);
  11. }
  12. global void execute(Database.BatchableContext BC,
  13. List<sObject> scope){
  14. for(Sobject s : scope){s.put(Field,Value);
  15. } update scope;
  16. }
  17. global void finish(Database.BatchableContext BC){
  18. }
  19. }

The following code can be used to call the above class:

 

1. Id batchInstanceId = Database.executeBatch(new UpdateInvoiceFields(q,e,f,v), 5);

=============================================================

I am little confused of the following lines:

 

1. ""query","entity","field","value"" declared as variable and at 7th line why it is assigned to q,e,f,v.

2.  return Database.getQueryLocator(query)...?

3.  [List<sObject> scope)  {  for(Sobject s : scope){s.put(Field,Value);]..in line 13,14.

Can't we use directly Account,lead,contact or any custom object. Like this:[ List<account>scope { for(account a:scope...].

4. Id batchInstanceId = Database.executeBatch(new UpdateInvoiceFields(q,e,f,v), 5);

 

can please explain line by line.

thank you in advance.

any kind of explanation/suggestions/information is highly appriciated.

 

 want to update another object say  1."account_master__c" from  2nd"ATM_transacction__c".writing after insert trigger in 2nd object.please look at the code.

 

trigger atm2 on ATM_Transaction__c (after insert)

{

for(atm_transaction__c atm: trigger.new)
{
aggregateResult a=[select sum(amount__c) s from atm_transaction__c where
account_id__c=:atm.account_id__c];

double i=(double)a.get('s');

account_master__c am=new account_master__c();
am=[select id, balance__c from account_master__c where
account_idm__c=:atm.accout_id__c]

if(am.balance__c > i){
am.balance__c=am.balance__c -i;
}
//update am;
}
update am;

}

 

where i wenr wrong.

thanks in advance.


To write an effective apex code,triggers,classes, batches and unit tests ,do  I need to learn any language apart from OOPs...! Like C#,Java,PHP,etc? What I should know to master in writing apex coding, and in Web services,Integrations in salesrooms ?Should I know any programming language before learning it or making an effective CRM application?

 

Any suggestions will be of great help! Thank you! 

Hi all,

I am newbie to apex Batch classes. I need to understand how Apex batches execute(the process).

I know how to write apex classes and trigeers. but totally confused in following Apex batch code. Kindly give me some tips/knowledge/information on how easily I can write apex batches.

==========================================================

  1. global class Beautification's implements Database.Batchable<sObject>{
  2. global final String Query;
  3. global final String Entity;
  4. global final String Field;
  5. global final String Value;
  6. global UpdateAccountFields(String q, String e, String f, String v){
  7. Query=q; Entity=e; Field=f;Value=v;
  8. }
  9. global Database.QueryLocator start(Database.BatchableContext BC){
  10. return Database.getQueryLocator(query);
  11. }
  12. global void execute(Database.BatchableContext BC,
  13. List<sObject> scope){
  14. for(Sobject s : scope){s.put(Field,Value);
  15. } update scope;
  16. }
  17. global void finish(Database.BatchableContext BC){
  18. }
  19. }

The following code can be used to call the above class:

 

1. Id batchInstanceId = Database.executeBatch(new UpdateInvoiceFields(q,e,f,v), 5);

=============================================================

I am little confused of the following lines:

 

1. ""query","entity","field","value"" declared as variable and at 7th line why it is assigned to q,e,f,v.

2.  return Database.getQueryLocator(query)...?

3.  [List<sObject> scope)  {  for(Sobject s : scope){s.put(Field,Value);]..in line 13,14.

Can't we use directly Account,lead,contact or any custom object. Like this:[ List<account>scope { for(account a:scope...].

4. Id batchInstanceId = Database.executeBatch(new UpdateInvoiceFields(q,e,f,v), 5);

 

can please explain line by line.

thank you in advance.

any kind of explanation/suggestions/information is highly appriciated.

 

 want to update another object say  1."account_master__c" from  2nd"ATM_transacction__c".writing after insert trigger in 2nd object.please look at the code.

 

trigger atm2 on ATM_Transaction__c (after insert)

{

for(atm_transaction__c atm: trigger.new)
{
aggregateResult a=[select sum(amount__c) s from atm_transaction__c where
account_id__c=:atm.account_id__c];

double i=(double)a.get('s');

account_master__c am=new account_master__c();
am=[select id, balance__c from account_master__c where
account_idm__c=:atm.accout_id__c]

if(am.balance__c > i){
am.balance__c=am.balance__c -i;
}
//update am;
}
update am;

}

 

where i wenr wrong.

thanks in advance.