-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
9Questions
-
8Replies
How to edit a apex test class which in present in change set
Hello All ,
While deploying my code to production I'm getting validation failover error due to some issue with a test class and apex class. I got the error but I'm not able to rectify them as I could not see an option to edit them. So what needs to be done in this situation? Do I need to edit those classes in sandbox and then again create a new change set? or somehow the old changeset could be reused? Please help me.
Thanks,
Tanoy
While deploying my code to production I'm getting validation failover error due to some issue with a test class and apex class. I got the error but I'm not able to rectify them as I could not see an option to edit them. So what needs to be done in this situation? Do I need to edit those classes in sandbox and then again create a new change set? or somehow the old changeset could be reused? Please help me.
Thanks,
Tanoy
- Tamojita Guhasarkar
- May 15, 2017
- Like
- 0
- Continue reading or reply
Need some clarification with Test class
Hello Guys,
I'm into a situation with a Test class , please help me to resolve it .
My Apex Code : -
public class Acc_dtls_nw
{
public String s;
public integer i =0;
public string acc_type_check(String Type_value)
{
string qry ='select count() from account where type=:Type_value';
i= database.countQuery(qry);
if (i>0)
{
s='Total no of account Types are: '+i;
}
else
{
s='Invalid type :';
}
return s;
}}
I'm not able to get a 100% code coverage for this class. below part is not included under code coverage
s='Total no of account Types are: '+i;
Now the test class I wrote is below
@istest
public class test_acc_dtls_nw
{
static testMethod void test_trucond()
{
Acc_dtls_nw ac= new Acc_dtls_nw();
string tst_true = ac.acc_type_check('Prospect');
// System.AssertEquals(ac.i,2);
string p ='prospect';
// System.AssertEquals(ac.s,p);
}
static testMethod void test_flscond()
{
Acc_dtls_nw ac= new Acc_dtls_nw();
string tst_flse = ac.acc_type_check('xyz');
// System.AssertEquals(ac.i,0);
}
}
So why that part is getting missed under code coverage? is it because S is not doing anything and used just for strong some text value? please help me to get this clarified.
I'm into a situation with a Test class , please help me to resolve it .
My Apex Code : -
public class Acc_dtls_nw
{
public String s;
public integer i =0;
public string acc_type_check(String Type_value)
{
string qry ='select count() from account where type=:Type_value';
i= database.countQuery(qry);
if (i>0)
{
s='Total no of account Types are: '+i;
}
else
{
s='Invalid type :';
}
return s;
}}
I'm not able to get a 100% code coverage for this class. below part is not included under code coverage
s='Total no of account Types are: '+i;
Now the test class I wrote is below
@istest
public class test_acc_dtls_nw
{
static testMethod void test_trucond()
{
Acc_dtls_nw ac= new Acc_dtls_nw();
string tst_true = ac.acc_type_check('Prospect');
// System.AssertEquals(ac.i,2);
string p ='prospect';
// System.AssertEquals(ac.s,p);
}
static testMethod void test_flscond()
{
Acc_dtls_nw ac= new Acc_dtls_nw();
string tst_flse = ac.acc_type_check('xyz');
// System.AssertEquals(ac.i,0);
}
}
So why that part is getting missed under code coverage? is it because S is not doing anything and used just for strong some text value? please help me to get this clarified.
- Tamojita Guhasarkar
- May 08, 2017
- Like
- 0
- Continue reading or reply
please help Getting conflicting dependency error while while installing force.com IDE for eclips -
Hi Guys,
Im getting below error while installing force.com IDE for eclips.
Cannot complete the install because of a conflicting dependency.
Software being installed: Force.com IDE 38.0.0.201701101558 (com.salesforce.ide.feature.feature.group 38.0.0.201701101558)
Software currently installed: Eclipse IDE for Java Developers 1.3.0.20100617-0520 (epp.package.java 1.3.0.20100617-0520)
Only one of the following can be installed at once:
Compare Support 3.5.100.I20100526-0800 (org.eclipse.compare 3.5.100.I20100526-0800)
Compare Support 3.5.101.R36x_v20100929-0800 (org.eclipse.compare 3.5.101.R36x_v20100929-0800)
Compare Support 3.5.600.v20150420-1449 (org.eclipse.compare 3.5.600.v20150420-1449)
Cannot satisfy dependency:
From: Force.com IDE 38.0.0.201701101558 (com.salesforce.ide.feature.feature.group 38.0.0.201701101558)
To: com.salesforce.ide.upgrade [38.0.0.201701101558]
Cannot satisfy dependency:
From: Force.com IDE Upgrade 38.0.0.201701101558 (com.salesforce.ide.upgrade 38.0.0.201701101558)
To: bundle org.eclipse.compare 3.5.600
Cannot satisfy dependency:
From: Eclipse IDE for Java Developers 1.3.0.20100617-0520 (epp.package.java 1.3.0.20100617-0520)
To: org.eclipse.epp.package.java.feature.feature.group [1.3.0.20100617-0520]
Cannot satisfy dependency:
From: EPP Java Package 1.3.0.20100617-0520 (org.eclipse.epp.package.java.feature.feature.group 1.3.0.20100617-0520)
To: org.eclipse.platform.feature.group [3.6.0.v20100602-9gF78GpqFt6trOGhL60z0oEx3fz-JKNwxPY]
Cannot satisfy dependency:
From: Eclipse Platform 3.6.0.v20100602-9gF78GpqFt6trOGhL60z0oEx3fz-JKNwxPY (org.eclipse.platform.feature.group 3.6.0.v20100602-9gF78GpqFt6trOGhL60z0oEx3fz-JKNwxPY)
To: org.eclipse.compare [3.5.100.I20100526-0800]
now , my Java and eclips both are kept under one separate folder and not in program files in C drive.
Im using jdk-8u131-windows-x64 for java
and
eclipse-java-helios-win32-x86_64 for Eclips.
Please can someone check and help me to resolve the issue.
Im getting below error while installing force.com IDE for eclips.
Cannot complete the install because of a conflicting dependency.
Software being installed: Force.com IDE 38.0.0.201701101558 (com.salesforce.ide.feature.feature.group 38.0.0.201701101558)
Software currently installed: Eclipse IDE for Java Developers 1.3.0.20100617-0520 (epp.package.java 1.3.0.20100617-0520)
Only one of the following can be installed at once:
Compare Support 3.5.100.I20100526-0800 (org.eclipse.compare 3.5.100.I20100526-0800)
Compare Support 3.5.101.R36x_v20100929-0800 (org.eclipse.compare 3.5.101.R36x_v20100929-0800)
Compare Support 3.5.600.v20150420-1449 (org.eclipse.compare 3.5.600.v20150420-1449)
Cannot satisfy dependency:
From: Force.com IDE 38.0.0.201701101558 (com.salesforce.ide.feature.feature.group 38.0.0.201701101558)
To: com.salesforce.ide.upgrade [38.0.0.201701101558]
Cannot satisfy dependency:
From: Force.com IDE Upgrade 38.0.0.201701101558 (com.salesforce.ide.upgrade 38.0.0.201701101558)
To: bundle org.eclipse.compare 3.5.600
Cannot satisfy dependency:
From: Eclipse IDE for Java Developers 1.3.0.20100617-0520 (epp.package.java 1.3.0.20100617-0520)
To: org.eclipse.epp.package.java.feature.feature.group [1.3.0.20100617-0520]
Cannot satisfy dependency:
From: EPP Java Package 1.3.0.20100617-0520 (org.eclipse.epp.package.java.feature.feature.group 1.3.0.20100617-0520)
To: org.eclipse.platform.feature.group [3.6.0.v20100602-9gF78GpqFt6trOGhL60z0oEx3fz-JKNwxPY]
Cannot satisfy dependency:
From: Eclipse Platform 3.6.0.v20100602-9gF78GpqFt6trOGhL60z0oEx3fz-JKNwxPY (org.eclipse.platform.feature.group 3.6.0.v20100602-9gF78GpqFt6trOGhL60z0oEx3fz-JKNwxPY)
To: org.eclipse.compare [3.5.100.I20100526-0800]
now , my Java and eclips both are kept under one separate folder and not in program files in C drive.
Im using jdk-8u131-windows-x64 for java
and
eclipse-java-helios-win32-x86_64 for Eclips.
Please can someone check and help me to resolve the issue.
- Tamojita Guhasarkar
- April 29, 2017
- Like
- 0
- Continue reading or reply
How to make filed read only and copy value from other fields when picklist value is selected
Hello Team ,
Need help to overcome the situation, please help.
I've a custom object that contains customer information like customer name, address etc. I have few other fields on this object named Recipient, Recipient Name, Recipient Address. The recipient is a Picklist field which contains values like "Myself" , "Other" . Now the requirement is
1> If user select "Myself" , then Recipient Name, Recipient Address should become read only and copy values from customer name, address.
2> If user selects Other, then he can type Recipient Name, Recipient Address by his choice.
Can someone guide me to how to achieve this, please ?
Thanks,
TG
Need help to overcome the situation, please help.
I've a custom object that contains customer information like customer name, address etc. I have few other fields on this object named Recipient, Recipient Name, Recipient Address. The recipient is a Picklist field which contains values like "Myself" , "Other" . Now the requirement is
1> If user select "Myself" , then Recipient Name, Recipient Address should become read only and copy values from customer name, address.
2> If user selects Other, then he can type Recipient Name, Recipient Address by his choice.
Can someone guide me to how to achieve this, please ?
Thanks,
TG
- Tamojita Guhasarkar
- April 20, 2017
- Like
- 0
- Continue reading or reply
How to restrict users to view only his records where OWD is set to Public read only?
Hello All ,
For my Organization , for an Object the OWD is set to Public Read Only.I have total 2000 users.Now I want for only 10 users to be able to see only their own records , but others should be able to view each other records. Can it be achieved w/o changing the OWD ? Please help.
Thanks,
Tanoy
For my Organization , for an Object the OWD is set to Public Read Only.I have total 2000 users.Now I want for only 10 users to be able to see only their own records , but others should be able to view each other records. Can it be achieved w/o changing the OWD ? Please help.
Thanks,
Tanoy
- Tamojita Guhasarkar
- March 27, 2017
- Like
- 0
- Continue reading or reply
Getting Null Pointer exception error while clicking on custom next button on Visuslforce Page
Hello Folks,
I'm trying to add next/previous/first/last - the pageinitiations on a Custom Controller page. But while clicing the button, I'm getting below error
System.NullPointerException: Attempt to de-reference a null object
Error is in expression '{!last}' in component <apex:commandButton> in page cus_message: Class.cus_message.last: line 31, column 1
Class.cus_message.last: line 31, column 1
Can someone please help to resolve the same.
Controller Code
public class cus_message
{
List<Account> acts =new List<account>();
public ApexPages.StandardSetController con {
get;
set;
}
public List<Account> getHigh_revenue_List()
{
acts =[select name,phone,industry,type,AnnualRevenue from Account where AnnualRevenue>50000];
system.debug('inside high revenue');
return acts;
}
Public List<Account> getLow_revenue_List()
{
acts =[select name,phone,industry,type,AnnualRevenue from Account where AnnualRevenue = NULL];
system.debug('inside low revenue');
return acts;
}
public void first() {
this.con.first();
}
// returns the last page of records
public void last() {
this.con.last();
}
// returns the previous page of records
public void previous() {
this.con.previous();
}
// returns the next page of records
public void next() {
this.con.next();
}
}
Visualforce Page
<apex:page controller="cus_message">
<apex:form >
<apex:pageBlock id="block_ID">
<apex:pageblockButtons >
<apex:commandButton value="Next Page" action="{!next}"/>
<apex:commandButton value="Last Page" action="{!last}"/>
</apex:pageblockButtons>
<apex:tabPanel >
<apex:tab label="High Revenue">
<apex:pageblockTable value="{!High_revenue_List}" var="var1">
<apex:column value="{!var1.name}"/>
<apex:column value="{!var1.industry}"/>
<apex:column value="{!var1.type}"/>
<apex:column value="{!var1.AnnualRevenue}"/>
</apex:pageblockTable>
</apex:tab>
<apex:tab label="Zero Revenue">
<apex:pageblockTable value="{!Low_revenue_List}" var="var2">
<apex:column value="{!var2.name}"/>
<apex:column value="{!var2.industry}"/>
<apex:column value="{!var2.type}"/>
<apex:column value="{!var2.AnnualRevenue}"/>
</apex:pageblockTable>
</apex:tab>
</apex:tabPanel>
</apex:pageBlock>
</apex:form>
</apex:page>
I'm trying to add next/previous/first/last - the pageinitiations on a Custom Controller page. But while clicing the button, I'm getting below error
System.NullPointerException: Attempt to de-reference a null object
Error is in expression '{!last}' in component <apex:commandButton> in page cus_message: Class.cus_message.last: line 31, column 1
Class.cus_message.last: line 31, column 1
Can someone please help to resolve the same.
Controller Code
public class cus_message
{
List<Account> acts =new List<account>();
public ApexPages.StandardSetController con {
get;
set;
}
public List<Account> getHigh_revenue_List()
{
acts =[select name,phone,industry,type,AnnualRevenue from Account where AnnualRevenue>50000];
system.debug('inside high revenue');
return acts;
}
Public List<Account> getLow_revenue_List()
{
acts =[select name,phone,industry,type,AnnualRevenue from Account where AnnualRevenue = NULL];
system.debug('inside low revenue');
return acts;
}
public void first() {
this.con.first();
}
// returns the last page of records
public void last() {
this.con.last();
}
// returns the previous page of records
public void previous() {
this.con.previous();
}
// returns the next page of records
public void next() {
this.con.next();
}
}
Visualforce Page
<apex:page controller="cus_message">
<apex:form >
<apex:pageBlock id="block_ID">
<apex:pageblockButtons >
<apex:commandButton value="Next Page" action="{!next}"/>
<apex:commandButton value="Last Page" action="{!last}"/>
</apex:pageblockButtons>
<apex:tabPanel >
<apex:tab label="High Revenue">
<apex:pageblockTable value="{!High_revenue_List}" var="var1">
<apex:column value="{!var1.name}"/>
<apex:column value="{!var1.industry}"/>
<apex:column value="{!var1.type}"/>
<apex:column value="{!var1.AnnualRevenue}"/>
</apex:pageblockTable>
</apex:tab>
<apex:tab label="Zero Revenue">
<apex:pageblockTable value="{!Low_revenue_List}" var="var2">
<apex:column value="{!var2.name}"/>
<apex:column value="{!var2.industry}"/>
<apex:column value="{!var2.type}"/>
<apex:column value="{!var2.AnnualRevenue}"/>
</apex:pageblockTable>
</apex:tab>
</apex:tabPanel>
</apex:pageBlock>
</apex:form>
</apex:page>
- Tamojita Guhasarkar
- March 01, 2017
- Like
- 0
- Continue reading or reply
<apex:dataList > - why and where to use?
Hello Folks, can someone plz explain the benefit of using <apex:dataList > .and some situation where we need to use <apex:dataList > ?
Thanks in Advance ,
Tanoy
Thanks in Advance ,
Tanoy
- Tamojita Guhasarkar
- February 13, 2017
- Like
- 0
- Continue reading or reply
Doubt Clear on SFDC Governor limit - bulkfy DML
Hello Folks ,
Please help me to clear few bacis doubts related to Governor limit - bulkfy DML
Case 1: My code is like below
List<Account> act = [ some query and it retrns 5000 records ];
for ( account a : act)
{
a.description =' updated by script';
}
update act;
Case 2: My code is like below
List<Account> act = [ some query and it retrns 5000 records ];
List<Account> new_act = new List<Account>();
for ( account a: act)
{
a.description =' updated by script ';
new_act.add(a);
}
update new_act;
================================
Ok so my question is as my quesry is retriving 5000 records and I want to update these records ,so I needto Bultyfly my dml so it will not breach the govornor limit . so in to achive this , as per my understading , both of these approches should do the same work , i.e , as I worte the Update outside the loop, hence it will execute only once ( though the for loop goes for 5000 times ) and update all these 5000 records.
So is this correct ? can someone clafiry please .
Thanks,
Tanoy
Please help me to clear few bacis doubts related to Governor limit - bulkfy DML
Case 1: My code is like below
List<Account> act = [ some query and it retrns 5000 records ];
for ( account a : act)
{
a.description =' updated by script';
}
update act;
Case 2: My code is like below
List<Account> act = [ some query and it retrns 5000 records ];
List<Account> new_act = new List<Account>();
for ( account a: act)
{
a.description =' updated by script ';
new_act.add(a);
}
update new_act;
================================
Ok so my question is as my quesry is retriving 5000 records and I want to update these records ,so I needto Bultyfly my dml so it will not breach the govornor limit . so in to achive this , as per my understading , both of these approches should do the same work , i.e , as I worte the Update outside the loop, hence it will execute only once ( though the for loop goes for 5000 times ) and update all these 5000 records.
So is this correct ? can someone clafiry please .
Thanks,
Tanoy
- Tamojita Guhasarkar
- February 05, 2017
- Like
- 0
- Continue reading or reply
Basic Question on Update fields
Hello All ,
I'hv a basic question on Updating fileds using APEX Code - rather I want to clear my concepts . The requirement is very simple. For Account Object , Update all Countries to United States of America where country is like US or USA . Now, I'm able to do it by writing below code
Public Class Acc_Country_Name_Change
{
Public Pagereference Name_update()
{
List<Account> Act = [SELECT name,BillingCountry FROM Account where BillingCountry in ( 'US','USA')];
for(Account a : act)
{
a.BillingCountry ='united states of america';
}
update act;
return null;
}
}
Now , I'hv two questions on this . Please help me to clear my concept.
1> in the For loop , its like FOR ( sObject : List ) - so why both are not List ? is it because in FOR Loop , only one row get processed at a time ? Or something else?
2> Inside the FOR loop , we are writing a.BillingCountry ='united states of america' , but in update its like Update act . Why so?
Can someone please help me to clarify my doubts? I know they are very basic , But I'm kind of confused.
Thanks,
Tanoy
I'hv a basic question on Updating fileds using APEX Code - rather I want to clear my concepts . The requirement is very simple. For Account Object , Update all Countries to United States of America where country is like US or USA . Now, I'm able to do it by writing below code
Public Class Acc_Country_Name_Change
{
Public Pagereference Name_update()
{
List<Account> Act = [SELECT name,BillingCountry FROM Account where BillingCountry in ( 'US','USA')];
for(Account a : act)
{
a.BillingCountry ='united states of america';
}
update act;
return null;
}
}
Now , I'hv two questions on this . Please help me to clear my concept.
1> in the For loop , its like FOR ( sObject : List ) - so why both are not List ? is it because in FOR Loop , only one row get processed at a time ? Or something else?
2> Inside the FOR loop , we are writing a.BillingCountry ='united states of america' , but in update its like Update act . Why so?
Can someone please help me to clarify my doubts? I know they are very basic , But I'm kind of confused.
Thanks,
Tanoy
- Tamojita Guhasarkar
- January 21, 2017
- Like
- 0
- Continue reading or reply
Need some clarification with Test class
Hello Guys,
I'm into a situation with a Test class , please help me to resolve it .
My Apex Code : -
public class Acc_dtls_nw
{
public String s;
public integer i =0;
public string acc_type_check(String Type_value)
{
string qry ='select count() from account where type=:Type_value';
i= database.countQuery(qry);
if (i>0)
{
s='Total no of account Types are: '+i;
}
else
{
s='Invalid type :';
}
return s;
}}
I'm not able to get a 100% code coverage for this class. below part is not included under code coverage
s='Total no of account Types are: '+i;
Now the test class I wrote is below
@istest
public class test_acc_dtls_nw
{
static testMethod void test_trucond()
{
Acc_dtls_nw ac= new Acc_dtls_nw();
string tst_true = ac.acc_type_check('Prospect');
// System.AssertEquals(ac.i,2);
string p ='prospect';
// System.AssertEquals(ac.s,p);
}
static testMethod void test_flscond()
{
Acc_dtls_nw ac= new Acc_dtls_nw();
string tst_flse = ac.acc_type_check('xyz');
// System.AssertEquals(ac.i,0);
}
}
So why that part is getting missed under code coverage? is it because S is not doing anything and used just for strong some text value? please help me to get this clarified.
I'm into a situation with a Test class , please help me to resolve it .
My Apex Code : -
public class Acc_dtls_nw
{
public String s;
public integer i =0;
public string acc_type_check(String Type_value)
{
string qry ='select count() from account where type=:Type_value';
i= database.countQuery(qry);
if (i>0)
{
s='Total no of account Types are: '+i;
}
else
{
s='Invalid type :';
}
return s;
}}
I'm not able to get a 100% code coverage for this class. below part is not included under code coverage
s='Total no of account Types are: '+i;
Now the test class I wrote is below
@istest
public class test_acc_dtls_nw
{
static testMethod void test_trucond()
{
Acc_dtls_nw ac= new Acc_dtls_nw();
string tst_true = ac.acc_type_check('Prospect');
// System.AssertEquals(ac.i,2);
string p ='prospect';
// System.AssertEquals(ac.s,p);
}
static testMethod void test_flscond()
{
Acc_dtls_nw ac= new Acc_dtls_nw();
string tst_flse = ac.acc_type_check('xyz');
// System.AssertEquals(ac.i,0);
}
}
So why that part is getting missed under code coverage? is it because S is not doing anything and used just for strong some text value? please help me to get this clarified.
- Tamojita Guhasarkar
- May 08, 2017
- Like
- 0
- Continue reading or reply
How to restrict users to view only his records where OWD is set to Public read only?
Hello All ,
For my Organization , for an Object the OWD is set to Public Read Only.I have total 2000 users.Now I want for only 10 users to be able to see only their own records , but others should be able to view each other records. Can it be achieved w/o changing the OWD ? Please help.
Thanks,
Tanoy
For my Organization , for an Object the OWD is set to Public Read Only.I have total 2000 users.Now I want for only 10 users to be able to see only their own records , but others should be able to view each other records. Can it be achieved w/o changing the OWD ? Please help.
Thanks,
Tanoy
- Tamojita Guhasarkar
- March 27, 2017
- Like
- 0
- Continue reading or reply
Getting Null Pointer exception error while clicking on custom next button on Visuslforce Page
Hello Folks,
I'm trying to add next/previous/first/last - the pageinitiations on a Custom Controller page. But while clicing the button, I'm getting below error
System.NullPointerException: Attempt to de-reference a null object
Error is in expression '{!last}' in component <apex:commandButton> in page cus_message: Class.cus_message.last: line 31, column 1
Class.cus_message.last: line 31, column 1
Can someone please help to resolve the same.
Controller Code
public class cus_message
{
List<Account> acts =new List<account>();
public ApexPages.StandardSetController con {
get;
set;
}
public List<Account> getHigh_revenue_List()
{
acts =[select name,phone,industry,type,AnnualRevenue from Account where AnnualRevenue>50000];
system.debug('inside high revenue');
return acts;
}
Public List<Account> getLow_revenue_List()
{
acts =[select name,phone,industry,type,AnnualRevenue from Account where AnnualRevenue = NULL];
system.debug('inside low revenue');
return acts;
}
public void first() {
this.con.first();
}
// returns the last page of records
public void last() {
this.con.last();
}
// returns the previous page of records
public void previous() {
this.con.previous();
}
// returns the next page of records
public void next() {
this.con.next();
}
}
Visualforce Page
<apex:page controller="cus_message">
<apex:form >
<apex:pageBlock id="block_ID">
<apex:pageblockButtons >
<apex:commandButton value="Next Page" action="{!next}"/>
<apex:commandButton value="Last Page" action="{!last}"/>
</apex:pageblockButtons>
<apex:tabPanel >
<apex:tab label="High Revenue">
<apex:pageblockTable value="{!High_revenue_List}" var="var1">
<apex:column value="{!var1.name}"/>
<apex:column value="{!var1.industry}"/>
<apex:column value="{!var1.type}"/>
<apex:column value="{!var1.AnnualRevenue}"/>
</apex:pageblockTable>
</apex:tab>
<apex:tab label="Zero Revenue">
<apex:pageblockTable value="{!Low_revenue_List}" var="var2">
<apex:column value="{!var2.name}"/>
<apex:column value="{!var2.industry}"/>
<apex:column value="{!var2.type}"/>
<apex:column value="{!var2.AnnualRevenue}"/>
</apex:pageblockTable>
</apex:tab>
</apex:tabPanel>
</apex:pageBlock>
</apex:form>
</apex:page>
I'm trying to add next/previous/first/last - the pageinitiations on a Custom Controller page. But while clicing the button, I'm getting below error
System.NullPointerException: Attempt to de-reference a null object
Error is in expression '{!last}' in component <apex:commandButton> in page cus_message: Class.cus_message.last: line 31, column 1
Class.cus_message.last: line 31, column 1
Can someone please help to resolve the same.
Controller Code
public class cus_message
{
List<Account> acts =new List<account>();
public ApexPages.StandardSetController con {
get;
set;
}
public List<Account> getHigh_revenue_List()
{
acts =[select name,phone,industry,type,AnnualRevenue from Account where AnnualRevenue>50000];
system.debug('inside high revenue');
return acts;
}
Public List<Account> getLow_revenue_List()
{
acts =[select name,phone,industry,type,AnnualRevenue from Account where AnnualRevenue = NULL];
system.debug('inside low revenue');
return acts;
}
public void first() {
this.con.first();
}
// returns the last page of records
public void last() {
this.con.last();
}
// returns the previous page of records
public void previous() {
this.con.previous();
}
// returns the next page of records
public void next() {
this.con.next();
}
}
Visualforce Page
<apex:page controller="cus_message">
<apex:form >
<apex:pageBlock id="block_ID">
<apex:pageblockButtons >
<apex:commandButton value="Next Page" action="{!next}"/>
<apex:commandButton value="Last Page" action="{!last}"/>
</apex:pageblockButtons>
<apex:tabPanel >
<apex:tab label="High Revenue">
<apex:pageblockTable value="{!High_revenue_List}" var="var1">
<apex:column value="{!var1.name}"/>
<apex:column value="{!var1.industry}"/>
<apex:column value="{!var1.type}"/>
<apex:column value="{!var1.AnnualRevenue}"/>
</apex:pageblockTable>
</apex:tab>
<apex:tab label="Zero Revenue">
<apex:pageblockTable value="{!Low_revenue_List}" var="var2">
<apex:column value="{!var2.name}"/>
<apex:column value="{!var2.industry}"/>
<apex:column value="{!var2.type}"/>
<apex:column value="{!var2.AnnualRevenue}"/>
</apex:pageblockTable>
</apex:tab>
</apex:tabPanel>
</apex:pageBlock>
</apex:form>
</apex:page>
- Tamojita Guhasarkar
- March 01, 2017
- Like
- 0
- Continue reading or reply
Doubt Clear on SFDC Governor limit - bulkfy DML
Hello Folks ,
Please help me to clear few bacis doubts related to Governor limit - bulkfy DML
Case 1: My code is like below
List<Account> act = [ some query and it retrns 5000 records ];
for ( account a : act)
{
a.description =' updated by script';
}
update act;
Case 2: My code is like below
List<Account> act = [ some query and it retrns 5000 records ];
List<Account> new_act = new List<Account>();
for ( account a: act)
{
a.description =' updated by script ';
new_act.add(a);
}
update new_act;
================================
Ok so my question is as my quesry is retriving 5000 records and I want to update these records ,so I needto Bultyfly my dml so it will not breach the govornor limit . so in to achive this , as per my understading , both of these approches should do the same work , i.e , as I worte the Update outside the loop, hence it will execute only once ( though the for loop goes for 5000 times ) and update all these 5000 records.
So is this correct ? can someone clafiry please .
Thanks,
Tanoy
Please help me to clear few bacis doubts related to Governor limit - bulkfy DML
Case 1: My code is like below
List<Account> act = [ some query and it retrns 5000 records ];
for ( account a : act)
{
a.description =' updated by script';
}
update act;
Case 2: My code is like below
List<Account> act = [ some query and it retrns 5000 records ];
List<Account> new_act = new List<Account>();
for ( account a: act)
{
a.description =' updated by script ';
new_act.add(a);
}
update new_act;
================================
Ok so my question is as my quesry is retriving 5000 records and I want to update these records ,so I needto Bultyfly my dml so it will not breach the govornor limit . so in to achive this , as per my understading , both of these approches should do the same work , i.e , as I worte the Update outside the loop, hence it will execute only once ( though the for loop goes for 5000 times ) and update all these 5000 records.
So is this correct ? can someone clafiry please .
Thanks,
Tanoy
- Tamojita Guhasarkar
- February 05, 2017
- Like
- 0
- Continue reading or reply
Basic Question on Update fields
Hello All ,
I'hv a basic question on Updating fileds using APEX Code - rather I want to clear my concepts . The requirement is very simple. For Account Object , Update all Countries to United States of America where country is like US or USA . Now, I'm able to do it by writing below code
Public Class Acc_Country_Name_Change
{
Public Pagereference Name_update()
{
List<Account> Act = [SELECT name,BillingCountry FROM Account where BillingCountry in ( 'US','USA')];
for(Account a : act)
{
a.BillingCountry ='united states of america';
}
update act;
return null;
}
}
Now , I'hv two questions on this . Please help me to clear my concept.
1> in the For loop , its like FOR ( sObject : List ) - so why both are not List ? is it because in FOR Loop , only one row get processed at a time ? Or something else?
2> Inside the FOR loop , we are writing a.BillingCountry ='united states of america' , but in update its like Update act . Why so?
Can someone please help me to clarify my doubts? I know they are very basic , But I'm kind of confused.
Thanks,
Tanoy
I'hv a basic question on Updating fileds using APEX Code - rather I want to clear my concepts . The requirement is very simple. For Account Object , Update all Countries to United States of America where country is like US or USA . Now, I'm able to do it by writing below code
Public Class Acc_Country_Name_Change
{
Public Pagereference Name_update()
{
List<Account> Act = [SELECT name,BillingCountry FROM Account where BillingCountry in ( 'US','USA')];
for(Account a : act)
{
a.BillingCountry ='united states of america';
}
update act;
return null;
}
}
Now , I'hv two questions on this . Please help me to clear my concept.
1> in the For loop , its like FOR ( sObject : List ) - so why both are not List ? is it because in FOR Loop , only one row get processed at a time ? Or something else?
2> Inside the FOR loop , we are writing a.BillingCountry ='united states of america' , but in update its like Update act . Why so?
Can someone please help me to clarify my doubts? I know they are very basic , But I'm kind of confused.
Thanks,
Tanoy
- Tamojita Guhasarkar
- January 21, 2017
- Like
- 0
- Continue reading or reply