-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
8Questions
-
6Replies
i have one Radio button.if i select that radio button(itemlabel) corrosponded itemvalue should display on page..can any one help me
vf page:
<apex:page controller="radiobox_Class">
<apex:form>
<apex:pageBlock>
<apex:pageBlockSection >
<apex:selectRadio label="Select Hobby" borderVisible="true" immediate="true" disabled="false" value="{!SelectGame}">
<apex:selectOption itemlabel="FootBall" itemvalue="FB"/>
<apex:selectOption itemlabel="Tennis" itemvalue="TN"/>
<apex:selectOption itemlabel="Hockey" itemvalue="HOC"/>
<apex:selectOption itemlabel="CoCo" itemvalue="Co"/>
<apex:selectOption itemlabel="Cricket" itemvalue="Cric"/>
</apex:selectRadio>
<apex:commandButton value="Show Selected game" action="{!Display}"/>
<apex:outputLabel>your selected game code is....{!output }</apex:outputLabel>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
class:
public class radiobox_class {
public string output{get;set;}
public string SelectGame{get;set;}
public void Display(){
if(SelectGame=='FootBall'){
output='FB';
}else if(SelectGame=='Tennis'){
output='TN';
}else if(SelectGame=='Hockey'){
output='HOC';
}else if(SelectGame=='Cricket'){
output='CIC';
}else if(SelectGame=='CoCo'){
output='Co';
}else{
output='sorry some thing went wrong';
}
}
}
i want through method only
THanks in Advance
<apex:page controller="radiobox_Class">
<apex:form>
<apex:pageBlock>
<apex:pageBlockSection >
<apex:selectRadio label="Select Hobby" borderVisible="true" immediate="true" disabled="false" value="{!SelectGame}">
<apex:selectOption itemlabel="FootBall" itemvalue="FB"/>
<apex:selectOption itemlabel="Tennis" itemvalue="TN"/>
<apex:selectOption itemlabel="Hockey" itemvalue="HOC"/>
<apex:selectOption itemlabel="CoCo" itemvalue="Co"/>
<apex:selectOption itemlabel="Cricket" itemvalue="Cric"/>
</apex:selectRadio>
<apex:commandButton value="Show Selected game" action="{!Display}"/>
<apex:outputLabel>your selected game code is....{!output }</apex:outputLabel>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
class:
public class radiobox_class {
public string output{get;set;}
public string SelectGame{get;set;}
public void Display(){
if(SelectGame=='FootBall'){
output='FB';
}else if(SelectGame=='Tennis'){
output='TN';
}else if(SelectGame=='Hockey'){
output='HOC';
}else if(SelectGame=='Cricket'){
output='CIC';
}else if(SelectGame=='CoCo'){
output='Co';
}else{
output='sorry some thing went wrong';
}
}
}
i want through method only
THanks in Advance
-
- randheer practise
- September 07, 2016
- Like
- 0
- Continue reading or reply
Can Anyone help me with an Ex of Apex Class and its Testclass using test.loaddata.
As per documentation iam cleared but how to do in practical to a basic Apex class and its Testclass using test.loaddata method
Its urgent please helpme anyone
Thanks in Advance
Its urgent please helpme anyone
Thanks in Advance
-
- randheer practise
- September 01, 2016
- Like
- 0
- Continue reading or reply
i have a basic insert class and two users user1 and user2..but for me only user2 can access the class and insert the class,if user1 executes it should not insert the record or he should not access the class
i have written a class,but both users are executing the class,but only user2 should insert the record what mistake is there in my class can annyone tell me.
class
public class inserting {
public void insertingrecords(string nm,decimal dd){
Account a = new Account();
a.name=nm;
insert a;
}
}
testclass using system.runas():
@isTest
private class TestRunAs {
public static testMethod void testRunAs() {
// Setup test data
// This code runs as the system user
Profile p = [SELECT Id,name FROM Profile WHERE Name='System Administrator'];
system.debug('values in p==='+'p.Name is '+p.name+'p.id is '+p.Id);
/*User u = new User(Alias ='rprac', Email='sharath.kanukuntla1@gmail.com',
EmailEncodingKey='UTF-8', LastName='practise1', LanguageLocaleKey='en_US',
LocaleSidKey='en_US', ProfileId = p.Id,
TimeZoneSidKey='America/Los_Angeles', UserName='randheer.practise1@gmail.com');
system.debug('user details are====== '+'email is '+u.Email+'Alias is '+u.Alias+'Profile id is '+u.ProfileId);
System.runAs(u) {
// The following code runs as user 'u'
System.debug('Current User: ' + UserInfo.getUserName());
System.debug('Current Profile: ' + UserInfo.getProfileId());
}*/
User u3 = [SELECT Id FROM User WHERE UserName='randheer.practise1@gmail.com'];
System.runAs(u3) {
inserting obj = new inserting();
obj.insertingrecords('sresht',12.22);
System.debug('Current User: ' + UserInfo.getUserName());
System.debug('Current Profile: ' + UserInfo.getProfileId());
}
}
}
class
public class inserting {
public void insertingrecords(string nm,decimal dd){
Account a = new Account();
a.name=nm;
insert a;
}
}
testclass using system.runas():
@isTest
private class TestRunAs {
public static testMethod void testRunAs() {
// Setup test data
// This code runs as the system user
Profile p = [SELECT Id,name FROM Profile WHERE Name='System Administrator'];
system.debug('values in p==='+'p.Name is '+p.name+'p.id is '+p.Id);
/*User u = new User(Alias ='rprac', Email='sharath.kanukuntla1@gmail.com',
EmailEncodingKey='UTF-8', LastName='practise1', LanguageLocaleKey='en_US',
LocaleSidKey='en_US', ProfileId = p.Id,
TimeZoneSidKey='America/Los_Angeles', UserName='randheer.practise1@gmail.com');
system.debug('user details are====== '+'email is '+u.Email+'Alias is '+u.Alias+'Profile id is '+u.ProfileId);
System.runAs(u) {
// The following code runs as user 'u'
System.debug('Current User: ' + UserInfo.getUserName());
System.debug('Current Profile: ' + UserInfo.getProfileId());
}*/
User u3 = [SELECT Id FROM User WHERE UserName='randheer.practise1@gmail.com'];
System.runAs(u3) {
inserting obj = new inserting();
obj.insertingrecords('sresht',12.22);
System.debug('Current User: ' + UserInfo.getUserName());
System.debug('Current Profile: ' + UserInfo.getProfileId());
}
}
}
-
- randheer practise
- August 30, 2016
- Like
- 0
- Continue reading or reply
Iam getting 95% of code coverage but iam unable to cover the catch block in my test class to the below upsert class,can anyone help me
public class UpsertDml {
public list<Account> acc{get;set;}
//default constructor1
public UpsertDml(){
acc=new list<Account>();
}
public void upsertAccount()
{
Account a = new Account(Name='krishna');
try{
insert a;
}catch(Exception e){
system.debug('Record '+a.Name +' inserted successfully');
}
List<Account> accounts=[SELECT id,name FROM Account WHERE name='kanusupdated'];
If(accounts.size() > 0){
try{
for(Account a1:accounts)
{
if(a1.name=='kanusupdated')
{
Account a2=new Account();
a2.id=a1.id;
a2.name='kanus updated';
acc.add(a2);
}
}
update acc;
system.debug('records were updated successfully===='+acc);
}catch(DMLException e){
system.debug('records were not updated====='+e);
}
}
}
}
testclass.
@isTest
public class upsertDml_Test {
//to cover first Exception
public static testMethod void main1Method(){
Account a = new Account();
a.Name='krihna';
a.BillingCity='khhgkg';
insert a;
upsertDml sc = new upsertDml();
sc.upsertAccount();
}
public static testmethod list<Account> recordCreation(){
List<Account> ac = new List<Account>();
Account a = new Account();
a.Name = 'kanusupdated';
ac.add(a);
return ac;
}
public static testmethod void P_main(){
Test.startTest();
list<Account> acc1 = recordCreation();
insert acc1;
upsertDml sc = new upsertDml();
sc.acc = recordCreation();
system.debug('values in sc.acc ============='+sc.acc);
sc.upsertAccount();
Test.stopTest();
}
}
public list<Account> acc{get;set;}
//default constructor1
public UpsertDml(){
acc=new list<Account>();
}
public void upsertAccount()
{
Account a = new Account(Name='krishna');
try{
insert a;
}catch(Exception e){
system.debug('Record '+a.Name +' inserted successfully');
}
List<Account> accounts=[SELECT id,name FROM Account WHERE name='kanusupdated'];
If(accounts.size() > 0){
try{
for(Account a1:accounts)
{
if(a1.name=='kanusupdated')
{
Account a2=new Account();
a2.id=a1.id;
a2.name='kanus updated';
acc.add(a2);
}
}
update acc;
system.debug('records were updated successfully===='+acc);
}catch(DMLException e){
system.debug('records were not updated====='+e);
}
}
}
}
testclass.
@isTest
public class upsertDml_Test {
//to cover first Exception
public static testMethod void main1Method(){
Account a = new Account();
a.Name='krihna';
a.BillingCity='khhgkg';
insert a;
upsertDml sc = new upsertDml();
sc.upsertAccount();
}
public static testmethod list<Account> recordCreation(){
List<Account> ac = new List<Account>();
Account a = new Account();
a.Name = 'kanusupdated';
ac.add(a);
return ac;
}
public static testmethod void P_main(){
Test.startTest();
list<Account> acc1 = recordCreation();
insert acc1;
upsertDml sc = new upsertDml();
sc.acc = recordCreation();
system.debug('values in sc.acc ============='+sc.acc);
sc.upsertAccount();
Test.stopTest();
}
}
-
- randheer practise
- August 30, 2016
- Like
- 0
- Continue reading or reply
how to write test class to the undelete class with 100 coverage including try catch blocks
public class UndeleteDml {
public static void undeleteAccount()
{
List<Account> accounts=[SELECT id,Name FROM Account WHERE name like 'siri rao' all rows];
system.debug('No of undeleted records are============'+accounts.size());
try{
undelete accounts;
system.debug('No of records in Account============'+accounts);
system.debug('records were undeleted from recyle bin successfully');
}catch(Exception e){
system.debug('sorry records were not undeleted');
}
}
}
thanks in advance
-
- randheer practise
- August 29, 2016
- Like
- 0
- Continue reading or reply
in the below class for upsert functionality iam getting 95% code coverage but iam unable to cover code in catch block while iam inserting the record,canany one help me from that
apex class
public class UpsertDml {
public list<Account> acc{get;set;}
//default constructor1
public UpsertDml(){
acc=new list<Account>();
}
public void upsertAccount()
{
Account a = new Account(Name='k');
try{
insert a;
}catch(Exception e){
system.debug('Recor '+a.Name +' inserted successfully');
}
List<Account> accounts=[SELECT id,name FROM Account WHERE name='kanusupdated'];
If(accounts.size() > 0){
try{
for(Account a1:accounts)
{
if(a1.name=='kanusupdated')
{
Account a2=new Account();
a2.id=a1.id;
a2.name='kanus updated';
acc.add(a2);
}
}
update acc;
system.debug('records were updated successfully===='+acc);
}catch(DMLException e){
system.debug('records were not updated====='+e);
}
}
}
}
============testclass
@isTest
public class upsertDml_Test {
public static testmethod list<Account> recordCreation(){
List<Account> ac = new List<Account>();
Account a = new Account();
a.Name = 'kanusupdated';
ac.add(a);
return ac;
}
public static testmethod void P_main(){
Test.startTest();
Account a = new Account(name='kanusupdated');
list<Account> acc1 = recordCreation();
insert acc1;
upsertDml sc = new upsertDml();
sc.acc = recordCreation();
system.debug('values in sc.acc ============='+sc.acc);
sc.upsertAccount();
Test.stopTest();
}
}
thanks in advance..just cover the code at catch block while iam inserting record with name 'k'..thanks in advance
public class UpsertDml {
public list<Account> acc{get;set;}
//default constructor1
public UpsertDml(){
acc=new list<Account>();
}
public void upsertAccount()
{
Account a = new Account(Name='k');
try{
insert a;
}catch(Exception e){
system.debug('Recor '+a.Name +' inserted successfully');
}
List<Account> accounts=[SELECT id,name FROM Account WHERE name='kanusupdated'];
If(accounts.size() > 0){
try{
for(Account a1:accounts)
{
if(a1.name=='kanusupdated')
{
Account a2=new Account();
a2.id=a1.id;
a2.name='kanus updated';
acc.add(a2);
}
}
update acc;
system.debug('records were updated successfully===='+acc);
}catch(DMLException e){
system.debug('records were not updated====='+e);
}
}
}
}
============testclass
@isTest
public class upsertDml_Test {
public static testmethod list<Account> recordCreation(){
List<Account> ac = new List<Account>();
Account a = new Account();
a.Name = 'kanusupdated';
ac.add(a);
return ac;
}
public static testmethod void P_main(){
Test.startTest();
Account a = new Account(name='kanusupdated');
list<Account> acc1 = recordCreation();
insert acc1;
upsertDml sc = new upsertDml();
sc.acc = recordCreation();
system.debug('values in sc.acc ============='+sc.acc);
sc.upsertAccount();
Test.stopTest();
}
}
thanks in advance..just cover the code at catch block while iam inserting record with name 'k'..thanks in advance
-
- randheer practise
- August 26, 2016
- Like
- 0
- Continue reading or reply
canany one help me that how to write a testclass ..to the below undelete class
it should cover both try aswell as catch also
public class UndeleteDml {
public static void undeleteAccount()
{
List<Account> accounts=[SELECT id,Name FROM Account WHERE name like 'siri rao' all rows];
system.debug('No of undeleted records are============'+accounts.size());
try{
undelete accounts;
system.debug('No of records in Account============'+accounts);
system.debug('records were undeleted from recyle bin successfully');
}catch(Exception e){
system.debug('sorry records were not undeleted');
}
}
}
thanks in advance
public class UndeleteDml {
public static void undeleteAccount()
{
List<Account> accounts=[SELECT id,Name FROM Account WHERE name like 'siri rao' all rows];
system.debug('No of undeleted records are============'+accounts.size());
try{
undelete accounts;
system.debug('No of records in Account============'+accounts);
system.debug('records were undeleted from recyle bin successfully');
}catch(Exception e){
system.debug('sorry records were not undeleted');
}
}
}
thanks in advance
-
- randheer practise
- August 26, 2016
- Like
- 0
- Continue reading or reply
iam writing test class to DeleteDML class iam gettinh 80%coverage but iam unable to cover code in Catch block.thanks in advance
DeleteDMl class
public class DeleteDml {
public void accountInserting(){
//fetching old records with name kanus
List<Account> accounts =[SELECT id,name from Account WHERE name='kanus'];
try{
delete accounts;
}catch(Exception e){
system.debug('records are not deleted');
}
}
}
testclass
@istest
public class DeleteDML_test {
public static testMethod Account insertingAccount(){
test.startTest();
Account a = new Account();
a.Name='kanus';
insert a;
DeleteDml d = new DeleteDml();
d.accountInserting();
Test.stopTest();
return a;
}
public static testMethod void Method2(){
Test.startTest();
Account a1=insertingAccount();
Account a2=[SELECT id,name FROM Account WHERE name='kanus123'];
try{
delete a2;
}catch(Exception e){
system.debug('no record with name kanus123');
}
test.stopTest();
DeleteDml d1 = new DeleteDml();
d1.accountInserting();
}
}
public class DeleteDml {
public void accountInserting(){
//fetching old records with name kanus
List<Account> accounts =[SELECT id,name from Account WHERE name='kanus'];
try{
delete accounts;
}catch(Exception e){
system.debug('records are not deleted');
}
}
}
testclass
@istest
public class DeleteDML_test {
public static testMethod Account insertingAccount(){
test.startTest();
Account a = new Account();
a.Name='kanus';
insert a;
DeleteDml d = new DeleteDml();
d.accountInserting();
Test.stopTest();
return a;
}
public static testMethod void Method2(){
Test.startTest();
Account a1=insertingAccount();
Account a2=[SELECT id,name FROM Account WHERE name='kanus123'];
try{
delete a2;
}catch(Exception e){
system.debug('no record with name kanus123');
}
test.stopTest();
DeleteDml d1 = new DeleteDml();
d1.accountInserting();
}
}
-
- randheer practise
- August 26, 2016
- Like
- 0
- Continue reading or reply
Calling batch from trigger
Am inserting 1000 records to Task object, as per the trigger functionality it splits in 200 and inserts/updates the records. During this insertion 5 batches splits up and running concurrently this is causing some failures in batches. So i need to create list of 1000 records during insert in the trigger and call the batch apex for single time kindly help me very urgent
- gowtham asokan 11
- September 01, 2016
- Like
- 0
- Continue reading or reply
- sfdcjoey
- August 30, 2016
- Like
- 0
- Continue reading or reply
iam writing test class to DeleteDML class iam gettinh 80%coverage but iam unable to cover code in Catch block.thanks in advance
DeleteDMl class
public class DeleteDml {
public void accountInserting(){
//fetching old records with name kanus
List<Account> accounts =[SELECT id,name from Account WHERE name='kanus'];
try{
delete accounts;
}catch(Exception e){
system.debug('records are not deleted');
}
}
}
testclass
@istest
public class DeleteDML_test {
public static testMethod Account insertingAccount(){
test.startTest();
Account a = new Account();
a.Name='kanus';
insert a;
DeleteDml d = new DeleteDml();
d.accountInserting();
Test.stopTest();
return a;
}
public static testMethod void Method2(){
Test.startTest();
Account a1=insertingAccount();
Account a2=[SELECT id,name FROM Account WHERE name='kanus123'];
try{
delete a2;
}catch(Exception e){
system.debug('no record with name kanus123');
}
test.stopTest();
DeleteDml d1 = new DeleteDml();
d1.accountInserting();
}
}
public class DeleteDml {
public void accountInserting(){
//fetching old records with name kanus
List<Account> accounts =[SELECT id,name from Account WHERE name='kanus'];
try{
delete accounts;
}catch(Exception e){
system.debug('records are not deleted');
}
}
}
testclass
@istest
public class DeleteDML_test {
public static testMethod Account insertingAccount(){
test.startTest();
Account a = new Account();
a.Name='kanus';
insert a;
DeleteDml d = new DeleteDml();
d.accountInserting();
Test.stopTest();
return a;
}
public static testMethod void Method2(){
Test.startTest();
Account a1=insertingAccount();
Account a2=[SELECT id,name FROM Account WHERE name='kanus123'];
try{
delete a2;
}catch(Exception e){
system.debug('no record with name kanus123');
}
test.stopTest();
DeleteDml d1 = new DeleteDml();
d1.accountInserting();
}
}
- randheer practise
- August 26, 2016
- Like
- 0
- Continue reading or reply