• SFDC_TTL
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 13
    Replies

Hi,

 

I am trying to call a future method from a before trigger.

 

Insert Operation is hapening fine.

 

Update, Delete are not getting executed.

 

Delete is failed with Error333: []

 

Update is failed with an error like 

Future method cannot be called from a future or batch method: MyFutureClass.myMethod(Id)

Please suggest.

 

trigger futurecheck on Account (after update) 

{
   system.debug('Name issssss ' + Trigger.NEW[0].name);
   Account acc = [SELECT name FROM Account WHERE name = 'Thru Future'];
   MyFutureClass.myMethod(acc.Id);
   
}


global class MyFutureClass
{

@future (callout=false)
Public static void myMethod(Id i)
{
System.debug('Method calleddddddd '+ i);

try {
acc.AccountSource='Phone Inquiry';
update acc;
}
catch (DmlException e) {


}

 

Hi,

 

Can anybody help on this.

 

We have to work with mail merge templates for document generation from SFDC. But we have few queries regaring the same. after some document reference, we got to know that using extended mail merge,

 

1. Document size cannot be more than 1 MB where as with standard mail merge, it is 2MB. Is there any other way for extended mail merge if the document size exceeds 1 MB??

 

2. The record count should be maximum 1000. How the record count is calculated (it is NOT MASS MAIL MERGE)

 

3. If we have enabled XMM by contacting salesforce and inactivated the same due to some reasons. can I use standard mail merge in such scenario?

 

Thank you

 

 

Hi,

 

I have a scenario of calling a class which inturn invokes the batch class. In normal scenario, the batch is getting invoked from the class, but coming to test method, batch is invoked execute method is not covered at all. Even the below line is in RED only.

 

global void execute(Database.BatchableContext ctx, List<Account> acclist)      {

1. Test class

private class Test_OwnerShipChanges

 Static testMethodvoid nonverifiedmailintimation()

{

 VerOwnrChangetoSemiAdmin batchV=new VerOwnrChangetoSemiAdmin();

 batchV.LogoTransfertosemiadmin();

}

}

 

2. Actual class

 

public class VerOwnrChangetoSemiAdmin

{

public void LogoTransfertosemiadmin()

{

batch_VerOwnrChangetoSemiAdmin verchange =new batch_VerOwnrChangetoSemiAdmin(query,Logolist,semiadmin.id,semiadmin.Email);

ID myBatchJobID = Database.executeBatch(verchange,1);

}

}

 

3.Batch class

 

globalclass batch_VerOwnrChangetoSemiAdmin implementsDatabase.Batchable<sObject> {

 

globalfinal String query;

globalfinal Id semiadminid;

globalfinal String semiadmemail;

globalList<Account> paracclist;

 

global batch_VerOwnrChangetoSemiAdmin(String qq,List<Account> logolist,Id semiadm,String semiadminemail)

{

query=qq;

semiadminid=semiadm;

semiadmemail=semiadminemail;

paracclist=logolist;

}

globalDatabase.QueryLocator start(Database.BatchableContext ctx)

{

 

returnDatabase.getQueryLocator(query);

}

globalvoid execute(Database.BatchableContext ctx, List<Account> acclist)

{

// some logic

}

 

}

globalvoidfinish(Database.BatchableContext ctx)

{

}

 

}

The execute method from batch class is not covered in the test coverage. Start method is getting invoked.

 

Please suggest

 

Thanks

 

 

public AccMvmtController()

{

 

public AccMvmtController(ApexPages.standardController cont)

{

fromLogo=newAccount_Movement__c();

toLogo =newAccount_Movement__c();

isnotblank=false; 

}

 

publicAccMvmtController()

{

fromLogo=newAccount_Movement__c();

toLogo =newAccount_Movement__c();

isnotblank=false; 

}

}

 

how to pass values to the no-argument constructor in my test method?

 

Please suggest.

 

Hi,

 

fromLogo and ToLogo are two lookup fields to account from a custom object (Account_Movement__c)  in my VF page.

 

public with sharing class AccMvmtController

{

public AccMvmtController(ApexPages.standardController cont)

{

fromLogo=newAccount_Movement__c();

toLogo =newAccount_Movement__c();

isnotblank=

false;

 }

 

public Account_Movement__c fromLogo {get;set;}

 

publicAccount_Movement__c toLogo {get;set;}

 

}

 

@istest

privatestaticvoidtestAccMvmtController()

{

 

System.runas(semiAdmin) {

 

Test.StartTest();

 

PageReference pageref = Page.CompanyMovement;

Test.setCurrentPage(pageRef);

 

Test.StopTest();

 

}

 

How to set parameters for fromLogo and ToLogo in my test class

 

Please suggest.

 

Thanks

 

Hi,

 

I have an after update trigger on Account. When a field is updated to 0, the account shud be deleted from the system. For that, i have the after update trigger and then a @ future class. It is giving me the follwing error like

 

Future method cannot be called from a future or batch method.

 

I checked the static boolean variable also to avoid recursive calls. Please check my code below and suggest.

 

1.trigger

SME_LogoDelete onAccount (afterupdate)

{

if

(Utility.isFutureUpdate != true){

 

Account[] newacc=trigger.NEW;

 

Account[] oldacc=trigger.OLD;

List<String> dellist=

newList<String>();

 

for(integer i=0;i<newacc.size();i++)

{

if(newacc[i].Number_of_Accounts__c!=oldacc[i].Number_of_Accounts__c && newacc[i].Number_of_Accounts__c==0)

{

dellist.add(newacc[i].id);

}

}

system.debug('******SME_LogoDelete22222*******'+dellist);

SME_LOGODelete.deletelogo(dellist);

}

}

 

2. Static boolean check

 

public class Utility{
 
    public static boolean isFutureUpdate=false;
 
}

 

3. Future call

 

global class SME_LOGODelete {
@future
public static void deletelogo(List<String> dellist)
 {
  List<Account> deletelist=new List<Account>([select Id from Account where ID=: dellist]);
  Utility.isFutureUpdate = true;

  System.debug('Method called with: '+dellist);
  DELETE deletelist;
 
  }
}

 

Thanks

Hi,

 

I am trying to call a future method from a before trigger.

 

Insert Operation is hapening fine.

 

Update, Delete are not getting executed.

 

Delete is failed with Error333: []

 

Update is failed with an error like 

Future method cannot be called from a future or batch method: MyFutureClass.myMethod(Id)

Please suggest.

 

trigger futurecheck on Account (after update) 

{
   system.debug('Name issssss ' + Trigger.NEW[0].name);
   Account acc = [SELECT name FROM Account WHERE name = 'Thru Future'];
   MyFutureClass.myMethod(acc.Id);
   
}


global class MyFutureClass
{

@future (callout=false)
Public static void myMethod(Id i)
{
System.debug('Method calleddddddd '+ i);

try {
acc.AccountSource='Phone Inquiry';
update acc;
}
catch (DmlException e) {


}

 

Hi,

 

I have a scenario of calling a class which inturn invokes the batch class. In normal scenario, the batch is getting invoked from the class, but coming to test method, batch is invoked execute method is not covered at all. Even the below line is in RED only.

 

global void execute(Database.BatchableContext ctx, List<Account> acclist)      {

1. Test class

private class Test_OwnerShipChanges

 Static testMethodvoid nonverifiedmailintimation()

{

 VerOwnrChangetoSemiAdmin batchV=new VerOwnrChangetoSemiAdmin();

 batchV.LogoTransfertosemiadmin();

}

}

 

2. Actual class

 

public class VerOwnrChangetoSemiAdmin

{

public void LogoTransfertosemiadmin()

{

batch_VerOwnrChangetoSemiAdmin verchange =new batch_VerOwnrChangetoSemiAdmin(query,Logolist,semiadmin.id,semiadmin.Email);

ID myBatchJobID = Database.executeBatch(verchange,1);

}

}

 

3.Batch class

 

globalclass batch_VerOwnrChangetoSemiAdmin implementsDatabase.Batchable<sObject> {

 

globalfinal String query;

globalfinal Id semiadminid;

globalfinal String semiadmemail;

globalList<Account> paracclist;

 

global batch_VerOwnrChangetoSemiAdmin(String qq,List<Account> logolist,Id semiadm,String semiadminemail)

{

query=qq;

semiadminid=semiadm;

semiadmemail=semiadminemail;

paracclist=logolist;

}

globalDatabase.QueryLocator start(Database.BatchableContext ctx)

{

 

returnDatabase.getQueryLocator(query);

}

globalvoid execute(Database.BatchableContext ctx, List<Account> acclist)

{

// some logic

}

 

}

globalvoidfinish(Database.BatchableContext ctx)

{

}

 

}

The execute method from batch class is not covered in the test coverage. Start method is getting invoked.

 

Please suggest

 

Thanks

 

 

Hi,

 

fromLogo and ToLogo are two lookup fields to account from a custom object (Account_Movement__c)  in my VF page.

 

public with sharing class AccMvmtController

{

public AccMvmtController(ApexPages.standardController cont)

{

fromLogo=newAccount_Movement__c();

toLogo =newAccount_Movement__c();

isnotblank=

false;

 }

 

public Account_Movement__c fromLogo {get;set;}

 

publicAccount_Movement__c toLogo {get;set;}

 

}

 

@istest

privatestaticvoidtestAccMvmtController()

{

 

System.runas(semiAdmin) {

 

Test.StartTest();

 

PageReference pageref = Page.CompanyMovement;

Test.setCurrentPage(pageRef);

 

Test.StopTest();

 

}

 

How to set parameters for fromLogo and ToLogo in my test class

 

Please suggest.

 

Thanks

 

Hi,

 

I have an after update trigger on Account. When a field is updated to 0, the account shud be deleted from the system. For that, i have the after update trigger and then a @ future class. It is giving me the follwing error like

 

Future method cannot be called from a future or batch method.

 

I checked the static boolean variable also to avoid recursive calls. Please check my code below and suggest.

 

1.trigger

SME_LogoDelete onAccount (afterupdate)

{

if

(Utility.isFutureUpdate != true){

 

Account[] newacc=trigger.NEW;

 

Account[] oldacc=trigger.OLD;

List<String> dellist=

newList<String>();

 

for(integer i=0;i<newacc.size();i++)

{

if(newacc[i].Number_of_Accounts__c!=oldacc[i].Number_of_Accounts__c && newacc[i].Number_of_Accounts__c==0)

{

dellist.add(newacc[i].id);

}

}

system.debug('******SME_LogoDelete22222*******'+dellist);

SME_LOGODelete.deletelogo(dellist);

}

}

 

2. Static boolean check

 

public class Utility{
 
    public static boolean isFutureUpdate=false;
 
}

 

3. Future call

 

global class SME_LOGODelete {
@future
public static void deletelogo(List<String> dellist)
 {
  List<Account> deletelist=new List<Account>([select Id from Account where ID=: dellist]);
  Utility.isFutureUpdate = true;

  System.debug('Method called with: '+dellist);
  DELETE deletelist;
 
  }
}

 

Thanks