-
ChatterFeed
-
0Best Answers
-
1Likes Received
-
0Likes Given
-
27Questions
-
67Replies
Need help to creating a Process Builder
Hi Team,
Can any one please help me to create a ProcessBuilder for below request.
1.If Is this approved Field(Picklist) = "Blank means None" , Request (Textfield) = "Empty(No value)" then Approval Status(Picklist) should be NotSubmitted.
2.If Is this approved Field, Request field = "RC-01234" then Approval Status should be Submitted for Approval.
3.If Is this approved Field = "Yes" , Request field = "RC-01235" then Approval Status should be Approved.
4.If Is this approved Field = "Yes" , Request field = "Empty" then Approval Status should be Not Submitted.
5.If Is this approved Field = "No" , Request field = "RC-01236" then Approval Status should be Rejected.
6.If Is this approved Field = "No" , Request field = "Empty" then Approval Status should be Not Submitted.
Let say If i select "IsthisApproved" = Yes, Request = some data (RC-01234) then Approval Status should be Approved. so hear we are updating the Approval Status field based on the IsthisApproved and Request fields.similorly other points as well. Please help us on this
Thanks in advance
Can any one please help me to create a ProcessBuilder for below request.
1.If Is this approved Field(Picklist) = "Blank means None" , Request (Textfield) = "Empty(No value)" then Approval Status(Picklist) should be NotSubmitted.
2.If Is this approved Field, Request field = "RC-01234" then Approval Status should be Submitted for Approval.
3.If Is this approved Field = "Yes" , Request field = "RC-01235" then Approval Status should be Approved.
4.If Is this approved Field = "Yes" , Request field = "Empty" then Approval Status should be Not Submitted.
5.If Is this approved Field = "No" , Request field = "RC-01236" then Approval Status should be Rejected.
6.If Is this approved Field = "No" , Request field = "Empty" then Approval Status should be Not Submitted.
Let say If i select "IsthisApproved" = Yes, Request = some data (RC-01234) then Approval Status should be Approved. so hear we are updating the Approval Status field based on the IsthisApproved and Request fields.similorly other points as well. Please help us on this
Thanks in advance
- Srini
- October 24, 2016
- Like
- 0
- Continue reading or reply
Help_Validation rule
Hi Team,
Can any one please help me to create a Validationrule for below senario.
Thanks in Advance
Can any one please help me to create a Validationrule for below senario.
Is this approved | Request # | Approval Status |
<Blank> | <Blank> | Not Submitted |
<Blank> | <Completed> | Submitted for Approval |
Yes | <Completed> | Approved |
Yes | <Blank> | Not Submitted |
No | <Completed> | Rejected |
No | <Blank> | Not Submitted |
Thanks in Advance
- Srini
- October 21, 2016
- Like
- 0
- Continue reading or reply
Help to create BatchJob
Hi Team,
We have a requirement to create batchapex. Mentioned the senario below.We have two fields(Checkboxes) are avalable in Opprtunity.
1.Last 30 days (Formula)
2.Last 30 Days (Workflow)
3.Last 730 days (Formula)
4.Last 730 Days (Workflow)
Hear If Formula field(Last 30 days)is true then workflow field(Last 30 Days) automatically should be true ,Similorly same to Last 730 days(Formula)is true it should be true for Last 730 Days (Workflow). Can any one please help us to create batch apex for the above requirement.
Thanks in Advance
We have a requirement to create batchapex. Mentioned the senario below.We have two fields(Checkboxes) are avalable in Opprtunity.
1.Last 30 days (Formula)
2.Last 30 Days (Workflow)
3.Last 730 days (Formula)
4.Last 730 Days (Workflow)
Hear If Formula field(Last 30 days)is true then workflow field(Last 30 Days) automatically should be true ,Similorly same to Last 730 days(Formula)is true it should be true for Last 730 Days (Workflow). Can any one please help us to create batch apex for the above requirement.
Thanks in Advance
- Srini
- September 22, 2016
- Like
- 0
- Continue reading or reply
BatchApex
Hi Team,
We have updated the Total_Sw_Channel_Manager__c and Total_Sw_Account_Manager__c field on opportunity using trigger which is working fine mentiiend below.But problem is this is effecting some other functionality.So we want to create batch apex based on below trigger logic.Can any one please help me to creating batch logic.
trigger OpportunitySplitTrigger on OpportunitySplit (after insert,after update, before delete,after unDelete)
{
set<id> oppIds = new set<id>();
if(trigger.isafter)
{
for(OpportunitySplit opsp : trigger.new)
{
if((trigger.isupdate && opsp.Role_Name__c != trigger.oldmap.get(opsp.id).Role_Name__c ) || trigger.isinsert)
oppIds.add(opsp.opportunityId);
}
}
if(trigger.isbefore && trigger.isdelete)
{
for(OpportunitySplit opsp : trigger.old)
{
if(RecourssionClass.iscalledsplitdeletefunctionality == false){
RecourssionClass.iscalledsplitdeletefunctionality = true;
//oppIds.add(opsp.opportunityId);
}
}
}
if(oppIds.size()>0)
{
list<opportunity> lstOppToUpdate = new list<opportunity>();
for(Opportunity opp : [select id,Total_Sw_Channel_Manager__c,Total_Sw_Account_Manager__c,(select id,Role_Name__c from OpportunitySplits where Role_Name__c ='SW Account Manager' OR Role_Name__c ='SW Channel Manager') from opportunity where id in:oppIds])
{
integer sumAcMngr =0;
integer sumChMgnr =0;
if(opp.OpportunitySplits.size()>0)
{
for(OpportunitySplit oSplit : opp.OpportunitySplits)
{
if(oSplit.Role_Name__c =='SW Account Manager' )
sumAcMngr+=1;
else if(oSplit.Role_Name__c =='SW Channel Manager')
sumChMgnr +=1;
}
}
opp.Total_Sw_Channel_Manager__c = sumChMgnr;
opp.Total_Sw_Account_Manager__c= sumAcMngr;
lstOppToUpdate.add(opp);
}
if(lstOppToUpdate.size()>0)
update lstOppToUpdate;
}
}
Thanks in Advance
We have updated the Total_Sw_Channel_Manager__c and Total_Sw_Account_Manager__c field on opportunity using trigger which is working fine mentiiend below.But problem is this is effecting some other functionality.So we want to create batch apex based on below trigger logic.Can any one please help me to creating batch logic.
trigger OpportunitySplitTrigger on OpportunitySplit (after insert,after update, before delete,after unDelete)
{
set<id> oppIds = new set<id>();
if(trigger.isafter)
{
for(OpportunitySplit opsp : trigger.new)
{
if((trigger.isupdate && opsp.Role_Name__c != trigger.oldmap.get(opsp.id).Role_Name__c ) || trigger.isinsert)
oppIds.add(opsp.opportunityId);
}
}
if(trigger.isbefore && trigger.isdelete)
{
for(OpportunitySplit opsp : trigger.old)
{
if(RecourssionClass.iscalledsplitdeletefunctionality == false){
RecourssionClass.iscalledsplitdeletefunctionality = true;
//oppIds.add(opsp.opportunityId);
}
}
}
if(oppIds.size()>0)
{
list<opportunity> lstOppToUpdate = new list<opportunity>();
for(Opportunity opp : [select id,Total_Sw_Channel_Manager__c,Total_Sw_Account_Manager__c,(select id,Role_Name__c from OpportunitySplits where Role_Name__c ='SW Account Manager' OR Role_Name__c ='SW Channel Manager') from opportunity where id in:oppIds])
{
integer sumAcMngr =0;
integer sumChMgnr =0;
if(opp.OpportunitySplits.size()>0)
{
for(OpportunitySplit oSplit : opp.OpportunitySplits)
{
if(oSplit.Role_Name__c =='SW Account Manager' )
sumAcMngr+=1;
else if(oSplit.Role_Name__c =='SW Channel Manager')
sumChMgnr +=1;
}
}
opp.Total_Sw_Channel_Manager__c = sumChMgnr;
opp.Total_Sw_Account_Manager__c= sumAcMngr;
lstOppToUpdate.add(opp);
}
if(lstOppToUpdate.size()>0)
update lstOppToUpdate;
}
}
Thanks in Advance
- Srini
- September 14, 2016
- Like
- 0
- Continue reading or reply
Scenarios help using trigger
Hi Team,
We have task,Whenever we entering in opportunity fields it should create a brand new task along with opportunity name.after creating automatic task it should assign some other user not for opportunity owner, along with email notification like "task has been assigned to you".Once he will complete the task again completion mail should sent to Opportunity Owner and their manager like "Your task has been completd".
Is this possible to one Trigger for all senarios?
How we will achieve this senarios.
Please help us for this.
Thanks in Advance
We have task,Whenever we entering in opportunity fields it should create a brand new task along with opportunity name.after creating automatic task it should assign some other user not for opportunity owner, along with email notification like "task has been assigned to you".Once he will complete the task again completion mail should sent to Opportunity Owner and their manager like "Your task has been completd".
Is this possible to one Trigger for all senarios?
How we will achieve this senarios.
Please help us for this.
Thanks in Advance
- Srini
- August 24, 2016
- Like
- 1
- Continue reading or reply
Need help for validation rule:
Hi Team,
Is there any possible to create a validation rule for stoping task creation when Opportunity stage = completed ?. If yes please help us.
Thanks in Advance
Is there any possible to create a validation rule for stoping task creation when Opportunity stage = completed ?. If yes please help us.
Thanks in Advance
- Srini
- August 05, 2016
- Like
- 0
- Continue reading or reply
Validation Rules:
Hi Team,
How to create a validation rule for below requirement:
Block opportunity with stage from C5-Closed Won onward, which means once Opportunitys stage is up to C5-Closed Won, its owner can't change back stage to C4/C3/C2/C1.
Can any one please help us.
Thanks in Advance
How to create a validation rule for below requirement:
Block opportunity with stage from C5-Closed Won onward, which means once Opportunitys stage is up to C5-Closed Won, its owner can't change back stage to C4/C3/C2/C1.
Can any one please help us.
Thanks in Advance
- Srini
- August 02, 2016
- Like
- 0
- Continue reading or reply
Workflow help
Hi Team,
We have one piclist field called as "Approved" along with the values are Yes,No.
1.If we select "NO", need to restrict the Order submissoins-opportunity is essential blocked.
2.If "Yes" is selected, Request# field becomes mandatory.
3.If Yes is selected and Request # is populated, Status = Approved.
4.If No is selected, Status = Rejected.
Can any one please help us how to create a workflow.
Thanks in Advance
We have one piclist field called as "Approved" along with the values are Yes,No.
1.If we select "NO", need to restrict the Order submissoins-opportunity is essential blocked.
2.If "Yes" is selected, Request# field becomes mandatory.
3.If Yes is selected and Request # is populated, Status = Approved.
4.If No is selected, Status = Rejected.
Can any one please help us how to create a workflow.
Thanks in Advance
- Srini
- August 01, 2016
- Like
- 0
- Continue reading or reply
Need SOQL Help
Hi Team,
We are facing the error like Unknown parsing query, while we are trying the query mentioned below,can any one please help us where we made the mistakes.
Select id,name,Opportunity.RecordType.name,(SELECT CreatedById,Id,LastModifiedDate,OwnerId, WhatId FROM Task),(SELECT OpportunityId FROM OpportunityTeamMember where UserId =' '),
(SELECT Id,IsActive,UseRole.Name FROM User Where IsActive=true and UserRoleId ='' And UseRole.Name like 'Assign-A%')) From Opportunity
Thanks
We are facing the error like Unknown parsing query, while we are trying the query mentioned below,can any one please help us where we made the mistakes.
Select id,name,Opportunity.RecordType.name,(SELECT CreatedById,Id,LastModifiedDate,OwnerId, WhatId FROM Task),(SELECT OpportunityId FROM OpportunityTeamMember where UserId =' '),
(SELECT Id,IsActive,UseRole.Name FROM User Where IsActive=true and UserRoleId ='' And UseRole.Name like 'Assign-A%')) From Opportunity
Thanks
- Srini
- July 20, 2016
- Like
- 0
- Continue reading or reply
Need to write a test class
Hi Everyone,
Can any one please help us writting a test class for below batch apex class.That would be great help.
Global class BatchApex_UpdateOpp implements Database.Batchable<Sobject>{
String TeamRole = 'Assign';
Public String query = 'SELECT id,name,Opportunity.RecordType.name,(SELECT ID,Subject,LastModifiedDate FROM ActivityHistories order by LastModifiedDate DESC LIMIT 1 ),(SELECT id,LastModifiedDate,TeamMemberRole FROM OpportunityTeamMembers) From Opportunity ;
global Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator(query);
}
//Execute Method
global void execute(Database.BatchableContext BC,List<Opportunity> scope){
List<OpenActivity> alist=New List<OpenActivity>();
List<OpportunityTeamMember> plist=New List<OpportunityTeamMember>();
for(Opportunity ot : scope){
for(ActivityHistory OPA : ot.getSObjects('ActivityHistories')){
DateTime dT = OPA.LastModifiedDate;
//DateTime dT = ot.ActivityDate.LastModifiedDate;
Date myDate = date.newinstance(dT.year(),dT.month(),dT.day());
Integer numberDaysDue = (myDate.daysBetween(system.today()));
if(OPA.Subject !=null){
if(numberDaysDue > Integer.valueOf(System.Label.GE_OppTeamDays)){
for(OpportunityTeamMember optm: ot.getSObjects('OpportunityTeamMembers')){
if(optm.TeamMemberRole=='Assign'){
plist.add(optm);
}
}
}
}else{
for(OpportunityTeamMember optm: ot.getSObjects('OpportunityTeamMembers')){
if(optm.TeamMemberRole=='Assign'){
plist.add(optm);
}
}
}
}
}
if(Plist.size()>0){
delete plist;
}
}
//Finish Method
global void finish(Database.BatchableContext BC){
}
}
Thanks in Advance
Can any one please help us writting a test class for below batch apex class.That would be great help.
Global class BatchApex_UpdateOpp implements Database.Batchable<Sobject>{
String TeamRole = 'Assign';
Public String query = 'SELECT id,name,Opportunity.RecordType.name,(SELECT ID,Subject,LastModifiedDate FROM ActivityHistories order by LastModifiedDate DESC LIMIT 1 ),(SELECT id,LastModifiedDate,TeamMemberRole FROM OpportunityTeamMembers) From Opportunity ;
global Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator(query);
}
//Execute Method
global void execute(Database.BatchableContext BC,List<Opportunity> scope){
List<OpenActivity> alist=New List<OpenActivity>();
List<OpportunityTeamMember> plist=New List<OpportunityTeamMember>();
for(Opportunity ot : scope){
for(ActivityHistory OPA : ot.getSObjects('ActivityHistories')){
DateTime dT = OPA.LastModifiedDate;
//DateTime dT = ot.ActivityDate.LastModifiedDate;
Date myDate = date.newinstance(dT.year(),dT.month(),dT.day());
Integer numberDaysDue = (myDate.daysBetween(system.today()));
if(OPA.Subject !=null){
if(numberDaysDue > Integer.valueOf(System.Label.GE_OppTeamDays)){
for(OpportunityTeamMember optm: ot.getSObjects('OpportunityTeamMembers')){
if(optm.TeamMemberRole=='Assign'){
plist.add(optm);
}
}
}
}else{
for(OpportunityTeamMember optm: ot.getSObjects('OpportunityTeamMembers')){
if(optm.TeamMemberRole=='Assign'){
plist.add(optm);
}
}
}
}
}
if(Plist.size()>0){
delete plist;
}
}
//Finish Method
global void finish(Database.BatchableContext BC){
}
}
Thanks in Advance
- Srini
- July 18, 2016
- Like
- 0
- Continue reading or reply
Compile Error: expecting right curly bracket, found 'else' at line
Hi Everyone,
When we are executing my code we are getting compile error.code is mentioned below.Please check and let us know where we have made the mistakes in the Code.
When we are executing my code we are getting compile error.code is mentioned below.Please check and let us know where we have made the mistakes in the Code.
for(Opportunity ot : scope){
String Subject= (String)ot.get(Schema.OpenActivities.Description);
if(Subject!=Null){
for(OpenActivities OPA : ot.getSObjects('OpenActivities')){
alist.add(OPA.id);
}
else{
for(OpportunityTeamMembers optm: ot.getSObjects('OpportunityTeamMembers')){
Plist.add(optm.id);
}
}
}
}
Thanks in Advance
String Subject= (String)ot.get(Schema.OpenActivities.Description);
if(Subject!=Null){
for(OpenActivities OPA : ot.getSObjects('OpenActivities')){
alist.add(OPA.id);
}
else{
for(OpportunityTeamMembers optm: ot.getSObjects('OpportunityTeamMembers')){
Plist.add(optm.id);
}
}
}
}
Thanks in Advance
- Srini
- July 15, 2016
- Like
- 0
- Continue reading or reply
Error:line breaks not allowed in string literals
Hi Team,
When we are using Below SOQL we are facing Erro Like "the line breaks not allowed in string literals"
SOQL:
Public String query = 'SELECT id,name,Opportunity.RecordType.name,
(SELECT Id,Ownerid, ActivityDate FROM OpenActivities Order By LastModifiedDate ASC),(SELECT LastModifiedDate,TeamMemberRole FROM OpportunityTeamMembers WHERE TeamMemberRole = \'Team\'') From Opportunity where id = 'OptyID';
How to remove the litterals from above query.Please Help us
Thanks
When we are using Below SOQL we are facing Erro Like "the line breaks not allowed in string literals"
SOQL:
Public String query = 'SELECT id,name,Opportunity.RecordType.name,
(SELECT Id,Ownerid, ActivityDate FROM OpenActivities Order By LastModifiedDate ASC),(SELECT LastModifiedDate,TeamMemberRole FROM OpportunityTeamMembers WHERE TeamMemberRole = \'Team\'') From Opportunity where id = 'OptyID';
How to remove the litterals from above query.Please Help us
Thanks
- Srini
- July 14, 2016
- Like
- 0
- Continue reading or reply
Opportunity Soql Query
Hi Team,
How to write a SOQL: In opportunity Object we have Related lists like Teammembers and open activities.I want get the fields like Teammembers role = 'AB' along with the open activities details from same opportunity .
Select id,Opportunity.RecordType.name,LastModifiedDate,Opportunity.LastModifiedDate,TeamMemberRole FROM OpportunityTeamMember where TeamMemberRole = 'ABC'
But i want to include openactivites fields also. How to add this query from above one.
Please help us.
Thanks
How to write a SOQL: In opportunity Object we have Related lists like Teammembers and open activities.I want get the fields like Teammembers role = 'AB' along with the open activities details from same opportunity .
Select id,Opportunity.RecordType.name,LastModifiedDate,Opportunity.LastModifiedDate,TeamMemberRole FROM OpportunityTeamMember where TeamMemberRole = 'ABC'
But i want to include openactivites fields also. How to add this query from above one.
Please help us.
Thanks
- Srini
- July 13, 2016
- Like
- 0
- Continue reading or reply
After update the opportunity field task should be create
Hi Team,
We have fields in the opportunity called as MIDescription Whenever we entered in the description field it should create a new brand task in the Open Activities related list. For that we have created one trigger in opportunity as mentioned below. Trigger is working as expected.
But hear one problem after creating the task.We need to assign that particular task to one of the Group member. After completion the task, completion mail should be getting opportunity Manager like.
Hello XXX,
Your Task has been Completed.
Here are the details -
Subject : Test
Status: Completed
Priority : Low
Can any one please help us
Please find the Below Trigger Code:
We have fields in the opportunity called as MIDescription Whenever we entered in the description field it should create a new brand task in the Open Activities related list. For that we have created one trigger in opportunity as mentioned below. Trigger is working as expected.
But hear one problem after creating the task.We need to assign that particular task to one of the Group member. After completion the task, completion mail should be getting opportunity Manager like.
Hello XXX,
Your Task has been Completed.
Here are the details -
Subject : Test
Status: Completed
Priority : Low
Can any one please help us
Please find the Below Trigger Code:
Trigger Task on Opportunity(before insert,before Update){
Set<Id> opIds = new Set<Id>();
List<Task> taskList = new List<Task>();
List<Opportunity> Opps = Trigger.new;
List<Opportunity> taskOps = [Select Id,Description__c from Opportunity where Id in :opIds];
if(Trigger.isInsert){
for (Opportunity Opp: Opps){
Task t = new Task();
t.WhatId = opp.Id;
// t.Subject = 'Task';
t.Subject = opp.Description__c;
taskList.add(t);
}
}
if(Trigger.isUpdate){
Map<Id,Opportunity> oldOppMap = Trigger.oldmap;
for (Opportunity Opp: Opps){
if(Opp.Description__c != oldOppMap.get(opp.Id).Description__c ){
Task t = new Task();
t.WhatId = opp.Id;
// t.Subject = ' Task';
t.Subject = opp.Description__c;
taskList.add(t);
}
}
}
insert taskList;
}
Thanks in Advance
Set<Id> opIds = new Set<Id>();
List<Task> taskList = new List<Task>();
List<Opportunity> Opps = Trigger.new;
List<Opportunity> taskOps = [Select Id,Description__c from Opportunity where Id in :opIds];
if(Trigger.isInsert){
for (Opportunity Opp: Opps){
Task t = new Task();
t.WhatId = opp.Id;
// t.Subject = 'Task';
t.Subject = opp.Description__c;
taskList.add(t);
}
}
if(Trigger.isUpdate){
Map<Id,Opportunity> oldOppMap = Trigger.oldmap;
for (Opportunity Opp: Opps){
if(Opp.Description__c != oldOppMap.get(opp.Id).Description__c ){
Task t = new Task();
t.WhatId = opp.Id;
// t.Subject = ' Task';
t.Subject = opp.Description__c;
taskList.add(t);
}
}
}
insert taskList;
}
Thanks in Advance
- Srini
- July 12, 2016
- Like
- 0
- Continue reading or reply
How to create a task when opportuinty field is updated ?
Hi Team,
We have one Requirement Hear we have some fields in the opportunity those are Status,Help,Description. Here we want to entering some details in the Description field for that time automatically Task should be create with Subject name TestDescription.
Through trigger is it possible? if possible please help us along wih code.
Thanks in Advance
We have one Requirement Hear we have some fields in the opportunity those are Status,Help,Description. Here we want to entering some details in the Description field for that time automatically Task should be create with Subject name TestDescription.
Through trigger is it possible? if possible please help us along wih code.
Thanks in Advance
- Srini
- July 10, 2016
- Like
- 0
- Continue reading or reply
Sending task email notification for profile level
Hi Team,
We have one requirement.Task email completion notification.for that we have written one trigger but i want to send specific role level can any one please help us.
Thanks
We have one requirement.Task email completion notification.for that we have written one trigger but i want to send specific role level can any one please help us.
Thanks
- Srini
- July 08, 2016
- Like
- 0
- Continue reading or reply
How to avoid getting email notification for all the other user
Hi All,
How to avoid getting email notification for all the other user.Can any one help us.
Thanks in Advance
How to avoid getting email notification for all the other user.Can any one help us.
Thanks in Advance
- Srini
- June 20, 2016
- Like
- 0
- Continue reading or reply
How to get the query the data that has been modified in last 24 hours .
Hi All,
How to get the query the data that has been modified in last 24 hours ?
Can any one helpme on this query
Thanks in advance
How to get the query the data that has been modified in last 24 hours ?
Can any one helpme on this query
Thanks in advance
- Srini
- June 16, 2016
- Like
- 0
- Continue reading or reply
How to send an email to public group users after task completed
Hi Team,
When task is completed email should sent to publicgroup users.Can any one please help us.
Thanks in advance.
When task is completed email should sent to publicgroup users.Can any one please help us.
Thanks in advance.
- Srini
- June 14, 2016
- Like
- 0
- Continue reading or reply
Need help for test class code coverage
Hi,
Can any one please help me on Batch apex test class as mentioned below.
Batch Apex:
global class MasterAccountNewLogoDate implements Database.Batchable<AggregateResult>{
/// get all Account Group by Ultimate_Parent_ID__c
/* START Method */
global Iterable<AggregateResult> start(database.batchablecontext BC){
return (AccountsWithParentID );
}
List<AggregateResult> AccountsWithParentID = [Select Ultimate_Parent_ID__c, Min(SW_New_Landing_Date_Formula__c) NewLogo_StatusDate from Account where Ultimate_Parent_ID__c!=Null and SW_New_Landing_Date_Formula__c!=Null group by Ultimate_Parent_ID__c];
/* EXECUTE Method */
global void execute(Database.BatchableContext BC, List<AggregateResult> scope){
Map<id, String> AccountNewLogoStatus = new Map<id, String>();
Map<id, date> AccountNewlogodate = new Map<id, date>();
List<account> AccountToUpdate = new List<Account>();
List<id> AccountId = new List<id>();
String tempStatus='';
////loop through the Ultimate Parent Ids and create map of id and newlogo dates
for (AggregateResult ParentIds : scope){
AccountId.add((ID)ParentIds.get('Ultimate_Parent_ID__c'));
AccountNewlogodate.put((ID)ParentIds.get('Ultimate_Parent_ID__c'),(Date)ParentIds.get('NewLogo_StatusDate'));
}
Account[] AllAccounts = [SELECT id,SW_Status_Formula__c,Ultimate_Parent_ID__c,GED_Master_Account_Status__c,GED_Master_Account_New_Logo_Date__c from Account where Ultimate_Parent_ID__c in :AccountId ];
//create map of the different statuses
for(Account Acc: AllAccounts ){
if(AccountNewLogoStatus.get(Acc.Ultimate_Parent_ID__c)!=Null){
tempStatus = AccountNewLogoStatus.get(Acc.Ultimate_Parent_ID__c);
if(Acc.SW_Status_Formula__c =='Prospect' ){
tempStatus = tempStatus + ',P';
}
if(Acc.SW_Status_Formula__c =='Customer (New Landing)' ){
tempStatus = tempStatus + ',N';
}
if(Acc.SW_Status_Formula__c =='Customer (Active)' ){
tempStatus = tempStatus + ',A';
}
if(Acc.SW_Status_Formula__c =='Customer (Dormant)' ){
tempStatus = tempStatus + ',D';
}
AccountNewLogoStatus.put(Acc.Ultimate_Parent_ID__c,tempStatus);
tempStatus ='';
}
else
{
if(Acc.SW_Status_Formula__c =='Prospect' ){
AccountNewLogoStatus.put(Acc.Ultimate_Parent_ID__c,'P');
}
if(Acc.SW_Status_Formula__c =='Customer (New Landing)'){
AccountNewLogoStatus.put(Acc.Ultimate_Parent_ID__c,'N');
}
if(Acc.SW_Status_Formula__c =='Customer (Active)'){
AccountNewLogoStatus.put(Acc.Ultimate_Parent_ID__c,'A');
}
if(Acc.SW_Status_Formula__c =='Customer (Dormant)'){
AccountNewLogoStatus.put(Acc.Ultimate_Parent_ID__c,'D');
}
}
}
//loop through to update the NL_status
for (Account Acc: AllAccounts ){
Acc.GED_Master_Account_New_Logo_Date__c =AccountNewlogodate.get(Acc.Ultimate_Parent_ID__c);
//Acc.GED_Master_Account_Status__c =AccountNewlogodate.ValueOf(Acc.Ultimate_Parent_ID__c);
if (AccountNewLogoStatus.get(Acc.Ultimate_Parent_ID__c)!=Null){
tempStatus=AccountNewLogoStatus.get(Acc.Ultimate_Parent_ID__c);
if(tempStatus.contains('N') && tempStatus.containsNone('A') && tempStatus.containsNone('D')){
Acc.GED_Master_Account_Status__c ='Customer (New Landing)';
}
if(tempStatus.contains('D') && tempStatus.containsNone('A') && tempStatus.containsNone('N')){
Acc.GED_Master_Account_Status__c ='Customer (Dormant)';
}
if(tempStatus.contains('P') && tempStatus.containsNone('A') && tempStatus.containsNone('D')){
Acc.GED_Master_Account_Status__c ='Prospect';
}
if(tempStatus.contains('A')){
Acc.GED_Master_Account_Status__c ='Customer (Active)';
}
}
AccountToUpdate.add(Acc);
}
if(AccountToUpdate.size()>0){
Update AccountToUpdate;
}
}//execute loop
/* FINISH Method */
global void finish(Database.BatchableContext info){
}//global void finish loop
}//global class loop
Thanks
Can any one please help me on Batch apex test class as mentioned below.
Batch Apex:
global class MasterAccountNewLogoDate implements Database.Batchable<AggregateResult>{
/// get all Account Group by Ultimate_Parent_ID__c
/* START Method */
global Iterable<AggregateResult> start(database.batchablecontext BC){
return (AccountsWithParentID );
}
List<AggregateResult> AccountsWithParentID = [Select Ultimate_Parent_ID__c, Min(SW_New_Landing_Date_Formula__c) NewLogo_StatusDate from Account where Ultimate_Parent_ID__c!=Null and SW_New_Landing_Date_Formula__c!=Null group by Ultimate_Parent_ID__c];
/* EXECUTE Method */
global void execute(Database.BatchableContext BC, List<AggregateResult> scope){
Map<id, String> AccountNewLogoStatus = new Map<id, String>();
Map<id, date> AccountNewlogodate = new Map<id, date>();
List<account> AccountToUpdate = new List<Account>();
List<id> AccountId = new List<id>();
String tempStatus='';
////loop through the Ultimate Parent Ids and create map of id and newlogo dates
for (AggregateResult ParentIds : scope){
AccountId.add((ID)ParentIds.get('Ultimate_Parent_ID__c'));
AccountNewlogodate.put((ID)ParentIds.get('Ultimate_Parent_ID__c'),(Date)ParentIds.get('NewLogo_StatusDate'));
}
Account[] AllAccounts = [SELECT id,SW_Status_Formula__c,Ultimate_Parent_ID__c,GED_Master_Account_Status__c,GED_Master_Account_New_Logo_Date__c from Account where Ultimate_Parent_ID__c in :AccountId ];
//create map of the different statuses
for(Account Acc: AllAccounts ){
if(AccountNewLogoStatus.get(Acc.Ultimate_Parent_ID__c)!=Null){
tempStatus = AccountNewLogoStatus.get(Acc.Ultimate_Parent_ID__c);
if(Acc.SW_Status_Formula__c =='Prospect' ){
tempStatus = tempStatus + ',P';
}
if(Acc.SW_Status_Formula__c =='Customer (New Landing)' ){
tempStatus = tempStatus + ',N';
}
if(Acc.SW_Status_Formula__c =='Customer (Active)' ){
tempStatus = tempStatus + ',A';
}
if(Acc.SW_Status_Formula__c =='Customer (Dormant)' ){
tempStatus = tempStatus + ',D';
}
AccountNewLogoStatus.put(Acc.Ultimate_Parent_ID__c,tempStatus);
tempStatus ='';
}
else
{
if(Acc.SW_Status_Formula__c =='Prospect' ){
AccountNewLogoStatus.put(Acc.Ultimate_Parent_ID__c,'P');
}
if(Acc.SW_Status_Formula__c =='Customer (New Landing)'){
AccountNewLogoStatus.put(Acc.Ultimate_Parent_ID__c,'N');
}
if(Acc.SW_Status_Formula__c =='Customer (Active)'){
AccountNewLogoStatus.put(Acc.Ultimate_Parent_ID__c,'A');
}
if(Acc.SW_Status_Formula__c =='Customer (Dormant)'){
AccountNewLogoStatus.put(Acc.Ultimate_Parent_ID__c,'D');
}
}
}
//loop through to update the NL_status
for (Account Acc: AllAccounts ){
Acc.GED_Master_Account_New_Logo_Date__c =AccountNewlogodate.get(Acc.Ultimate_Parent_ID__c);
//Acc.GED_Master_Account_Status__c =AccountNewlogodate.ValueOf(Acc.Ultimate_Parent_ID__c);
if (AccountNewLogoStatus.get(Acc.Ultimate_Parent_ID__c)!=Null){
tempStatus=AccountNewLogoStatus.get(Acc.Ultimate_Parent_ID__c);
if(tempStatus.contains('N') && tempStatus.containsNone('A') && tempStatus.containsNone('D')){
Acc.GED_Master_Account_Status__c ='Customer (New Landing)';
}
if(tempStatus.contains('D') && tempStatus.containsNone('A') && tempStatus.containsNone('N')){
Acc.GED_Master_Account_Status__c ='Customer (Dormant)';
}
if(tempStatus.contains('P') && tempStatus.containsNone('A') && tempStatus.containsNone('D')){
Acc.GED_Master_Account_Status__c ='Prospect';
}
if(tempStatus.contains('A')){
Acc.GED_Master_Account_Status__c ='Customer (Active)';
}
}
AccountToUpdate.add(Acc);
}
if(AccountToUpdate.size()>0){
Update AccountToUpdate;
}
}//execute loop
/* FINISH Method */
global void finish(Database.BatchableContext info){
}//global void finish loop
}//global class loop
Thanks
- Srini
- June 13, 2016
- Like
- 0
- Continue reading or reply
Scenarios help using trigger
Hi Team,
We have task,Whenever we entering in opportunity fields it should create a brand new task along with opportunity name.after creating automatic task it should assign some other user not for opportunity owner, along with email notification like "task has been assigned to you".Once he will complete the task again completion mail should sent to Opportunity Owner and their manager like "Your task has been completd".
Is this possible to one Trigger for all senarios?
How we will achieve this senarios.
Please help us for this.
Thanks in Advance
We have task,Whenever we entering in opportunity fields it should create a brand new task along with opportunity name.after creating automatic task it should assign some other user not for opportunity owner, along with email notification like "task has been assigned to you".Once he will complete the task again completion mail should sent to Opportunity Owner and their manager like "Your task has been completd".
Is this possible to one Trigger for all senarios?
How we will achieve this senarios.
Please help us for this.
Thanks in Advance
- Srini
- August 24, 2016
- Like
- 1
- Continue reading or reply
Help_Validation rule
Hi Team,
Can any one please help me to create a Validationrule for below senario.
Thanks in Advance
Can any one please help me to create a Validationrule for below senario.
Is this approved | Request # | Approval Status |
<Blank> | <Blank> | Not Submitted |
<Blank> | <Completed> | Submitted for Approval |
Yes | <Completed> | Approved |
Yes | <Blank> | Not Submitted |
No | <Completed> | Rejected |
No | <Blank> | Not Submitted |
Thanks in Advance
- Srini
- October 21, 2016
- Like
- 0
- Continue reading or reply
Help to create BatchJob
Hi Team,
We have a requirement to create batchapex. Mentioned the senario below.We have two fields(Checkboxes) are avalable in Opprtunity.
1.Last 30 days (Formula)
2.Last 30 Days (Workflow)
3.Last 730 days (Formula)
4.Last 730 Days (Workflow)
Hear If Formula field(Last 30 days)is true then workflow field(Last 30 Days) automatically should be true ,Similorly same to Last 730 days(Formula)is true it should be true for Last 730 Days (Workflow). Can any one please help us to create batch apex for the above requirement.
Thanks in Advance
We have a requirement to create batchapex. Mentioned the senario below.We have two fields(Checkboxes) are avalable in Opprtunity.
1.Last 30 days (Formula)
2.Last 30 Days (Workflow)
3.Last 730 days (Formula)
4.Last 730 Days (Workflow)
Hear If Formula field(Last 30 days)is true then workflow field(Last 30 Days) automatically should be true ,Similorly same to Last 730 days(Formula)is true it should be true for Last 730 Days (Workflow). Can any one please help us to create batch apex for the above requirement.
Thanks in Advance
- Srini
- September 22, 2016
- Like
- 0
- Continue reading or reply
BatchApex
Hi Team,
We have updated the Total_Sw_Channel_Manager__c and Total_Sw_Account_Manager__c field on opportunity using trigger which is working fine mentiiend below.But problem is this is effecting some other functionality.So we want to create batch apex based on below trigger logic.Can any one please help me to creating batch logic.
trigger OpportunitySplitTrigger on OpportunitySplit (after insert,after update, before delete,after unDelete)
{
set<id> oppIds = new set<id>();
if(trigger.isafter)
{
for(OpportunitySplit opsp : trigger.new)
{
if((trigger.isupdate && opsp.Role_Name__c != trigger.oldmap.get(opsp.id).Role_Name__c ) || trigger.isinsert)
oppIds.add(opsp.opportunityId);
}
}
if(trigger.isbefore && trigger.isdelete)
{
for(OpportunitySplit opsp : trigger.old)
{
if(RecourssionClass.iscalledsplitdeletefunctionality == false){
RecourssionClass.iscalledsplitdeletefunctionality = true;
//oppIds.add(opsp.opportunityId);
}
}
}
if(oppIds.size()>0)
{
list<opportunity> lstOppToUpdate = new list<opportunity>();
for(Opportunity opp : [select id,Total_Sw_Channel_Manager__c,Total_Sw_Account_Manager__c,(select id,Role_Name__c from OpportunitySplits where Role_Name__c ='SW Account Manager' OR Role_Name__c ='SW Channel Manager') from opportunity where id in:oppIds])
{
integer sumAcMngr =0;
integer sumChMgnr =0;
if(opp.OpportunitySplits.size()>0)
{
for(OpportunitySplit oSplit : opp.OpportunitySplits)
{
if(oSplit.Role_Name__c =='SW Account Manager' )
sumAcMngr+=1;
else if(oSplit.Role_Name__c =='SW Channel Manager')
sumChMgnr +=1;
}
}
opp.Total_Sw_Channel_Manager__c = sumChMgnr;
opp.Total_Sw_Account_Manager__c= sumAcMngr;
lstOppToUpdate.add(opp);
}
if(lstOppToUpdate.size()>0)
update lstOppToUpdate;
}
}
Thanks in Advance
We have updated the Total_Sw_Channel_Manager__c and Total_Sw_Account_Manager__c field on opportunity using trigger which is working fine mentiiend below.But problem is this is effecting some other functionality.So we want to create batch apex based on below trigger logic.Can any one please help me to creating batch logic.
trigger OpportunitySplitTrigger on OpportunitySplit (after insert,after update, before delete,after unDelete)
{
set<id> oppIds = new set<id>();
if(trigger.isafter)
{
for(OpportunitySplit opsp : trigger.new)
{
if((trigger.isupdate && opsp.Role_Name__c != trigger.oldmap.get(opsp.id).Role_Name__c ) || trigger.isinsert)
oppIds.add(opsp.opportunityId);
}
}
if(trigger.isbefore && trigger.isdelete)
{
for(OpportunitySplit opsp : trigger.old)
{
if(RecourssionClass.iscalledsplitdeletefunctionality == false){
RecourssionClass.iscalledsplitdeletefunctionality = true;
//oppIds.add(opsp.opportunityId);
}
}
}
if(oppIds.size()>0)
{
list<opportunity> lstOppToUpdate = new list<opportunity>();
for(Opportunity opp : [select id,Total_Sw_Channel_Manager__c,Total_Sw_Account_Manager__c,(select id,Role_Name__c from OpportunitySplits where Role_Name__c ='SW Account Manager' OR Role_Name__c ='SW Channel Manager') from opportunity where id in:oppIds])
{
integer sumAcMngr =0;
integer sumChMgnr =0;
if(opp.OpportunitySplits.size()>0)
{
for(OpportunitySplit oSplit : opp.OpportunitySplits)
{
if(oSplit.Role_Name__c =='SW Account Manager' )
sumAcMngr+=1;
else if(oSplit.Role_Name__c =='SW Channel Manager')
sumChMgnr +=1;
}
}
opp.Total_Sw_Channel_Manager__c = sumChMgnr;
opp.Total_Sw_Account_Manager__c= sumAcMngr;
lstOppToUpdate.add(opp);
}
if(lstOppToUpdate.size()>0)
update lstOppToUpdate;
}
}
Thanks in Advance
- Srini
- September 14, 2016
- Like
- 0
- Continue reading or reply