You need to sign in to do that
Don't have an account?
Anuja Joshi 16
Error Error: Compile Error: unexpected token: ')' at line 25 column 40
Hello
I am new in Salesforce .I created VF page controller class.In that I got the month year and want to convert month which is in Number format into string so for this I wrote the method Getmonth() but having error.Please help.
public class UploadCSVFileController
{
private final Account acct;
public id accountid{get;set;}
public string Mon{get;set;}
public string Yrs{get;set;}
Public Period__c cp;
Public String Monthinletter;
Public String MonthWithZero;
public UploadCSVFileController(apexpages.standardcontroller stdcontroller)
{
system.debug('Inside Constructor');
acct=(Account)stdcontroller.getrecord();
accountid=acct.id;
System.debug('The account id'+accountid);
Mon = ApexPages.currentPage().getParameters().get('mm');
Yrs = ApexPages.currentPage().getParameters().get('yyyy');
System.debug('The current month is:'+Mon);
System.debug('The current year is:'+Yrs);
MonthWithZero=Mon.leftpad(2,'0');
string monthyear=MonthWithZero+'-'+yrs;
cp=[select id,name,Month_Year__c from Period__c WHERE name=:monthyear];
system.debug(cp);
}
public String GetMonth(MonthWithZero)
{
if(MonthWithZero=='01')
{
Monthinletter='January';
return Monthinletter;
}
}
}
I am new in Salesforce .I created VF page controller class.In that I got the month year and want to convert month which is in Number format into string so for this I wrote the method Getmonth() but having error.Please help.
public class UploadCSVFileController
{
private final Account acct;
public id accountid{get;set;}
public string Mon{get;set;}
public string Yrs{get;set;}
Public Period__c cp;
Public String Monthinletter;
Public String MonthWithZero;
public UploadCSVFileController(apexpages.standardcontroller stdcontroller)
{
system.debug('Inside Constructor');
acct=(Account)stdcontroller.getrecord();
accountid=acct.id;
System.debug('The account id'+accountid);
Mon = ApexPages.currentPage().getParameters().get('mm');
Yrs = ApexPages.currentPage().getParameters().get('yyyy');
System.debug('The current month is:'+Mon);
System.debug('The current year is:'+Yrs);
MonthWithZero=Mon.leftpad(2,'0');
string monthyear=MonthWithZero+'-'+yrs;
cp=[select id,name,Month_Year__c from Period__c WHERE name=:monthyear];
system.debug(cp);
}
public String GetMonth(MonthWithZero)
{
if(MonthWithZero=='01')
{
Monthinletter='January';
return Monthinletter;
}
}
}
I see no missing or extra "(" or ")" characters, but I do see one issue:
In the following line of code, the datatype is missing:
should actually be something like:
Hope this helps!
Best regards,
Martijn Schwärzer
P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
Change this line :
To this line:
This will solve the issue.
Please mark as best answer if it helps. Thanks