You need to sign in to do that
Don't have an account?
Caisa
Help: Error Message
Hello,
I am brand new to Apex.
I am getting the following error: Error: Compile Error: Expression cannot be a statement at line 47 column 7
o.Dynamic_Dates_TB__c is of type Checbox.
This is the code I wrote. What am I doing wrong?
trigger TBAutoClientInitiation on Opportunity (before update)
{
public static Boolean IsWeekendDay(Date dateParam)
{
boolean result = false;
system.debug('dateParam = '+dateParam);
//Recover the day of the week
Date startOfWeek = dateParam.toStartOfWeek();
system.debug('startOfWeek = '+startOfWeek);
Integer dayOfWeek = dateParam.day() - startOfWeek.day();
system.debug('dayOfWeek = '+dayOfWeek);
result = dayOfWeek == 0 || dayOfWeek == 6 ? true : false;
system.debug('result = '+result);
return result;
}
public static Date AddBusinessDays(Date StartDate, integer BusinessDaysToAdd )
{
//Add or decrease in BusinessDaysToAdd days
Date finalDate;
if(StartDate != null )
{
finalDate = StartDate;
system.debug('finaldate = '+finalDate);
integer direction = BusinessDaysToAdd < 0 ? -1 : 1;
system.debug('direction = '+direction);
while(BusinessDaysToAdd != 0)
{
finalDate = finalDate.AddDays(direction);
system.debug('BusinessDaysToAdd = '+BusinessDaysToAdd);
system.debug('finaldate = '+finalDate);
if (!isWeekendDay(finalDate))
{
BusinessDaysToAdd -= direction;
}
}
}
return finalDate;
}
{
for(Opportunity o : Trigger.new)
{
if(o.Dynamic_Dates_TB__c==True)
{
o.TB_Kickoff_Call_w_Client_ED__c == AddBusinessDays(o.TB_Kickoff_Call_w_Client_SD__c,1);
o.Data_Req_Start_Date__c == AddBusinessDays( o.TB_Kickoff_Call_w_Client_ED__c,18);
}
}
}
}
I am brand new to Apex.
I am getting the following error: Error: Compile Error: Expression cannot be a statement at line 47 column 7
o.Dynamic_Dates_TB__c is of type Checbox.
This is the code I wrote. What am I doing wrong?
trigger TBAutoClientInitiation on Opportunity (before update)
{
public static Boolean IsWeekendDay(Date dateParam)
{
boolean result = false;
system.debug('dateParam = '+dateParam);
//Recover the day of the week
Date startOfWeek = dateParam.toStartOfWeek();
system.debug('startOfWeek = '+startOfWeek);
Integer dayOfWeek = dateParam.day() - startOfWeek.day();
system.debug('dayOfWeek = '+dayOfWeek);
result = dayOfWeek == 0 || dayOfWeek == 6 ? true : false;
system.debug('result = '+result);
return result;
}
public static Date AddBusinessDays(Date StartDate, integer BusinessDaysToAdd )
{
//Add or decrease in BusinessDaysToAdd days
Date finalDate;
if(StartDate != null )
{
finalDate = StartDate;
system.debug('finaldate = '+finalDate);
integer direction = BusinessDaysToAdd < 0 ? -1 : 1;
system.debug('direction = '+direction);
while(BusinessDaysToAdd != 0)
{
finalDate = finalDate.AddDays(direction);
system.debug('BusinessDaysToAdd = '+BusinessDaysToAdd);
system.debug('finaldate = '+finalDate);
if (!isWeekendDay(finalDate))
{
BusinessDaysToAdd -= direction;
}
}
}
return finalDate;
}
{
for(Opportunity o : Trigger.new)
{
if(o.Dynamic_Dates_TB__c==True)
{
o.TB_Kickoff_Call_w_Client_ED__c == AddBusinessDays(o.TB_Kickoff_Call_w_Client_SD__c,1);
o.Data_Req_Start_Date__c == AddBusinessDays( o.TB_Kickoff_Call_w_Client_ED__c,18);
}
}
}
}
try this
All Answers
If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
try this
https://developer.salesforce.com/forums/ForumsMain?id=906F0000000g1GxIAI