-
ChatterFeed
-
0Best Answers
-
1Likes Received
-
0Likes Given
-
7Questions
-
11Replies
How to Write a Test Class that covers the Single email Message in Trigger
Hi All,
trigger SendNotification on Savings_Risk_Checklist__c (After insert,after update) {
for(Savings_Risk_Checklist__c SCS :trigger.new) {
if (Trigger.isAfter && (Trigger.IsInsert || Trigger.IsUpdate)) {
string str = '';
str='<html>';
str=str+'<body>';
str=str+'<p> Hello,<br/> </p>';
str=str+'<p> This notification is to inform you that a Sales Leader has just submitted a Savings Risk Checklist form. Please follow the link below to review the form. <br/> </p>';
str=str+'<p> '+
SCS.Savings_Risk_Checklist_Link__c+' <br/> </p>';
str=str+'<p> If you have any issues accessing the link or form, please contact Melissa Umeda (melissa.umeda@cbre.com). <br/> </p>';
str=str+'<p>Thanks,<br/> </p>';
str=str+'<p>GWS Salesforce Operations Team<br/> </p>';
str=str+'</body>';
str=str+'</html>';
if(SCS.Savings_Checklist_Form_Status__c =='Proposal Submitted'|| SCS.Savings_Checklist_Form_Status__c=='Final From Submitted') {
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
//EmailTemplate et=[Select id from EmailTemplate where Name=:'Savings Risk Check List Proposal Submittion'];
//mail.setWhatId(SCS.ID);
mail.setTargetObjectId(userinfo.getUserId());
//mail.setTemplateId(et.id);
mail.setTargetObjectId(SCS.CreatedById);
mail.setTreatTargetObjectAsRecipient(false);
mail.setToAddresses(new List<String>{'Test@gmail.com'});
mail.setSaveAsActivity(false);
mail.setHtmlBody(str);
Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
}
}
}
}
Can Any one Suggests how can write a Test class for Above Trigger,
Thanks,
trigger SendNotification on Savings_Risk_Checklist__c (After insert,after update) {
for(Savings_Risk_Checklist__c SCS :trigger.new) {
if (Trigger.isAfter && (Trigger.IsInsert || Trigger.IsUpdate)) {
string str = '';
str='<html>';
str=str+'<body>';
str=str+'<p> Hello,<br/> </p>';
str=str+'<p> This notification is to inform you that a Sales Leader has just submitted a Savings Risk Checklist form. Please follow the link below to review the form. <br/> </p>';
str=str+'<p> '+
SCS.Savings_Risk_Checklist_Link__c+' <br/> </p>';
str=str+'<p> If you have any issues accessing the link or form, please contact Melissa Umeda (melissa.umeda@cbre.com). <br/> </p>';
str=str+'<p>Thanks,<br/> </p>';
str=str+'<p>GWS Salesforce Operations Team<br/> </p>';
str=str+'</body>';
str=str+'</html>';
if(SCS.Savings_Checklist_Form_Status__c =='Proposal Submitted'|| SCS.Savings_Checklist_Form_Status__c=='Final From Submitted') {
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
//EmailTemplate et=[Select id from EmailTemplate where Name=:'Savings Risk Check List Proposal Submittion'];
//mail.setWhatId(SCS.ID);
mail.setTargetObjectId(userinfo.getUserId());
//mail.setTemplateId(et.id);
mail.setTargetObjectId(SCS.CreatedById);
mail.setTreatTargetObjectAsRecipient(false);
mail.setToAddresses(new List<String>{'Test@gmail.com'});
mail.setSaveAsActivity(false);
mail.setHtmlBody(str);
Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
}
}
}
}
Can Any one Suggests how can write a Test class for Above Trigger,
Thanks,
- Vasu.P
- July 03, 2017
- Like
- 0
- Continue reading or reply
Target object ID error while sending email through Trigger for a Custom Object
Hi All,
trigger SendNotification on Savings_Risk_Checklist__c (After insert,after update) {
Savings_Risk_Checklist__c SCS = trigger.new[0];
if (Trigger.IsInsert || Trigger.IsUpdate) {
if(SCS.Savings_Checklist_Form_Status__c =='Proposal Submitted'|| SCS.Savings_Checklist_Form_Status__c=='Final From Submitted') {
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
EmailTemplate et=[Select id from EmailTemplate where Name=:'Savings Risk Check List Proposal Submittion'];
//mail.setWhatId(SCS.ID);
mail.setTargetObjectId(SCS.id);
mail.setTemplateId(et.id);
mail.setToAddresses(new List<String>{'putluruvishnu@gmail.com'});
mail.setSaveAsActivity(false);
Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
}
i have Written above code on Custom Object to send an email. but i am Getting Below Error
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger SendNotification caused an unexpected exception, contact your administrator: SendNotification: execution of AfterUpdate caused by: System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_TYPE_FOR_OPERATION, Only User, Contact, Lead, or Person objects are allowed for targetObjectId: 01I37000000kq3E.: [targetObjectId, 01I37000000kq3EEAQ]: Trigger.SendNotification: line 13, column 1
trigger SendNotification on Savings_Risk_Checklist__c (After insert,after update) {
Savings_Risk_Checklist__c SCS = trigger.new[0];
if (Trigger.IsInsert || Trigger.IsUpdate) {
if(SCS.Savings_Checklist_Form_Status__c =='Proposal Submitted'|| SCS.Savings_Checklist_Form_Status__c=='Final From Submitted') {
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
EmailTemplate et=[Select id from EmailTemplate where Name=:'Savings Risk Check List Proposal Submittion'];
//mail.setWhatId(SCS.ID);
mail.setTargetObjectId(SCS.id);
mail.setTemplateId(et.id);
mail.setToAddresses(new List<String>{'putluruvishnu@gmail.com'});
mail.setSaveAsActivity(false);
Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
}
i have Written above code on Custom Object to send an email. but i am Getting Below Error
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger SendNotification caused an unexpected exception, contact your administrator: SendNotification: execution of AfterUpdate caused by: System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_TYPE_FOR_OPERATION, Only User, Contact, Lead, or Person objects are allowed for targetObjectId: 01I37000000kq3E.: [targetObjectId, 01I37000000kq3EEAQ]: Trigger.SendNotification: line 13, column 1
- Vasu.P
- June 30, 2017
- Like
- 0
- Continue reading or reply
Sending Email through Trigger When Opportunity Stage Changes
Hi All,
i need to Send an Email When Opportunity stage changes. for this i have Write one Class and Trigger. when i Tried to Insert or Update an Opportunity i have received below error
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger SendEmailToAccount caused an unexpected exception, contact your administrator: SendEmailToAccount: execution of AfterInsert caused by: System.EmailException: SendEmail failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Missing targetObjectId with template: []: Class.HelperContactTrigger.sendEmail: line 34, column 1
Apex Class:
public with sharing class HelperContactTrigger {
public static List<Opportunity> sendEmail(List<Opportunity>Opportunities)
{
//query on template object
EmailTemplate et=[Select id from EmailTemplate where name=:'Approved By Manager'];
//list of emails
List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();
for(Opportunity Opp : Opportunities)
{
//check for Account
if(Opp.StageName =='Prospecting'|| Opp.StageName=='Qualification'){
//initiallize messaging method
Messaging.SingleEmailMessage singleMail = new Messaging.SingleEmailMessage();
//set object Id
List<String> sendTo = new List<String>();
sendTo.add('putluruvishnu@gmail.com');
singlemail.setToAddresses(sendTo);
//set template Id
singleMail.setTemplateId(et.Id);
//flag to false to stop inserting activity history
singleMail.setSaveAsActivity(false);
//add mail
emails.add(singleMail);
}
}
//send mail
Messaging.sendEmail(emails);
return Opportunities;
}
Apex Trigger:
----------------------
trigger SendEmailToAccount on Opportunity (after insert,after update)
{
if(Trigger.isAfter)
{
if(Trigger.isInsert )
{
//helper class for single email but bulk messages
HelperContactTrigger.sendEmail(trigger.new);
}
}
if(trigger.isAfter && trigger.isUpdate )
{
HelperContactTrigger.sendEmail(trigger.new);
}
}
i need to Send an Email When Opportunity stage changes. for this i have Write one Class and Trigger. when i Tried to Insert or Update an Opportunity i have received below error
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger SendEmailToAccount caused an unexpected exception, contact your administrator: SendEmailToAccount: execution of AfterInsert caused by: System.EmailException: SendEmail failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Missing targetObjectId with template: []: Class.HelperContactTrigger.sendEmail: line 34, column 1
Apex Class:
public with sharing class HelperContactTrigger {
public static List<Opportunity> sendEmail(List<Opportunity>Opportunities)
{
//query on template object
EmailTemplate et=[Select id from EmailTemplate where name=:'Approved By Manager'];
//list of emails
List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();
for(Opportunity Opp : Opportunities)
{
//check for Account
if(Opp.StageName =='Prospecting'|| Opp.StageName=='Qualification'){
//initiallize messaging method
Messaging.SingleEmailMessage singleMail = new Messaging.SingleEmailMessage();
//set object Id
List<String> sendTo = new List<String>();
sendTo.add('putluruvishnu@gmail.com');
singlemail.setToAddresses(sendTo);
//set template Id
singleMail.setTemplateId(et.Id);
//flag to false to stop inserting activity history
singleMail.setSaveAsActivity(false);
//add mail
emails.add(singleMail);
}
}
//send mail
Messaging.sendEmail(emails);
return Opportunities;
}
Apex Trigger:
----------------------
trigger SendEmailToAccount on Opportunity (after insert,after update)
{
if(Trigger.isAfter)
{
if(Trigger.isInsert )
{
//helper class for single email but bulk messages
HelperContactTrigger.sendEmail(trigger.new);
}
}
if(trigger.isAfter && trigger.isUpdate )
{
HelperContactTrigger.sendEmail(trigger.new);
}
}
- Vasu.P
- June 29, 2017
- Like
- 0
- Continue reading or reply
How to Auto Refresh a Standard Visual force page when an Workflow field update will happen
Hi All,
i have a standard opportunity page. also i have a field update on this. so i have to auto refresh my opportunity page when a field update happen. now i need to manully refresh the page. how can i achieve this. i have written a inline visual force page with a 'Reload' button embadded with the satndard page. but i need to manually click this button. i need the auto refresh the page.
Thanks,
i have a standard opportunity page. also i have a field update on this. so i have to auto refresh my opportunity page when a field update happen. now i need to manully refresh the page. how can i achieve this. i have written a inline visual force page with a 'Reload' button embadded with the satndard page. but i need to manually click this button. i need the auto refresh the page.
Thanks,
- Vasu.P
- May 15, 2017
- Like
- 1
- Continue reading or reply
Trigger is not working while Updating through Dataloadeer
Hi All,
trigger UpdateActiveProspect on Opportunity (after insert,after update){
list<account> ali=new list<account>();
if(trigger.isafter && (trigger.isinsert || trigger.isupdate)){
list<Opportunity> Opp=new list<Opportunity>();
List<Opportunity> opp1=new List<Opportunity>();
set<id> ids=new set<id>();
for(Opportunity o:trigger.new){
ids.add(o.accountid);
}
list<account> accli=[select id,name,Account_Status__c,Active_Prospect__c ,(select id,accountID,StageName,Contract_Expiration_Date__c from Opportunities) from account where id=:ids];
for(account a1:accli){
for(Opportunity op:a1.opportunities){
if(op.stageName=='Intro Meeting / Discovery'||op.stageName=='Relationship Building'||
op.stageName=='Opportunity Identification'||op.stageName=='Solution/Submit RFI'||
op.stageName=='Solution/Submit RFP'||op.stageName=='Solution/Submit Pre-emptive Bid'||
op.stageName=='Presentation / Pitching'||op.stageName=='Red Zone / Awarded'){
opp.add(op);
}
if(op.stageName=='Win (Contract Signed)'&& op.Contract_Expiration_Date__c > System.TODAY()){
opp1.add(op);
}
}
if(opp.size()>0){
a1.Active_Prospect__c=true;
}else{
a1.Active_Prospect__c=false;
}
if(opp1.Size()>0){
a1.Account_Status__c='Active';
}else{
a1.Account_Status__c='Inactive';
}
ali.add(a1);
}
}
update ali;
}
Above is the Trigger. Any one can Help
Thanks In advance
trigger UpdateActiveProspect on Opportunity (after insert,after update){
list<account> ali=new list<account>();
if(trigger.isafter && (trigger.isinsert || trigger.isupdate)){
list<Opportunity> Opp=new list<Opportunity>();
List<Opportunity> opp1=new List<Opportunity>();
set<id> ids=new set<id>();
for(Opportunity o:trigger.new){
ids.add(o.accountid);
}
list<account> accli=[select id,name,Account_Status__c,Active_Prospect__c ,(select id,accountID,StageName,Contract_Expiration_Date__c from Opportunities) from account where id=:ids];
for(account a1:accli){
for(Opportunity op:a1.opportunities){
if(op.stageName=='Intro Meeting / Discovery'||op.stageName=='Relationship Building'||
op.stageName=='Opportunity Identification'||op.stageName=='Solution/Submit RFI'||
op.stageName=='Solution/Submit RFP'||op.stageName=='Solution/Submit Pre-emptive Bid'||
op.stageName=='Presentation / Pitching'||op.stageName=='Red Zone / Awarded'){
opp.add(op);
}
if(op.stageName=='Win (Contract Signed)'&& op.Contract_Expiration_Date__c > System.TODAY()){
opp1.add(op);
}
}
if(opp.size()>0){
a1.Active_Prospect__c=true;
}else{
a1.Active_Prospect__c=false;
}
if(opp1.Size()>0){
a1.Account_Status__c='Active';
}else{
a1.Account_Status__c='Inactive';
}
ali.add(a1);
}
}
update ali;
}
Above is the Trigger. Any one can Help
Thanks In advance
- Vasu.P
- March 15, 2017
- Like
- 0
- Continue reading or reply
Workflow Formula Field Update
Hi Guys,
i have a Formula field that is getting Avg values Like 1.3,1.4.up to 3.9 so i need to round the Values As if the Value is 0.4 then Round to '0' and also if the value is 0.5 to 0.9 then i need to round the Value to 1 how can i achive this using workfloe field update
Thanks,
i have a Formula field that is getting Avg values Like 1.3,1.4.up to 3.9 so i need to round the Values As if the Value is 0.4 then Round to '0' and also if the value is 0.5 to 0.9 then i need to round the Value to 1 how can i achive this using workfloe field update
Thanks,
- Vasu.P
- October 18, 2016
- Like
- 0
- Continue reading or reply
How to Auto Refresh a Standard Visual force page when an Workflow field update will happen
Hi All,
i have a standard opportunity page. also i have a field update on this. so i have to auto refresh my opportunity page when a field update happen. now i need to manully refresh the page. how can i achieve this. i have written a inline visual force page with a 'Reload' button embadded with the satndard page. but i need to manually click this button. i need the auto refresh the page.
Thanks,
i have a standard opportunity page. also i have a field update on this. so i have to auto refresh my opportunity page when a field update happen. now i need to manully refresh the page. how can i achieve this. i have written a inline visual force page with a 'Reload' button embadded with the satndard page. but i need to manually click this button. i need the auto refresh the page.
Thanks,
- Vasu.P
- May 15, 2017
- Like
- 1
- Continue reading or reply
How to Write a Test Class that covers the Single email Message in Trigger
Hi All,
trigger SendNotification on Savings_Risk_Checklist__c (After insert,after update) {
for(Savings_Risk_Checklist__c SCS :trigger.new) {
if (Trigger.isAfter && (Trigger.IsInsert || Trigger.IsUpdate)) {
string str = '';
str='<html>';
str=str+'<body>';
str=str+'<p> Hello,<br/> </p>';
str=str+'<p> This notification is to inform you that a Sales Leader has just submitted a Savings Risk Checklist form. Please follow the link below to review the form. <br/> </p>';
str=str+'<p> '+
SCS.Savings_Risk_Checklist_Link__c+' <br/> </p>';
str=str+'<p> If you have any issues accessing the link or form, please contact Melissa Umeda (melissa.umeda@cbre.com). <br/> </p>';
str=str+'<p>Thanks,<br/> </p>';
str=str+'<p>GWS Salesforce Operations Team<br/> </p>';
str=str+'</body>';
str=str+'</html>';
if(SCS.Savings_Checklist_Form_Status__c =='Proposal Submitted'|| SCS.Savings_Checklist_Form_Status__c=='Final From Submitted') {
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
//EmailTemplate et=[Select id from EmailTemplate where Name=:'Savings Risk Check List Proposal Submittion'];
//mail.setWhatId(SCS.ID);
mail.setTargetObjectId(userinfo.getUserId());
//mail.setTemplateId(et.id);
mail.setTargetObjectId(SCS.CreatedById);
mail.setTreatTargetObjectAsRecipient(false);
mail.setToAddresses(new List<String>{'Test@gmail.com'});
mail.setSaveAsActivity(false);
mail.setHtmlBody(str);
Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
}
}
}
}
Can Any one Suggests how can write a Test class for Above Trigger,
Thanks,
trigger SendNotification on Savings_Risk_Checklist__c (After insert,after update) {
for(Savings_Risk_Checklist__c SCS :trigger.new) {
if (Trigger.isAfter && (Trigger.IsInsert || Trigger.IsUpdate)) {
string str = '';
str='<html>';
str=str+'<body>';
str=str+'<p> Hello,<br/> </p>';
str=str+'<p> This notification is to inform you that a Sales Leader has just submitted a Savings Risk Checklist form. Please follow the link below to review the form. <br/> </p>';
str=str+'<p> '+
SCS.Savings_Risk_Checklist_Link__c+' <br/> </p>';
str=str+'<p> If you have any issues accessing the link or form, please contact Melissa Umeda (melissa.umeda@cbre.com). <br/> </p>';
str=str+'<p>Thanks,<br/> </p>';
str=str+'<p>GWS Salesforce Operations Team<br/> </p>';
str=str+'</body>';
str=str+'</html>';
if(SCS.Savings_Checklist_Form_Status__c =='Proposal Submitted'|| SCS.Savings_Checklist_Form_Status__c=='Final From Submitted') {
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
//EmailTemplate et=[Select id from EmailTemplate where Name=:'Savings Risk Check List Proposal Submittion'];
//mail.setWhatId(SCS.ID);
mail.setTargetObjectId(userinfo.getUserId());
//mail.setTemplateId(et.id);
mail.setTargetObjectId(SCS.CreatedById);
mail.setTreatTargetObjectAsRecipient(false);
mail.setToAddresses(new List<String>{'Test@gmail.com'});
mail.setSaveAsActivity(false);
mail.setHtmlBody(str);
Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
}
}
}
}
Can Any one Suggests how can write a Test class for Above Trigger,
Thanks,
- Vasu.P
- July 03, 2017
- Like
- 0
- Continue reading or reply
Target object ID error while sending email through Trigger for a Custom Object
Hi All,
trigger SendNotification on Savings_Risk_Checklist__c (After insert,after update) {
Savings_Risk_Checklist__c SCS = trigger.new[0];
if (Trigger.IsInsert || Trigger.IsUpdate) {
if(SCS.Savings_Checklist_Form_Status__c =='Proposal Submitted'|| SCS.Savings_Checklist_Form_Status__c=='Final From Submitted') {
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
EmailTemplate et=[Select id from EmailTemplate where Name=:'Savings Risk Check List Proposal Submittion'];
//mail.setWhatId(SCS.ID);
mail.setTargetObjectId(SCS.id);
mail.setTemplateId(et.id);
mail.setToAddresses(new List<String>{'putluruvishnu@gmail.com'});
mail.setSaveAsActivity(false);
Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
}
i have Written above code on Custom Object to send an email. but i am Getting Below Error
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger SendNotification caused an unexpected exception, contact your administrator: SendNotification: execution of AfterUpdate caused by: System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_TYPE_FOR_OPERATION, Only User, Contact, Lead, or Person objects are allowed for targetObjectId: 01I37000000kq3E.: [targetObjectId, 01I37000000kq3EEAQ]: Trigger.SendNotification: line 13, column 1
trigger SendNotification on Savings_Risk_Checklist__c (After insert,after update) {
Savings_Risk_Checklist__c SCS = trigger.new[0];
if (Trigger.IsInsert || Trigger.IsUpdate) {
if(SCS.Savings_Checklist_Form_Status__c =='Proposal Submitted'|| SCS.Savings_Checklist_Form_Status__c=='Final From Submitted') {
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
EmailTemplate et=[Select id from EmailTemplate where Name=:'Savings Risk Check List Proposal Submittion'];
//mail.setWhatId(SCS.ID);
mail.setTargetObjectId(SCS.id);
mail.setTemplateId(et.id);
mail.setToAddresses(new List<String>{'putluruvishnu@gmail.com'});
mail.setSaveAsActivity(false);
Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
}
i have Written above code on Custom Object to send an email. but i am Getting Below Error
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger SendNotification caused an unexpected exception, contact your administrator: SendNotification: execution of AfterUpdate caused by: System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_TYPE_FOR_OPERATION, Only User, Contact, Lead, or Person objects are allowed for targetObjectId: 01I37000000kq3E.: [targetObjectId, 01I37000000kq3EEAQ]: Trigger.SendNotification: line 13, column 1
- Vasu.P
- June 30, 2017
- Like
- 0
- Continue reading or reply
How to Auto Refresh a Standard Visual force page when an Workflow field update will happen
Hi All,
i have a standard opportunity page. also i have a field update on this. so i have to auto refresh my opportunity page when a field update happen. now i need to manully refresh the page. how can i achieve this. i have written a inline visual force page with a 'Reload' button embadded with the satndard page. but i need to manually click this button. i need the auto refresh the page.
Thanks,
i have a standard opportunity page. also i have a field update on this. so i have to auto refresh my opportunity page when a field update happen. now i need to manully refresh the page. how can i achieve this. i have written a inline visual force page with a 'Reload' button embadded with the satndard page. but i need to manually click this button. i need the auto refresh the page.
Thanks,
- Vasu.P
- May 15, 2017
- Like
- 1
- Continue reading or reply
Trigger is not working while Updating through Dataloadeer
Hi All,
trigger UpdateActiveProspect on Opportunity (after insert,after update){
list<account> ali=new list<account>();
if(trigger.isafter && (trigger.isinsert || trigger.isupdate)){
list<Opportunity> Opp=new list<Opportunity>();
List<Opportunity> opp1=new List<Opportunity>();
set<id> ids=new set<id>();
for(Opportunity o:trigger.new){
ids.add(o.accountid);
}
list<account> accli=[select id,name,Account_Status__c,Active_Prospect__c ,(select id,accountID,StageName,Contract_Expiration_Date__c from Opportunities) from account where id=:ids];
for(account a1:accli){
for(Opportunity op:a1.opportunities){
if(op.stageName=='Intro Meeting / Discovery'||op.stageName=='Relationship Building'||
op.stageName=='Opportunity Identification'||op.stageName=='Solution/Submit RFI'||
op.stageName=='Solution/Submit RFP'||op.stageName=='Solution/Submit Pre-emptive Bid'||
op.stageName=='Presentation / Pitching'||op.stageName=='Red Zone / Awarded'){
opp.add(op);
}
if(op.stageName=='Win (Contract Signed)'&& op.Contract_Expiration_Date__c > System.TODAY()){
opp1.add(op);
}
}
if(opp.size()>0){
a1.Active_Prospect__c=true;
}else{
a1.Active_Prospect__c=false;
}
if(opp1.Size()>0){
a1.Account_Status__c='Active';
}else{
a1.Account_Status__c='Inactive';
}
ali.add(a1);
}
}
update ali;
}
Above is the Trigger. Any one can Help
Thanks In advance
trigger UpdateActiveProspect on Opportunity (after insert,after update){
list<account> ali=new list<account>();
if(trigger.isafter && (trigger.isinsert || trigger.isupdate)){
list<Opportunity> Opp=new list<Opportunity>();
List<Opportunity> opp1=new List<Opportunity>();
set<id> ids=new set<id>();
for(Opportunity o:trigger.new){
ids.add(o.accountid);
}
list<account> accli=[select id,name,Account_Status__c,Active_Prospect__c ,(select id,accountID,StageName,Contract_Expiration_Date__c from Opportunities) from account where id=:ids];
for(account a1:accli){
for(Opportunity op:a1.opportunities){
if(op.stageName=='Intro Meeting / Discovery'||op.stageName=='Relationship Building'||
op.stageName=='Opportunity Identification'||op.stageName=='Solution/Submit RFI'||
op.stageName=='Solution/Submit RFP'||op.stageName=='Solution/Submit Pre-emptive Bid'||
op.stageName=='Presentation / Pitching'||op.stageName=='Red Zone / Awarded'){
opp.add(op);
}
if(op.stageName=='Win (Contract Signed)'&& op.Contract_Expiration_Date__c > System.TODAY()){
opp1.add(op);
}
}
if(opp.size()>0){
a1.Active_Prospect__c=true;
}else{
a1.Active_Prospect__c=false;
}
if(opp1.Size()>0){
a1.Account_Status__c='Active';
}else{
a1.Account_Status__c='Inactive';
}
ali.add(a1);
}
}
update ali;
}
Above is the Trigger. Any one can Help
Thanks In advance
- Vasu.P
- March 15, 2017
- Like
- 0
- Continue reading or reply
Workflow Formula Field Update
Hi Guys,
i have a Formula field that is getting Avg values Like 1.3,1.4.up to 3.9 so i need to round the Values As if the Value is 0.4 then Round to '0' and also if the value is 0.5 to 0.9 then i need to round the Value to 1 how can i achive this using workfloe field update
Thanks,
i have a Formula field that is getting Avg values Like 1.3,1.4.up to 3.9 so i need to round the Values As if the Value is 0.4 then Round to '0' and also if the value is 0.5 to 0.9 then i need to round the Value to 1 how can i achive this using workfloe field update
Thanks,
- Vasu.P
- October 18, 2016
- Like
- 0
- Continue reading or reply