-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
5Questions
-
4Replies
contact record count
Hello Gurus:-
We have standard "Contact" object in SFDC.
and field is Total_Family_Member__c (number field )on the contactobject
my scenario is when contact is created in the same accountId then contact field (Total_Family_Member__c) is the update.
my codeis :--
trigger Totalfamilymember2 on Contact (Before insert,Before update,Before delete,Before Undelete) {
set<id> ids = new set<id>();
list<contact> contactToUpdate = new List<contact>();
if(Trigger.isinsert||Trigger.isupdate|| Trigger.isundelete){
for(contact con : trigger.new){
if(con.AccountId != null){
Ids.add(con.AccountId);
}
}
}
if(Trigger.isdelete){
for(contact con : trigger.old){
if(con.AccountId != null){
Ids.add(con.AccountId);
}
}
}
for(AggregateResult ar :[SELECT AccountId,count(id) related FROM Contact where AccountId in: Ids GROUP BY AccountId]){
contactToUpdate.add(new contact(Accountid = (Id)ar.get('AccountId'),Total_Family_Member__c= (Decimal)ar.get('related') ));
}
}
Result is not show please find ???
We have standard "Contact" object in SFDC.
and field is Total_Family_Member__c (number field )on the contactobject
my scenario is when contact is created in the same accountId then contact field (Total_Family_Member__c) is the update.
my codeis :--
trigger Totalfamilymember2 on Contact (Before insert,Before update,Before delete,Before Undelete) {
set<id> ids = new set<id>();
list<contact> contactToUpdate = new List<contact>();
if(Trigger.isinsert||Trigger.isupdate|| Trigger.isundelete){
for(contact con : trigger.new){
if(con.AccountId != null){
Ids.add(con.AccountId);
}
}
}
if(Trigger.isdelete){
for(contact con : trigger.old){
if(con.AccountId != null){
Ids.add(con.AccountId);
}
}
}
for(AggregateResult ar :[SELECT AccountId,count(id) related FROM Contact where AccountId in: Ids GROUP BY AccountId]){
contactToUpdate.add(new contact(Accountid = (Id)ar.get('AccountId'),Total_Family_Member__c= (Decimal)ar.get('related') ));
}
}
Result is not show please find ???
-
- chandan kumar 99
- December 29, 2017
- Like
- 0
- Continue reading or reply
i have a create custom controller to show list of account and also visual force page click button to New Account then show popup window and fill value then save value
my code is :-
public class AccountDetailCtr{
public Account account{get; set;}
public List<Account> getlstAcc(){
List<Account> accounts = new List<Account>();
accounts=[Select id,name,AnnualRevenue,rating,Industry,Phone,ShippingAddress,AccountNumber from account ];
if(accounts!=null && accounts.size()>0)
return accounts ;
else
ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.info,'No account record found'));
return accounts ;
}
public PageReference save() {
update account;
pagereference p = page.SecondPageSLDS;
p.setRedirect(true);
p.getParameters().put('id', account.Id);
return p;
}
}
when save button press then following error show
Attempt to de-reference a null object
Error is in expression '{!save}' in component <apex:commandButton> in page secondpageslds: Class.AccountDetailCtr.save: line 16, column 1
An unexpected error has occurred. Your development organization has been notified.
public class AccountDetailCtr{
public Account account{get; set;}
public List<Account> getlstAcc(){
List<Account> accounts = new List<Account>();
accounts=[Select id,name,AnnualRevenue,rating,Industry,Phone,ShippingAddress,AccountNumber from account ];
if(accounts!=null && accounts.size()>0)
return accounts ;
else
ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.info,'No account record found'));
return accounts ;
}
public PageReference save() {
update account;
pagereference p = page.SecondPageSLDS;
p.setRedirect(true);
p.getParameters().put('id', account.Id);
return p;
}
}
when save button press then following error show
Attempt to de-reference a null object
Error is in expression '{!save}' in component <apex:commandButton> in page secondpageslds: Class.AccountDetailCtr.save: line 16, column 1
An unexpected error has occurred. Your development organization has been notified.
-
- chandan kumar 99
- December 26, 2017
- Like
- 0
- Continue reading or reply
In Visualforce SLDS page click a new button then go to account new page using java script
Hello Gurus,
I have a create Account List page And create a button(New Account) in list page when clicking a new account button go to Account new page
My SLDS Button Code is:=
<div class="slds-col slds-no-flex slds-grid slds-align-top slds-button-group" role="group">
<button class="slds-button slds-button--neutral">New Account</button>
</div>
Thanks
I have a create Account List page And create a button(New Account) in list page when clicking a new account button go to Account new page
My SLDS Button Code is:=
<div class="slds-col slds-no-flex slds-grid slds-align-top slds-button-group" role="group">
<button class="slds-button slds-button--neutral">New Account</button>
</div>
Thanks
-
- chandan kumar 99
- December 22, 2017
- Like
- 0
- Continue reading or reply
SELF_REFERENCE_FROM_TRIGGER
Hi Gurus,
I have a trigger on Task object and I am trying to before insert and update a field Task object. I am getting following error message:
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger WeekendTasks caused an unexpected exception, contact your administrator: WeekendTasks: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 00T7F00000G5ulOUAR; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = 00T7F00000G5ulO) is currently in trigger WeekendTasks, therefore it cannot recursively update itself: []: Trigger.WeekendTasks: line 15, column 1
Here is my trigger
trigger WeekendTasks on Task (before insert,Before update) {
list<Task> Tasweek =new List<Task>();
for(Task tweek:Trigger.new){
if(tweek.Subject != null) {
Date origin = Date.newInstance(1900,1,6);
Date due = tweek.ActivityDate;
Integer x = origin.daysBetween(due);
Integer day = Math.mod(x,7);
if (day < 2 ) {
Task tas = new Task (Id = tweek.Id,ActivityDate = (tweek.ActivityDate + 2));
Tasweek.add(tas);
}
}
}
update Tasweek;
}
I have a trigger on Task object and I am trying to before insert and update a field Task object. I am getting following error message:
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger WeekendTasks caused an unexpected exception, contact your administrator: WeekendTasks: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 00T7F00000G5ulOUAR; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = 00T7F00000G5ulO) is currently in trigger WeekendTasks, therefore it cannot recursively update itself: []: Trigger.WeekendTasks: line 15, column 1
Here is my trigger
trigger WeekendTasks on Task (before insert,Before update) {
list<Task> Tasweek =new List<Task>();
for(Task tweek:Trigger.new){
if(tweek.Subject != null) {
Date origin = Date.newInstance(1900,1,6);
Date due = tweek.ActivityDate;
Integer x = origin.daysBetween(due);
Integer day = Math.mod(x,7);
if (day < 2 ) {
Task tas = new Task (Id = tweek.Id,ActivityDate = (tweek.ActivityDate + 2));
Tasweek.add(tas);
}
}
}
update Tasweek;
}
-
- chandan kumar 99
- December 21, 2017
- Like
- 0
- Continue reading or reply
can you create multi-select picklist using Apex class and Trigger in salesforce
Hi everyone
my question is
How Many way to create multi-select picklist. Please solve
Thanks
my question is
How Many way to create multi-select picklist. Please solve
Thanks
-
- chandan kumar 99
- November 17, 2017
- Like
- 0
- Continue reading or reply
SELF_REFERENCE_FROM_TRIGGER
Hi Gurus,
I have a trigger on Task object and I am trying to before insert and update a field Task object. I am getting following error message:
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger WeekendTasks caused an unexpected exception, contact your administrator: WeekendTasks: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 00T7F00000G5ulOUAR; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = 00T7F00000G5ulO) is currently in trigger WeekendTasks, therefore it cannot recursively update itself: []: Trigger.WeekendTasks: line 15, column 1
Here is my trigger
trigger WeekendTasks on Task (before insert,Before update) {
list<Task> Tasweek =new List<Task>();
for(Task tweek:Trigger.new){
if(tweek.Subject != null) {
Date origin = Date.newInstance(1900,1,6);
Date due = tweek.ActivityDate;
Integer x = origin.daysBetween(due);
Integer day = Math.mod(x,7);
if (day < 2 ) {
Task tas = new Task (Id = tweek.Id,ActivityDate = (tweek.ActivityDate + 2));
Tasweek.add(tas);
}
}
}
update Tasweek;
}
I have a trigger on Task object and I am trying to before insert and update a field Task object. I am getting following error message:
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger WeekendTasks caused an unexpected exception, contact your administrator: WeekendTasks: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 00T7F00000G5ulOUAR; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = 00T7F00000G5ulO) is currently in trigger WeekendTasks, therefore it cannot recursively update itself: []: Trigger.WeekendTasks: line 15, column 1
Here is my trigger
trigger WeekendTasks on Task (before insert,Before update) {
list<Task> Tasweek =new List<Task>();
for(Task tweek:Trigger.new){
if(tweek.Subject != null) {
Date origin = Date.newInstance(1900,1,6);
Date due = tweek.ActivityDate;
Integer x = origin.daysBetween(due);
Integer day = Math.mod(x,7);
if (day < 2 ) {
Task tas = new Task (Id = tweek.Id,ActivityDate = (tweek.ActivityDate + 2));
Tasweek.add(tas);
}
}
}
update Tasweek;
}
- chandan kumar 99
- December 21, 2017
- Like
- 0
- Continue reading or reply
can you create multi-select picklist using Apex class and Trigger in salesforce
Hi everyone
my question is
How Many way to create multi-select picklist. Please solve
Thanks
my question is
How Many way to create multi-select picklist. Please solve
Thanks
- chandan kumar 99
- November 17, 2017
- Like
- 0
- Continue reading or reply
Trigger on Contact for Total Family Members
- We have standard "Contact" object in SFDC.
- You have to add one Field in Contact Object that is "Total Family Members" type is Number(2,0):
- Let Account be the Family. So if there are 5 Contacts belongs to same account, that means these all 5 belongs to same family.
- Create a trigger on Contact to calculate "Family Members Count".
- Create one Account: Create New Contact as a child for it. Then Contact's "Total Family Member" will have value 1.
- Create another Contact for the same Account then Both Contact should have value 2 for "Total Family Member Field".
- if someone changes contact's family like : changing account lookup value for a contact, then Both family will reflect. Because one family member is removed from one family and added to new Family. values should be updated:
- All Contact's of Older Family should now have the "Total Family Member" value decreased by1.
- And for new family all Contact's "Total Family Member" will have value increased by1.
- arpit vijayvergiya
- May 17, 2017
- Like
- 0
- Continue reading or reply