You need to sign in to do that
Don't have an account?
Supriyo Ghosh 9
Apex class syntax
Hi,
public PageReference pageChange ()
{
string vertical = ApexPages.currentPage().getParameters().get('vert');string PrinCode = ApexPages.currentPage().getParameters().get('PriCd');string ArnNo = ApexPages.currentPage().getParameters().get('Arn');
string isrollover = ApexPages.currentPage().getParameters().get('Rollover');
I want to change String to boolean,but when I am giving it as Boolean isrollover = ......
It is showing error.Please help.
public PageReference pageChange ()
{
string vertical = ApexPages.currentPage().getParameters().get('vert');string PrinCode = ApexPages.currentPage().getParameters().get('PriCd');string ArnNo = ApexPages.currentPage().getParameters().get('Arn');
string isrollover = ApexPages.currentPage().getParameters().get('Rollover');
I want to change String to boolean,but when I am giving it as Boolean isrollover = ......
It is showing error.Please help.
Check once below code :
string isrollover = ApexPages.currentPage().getParameters().get('Rollover');
try {
Boolean b = isrollover .equals('TRUE');
}catch(Exception e) {
System.debug('******** THERE WAS AN EXCEPTION: ' + e.getMessage());
}
Hope this helps you!
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.
Salesforce Freelance Consultant/Developer/Administrator/Trainer
@For Salesforce Project Support: varaprasad4sfdc@gmail.com
Salesforce latest interview questions and training videos :
https://www.youtube.com/channel/UCOcam_Hb4KjeBdYJlJWV_ZA?sub_confirmation=1
Use like the below code
You should have to type cast your string variable into boolean.if
your string contains true then boolean variable returns true otherwise
it returns false.
public PageReference pageChange ()
{
string vertical = ApexPages.currentPage().getParameters().get('vert');
string PrinCode = ApexPages.currentPage().getParameters().get('PriCd');
string ArnNo = ApexPages.currentPage().getParameters().get('Arn');
string isrollover = ApexPages.currentPage().getParameters().get('Rollover');
boolean istrue = Boolean.valueOf(isrollover );
if(istrue ==true) {
//your code----
} else{
//your else code
}
}
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi