You need to sign in to do that
Don't have an account?
Ram 1969
Want parent picklist to update some of the child record picklist
Hi,
I am newbie here and pretty new to SFDC. I would like to achieve following
1. On opportunity stage - when I select "Opp Lost" - I need it to auto change all records in related list (custom object) picklist field to "Opp Lost"
2. But if I select opportunity stage "Opp Won" - I need it to change the records to "Opp Won" that are currently "In Progress" stage. Any records that are selected "Opp Lost" are not changed.
FYI - In Opportunity stage - we have 7 stage including "Opp Lost" & "Opp Won" however in the related list custom object picklist field - we have 3 stages "Opp Won", "In Progress" & "Opp Lost"
How can I achieve this? Coding is not an option since I am a rookie.
Thanks / Ram
I am newbie here and pretty new to SFDC. I would like to achieve following
1. On opportunity stage - when I select "Opp Lost" - I need it to auto change all records in related list (custom object) picklist field to "Opp Lost"
2. But if I select opportunity stage "Opp Won" - I need it to change the records to "Opp Won" that are currently "In Progress" stage. Any records that are selected "Opp Lost" are not changed.
FYI - In Opportunity stage - we have 7 stage including "Opp Lost" & "Opp Won" however in the related list custom object picklist field - we have 3 stages "Opp Won", "In Progress" & "Opp Lost"
How can I achieve this? Coding is not an option since I am a rookie.
Thanks / Ram
Please view this video it will help you- https://www.youtube.com/watch?v=ArxaE-CHnCM
All Answers
On the Opp page - I have "Opp Value" which is a formula field picking value from roll up summary. The roll up summary is aggregating "value" from custom object field
On every custom object record (as mentioned above) - I have 3 stages - "Opp Won", "In Progress" & "Opp Lost" & the user can also enter the "value" for each record.
So now if a user changes the stage in custom object to "Opp Lost" - I would like "Opp Value" exclude the value of this record (so basically the roll up summary is aggregating the records that are either "Opp Won"or "In Progress"
How can this be achieved?
Trigger OppClosewonChangechildRecord on Opportunity(After Update)
{
Set<id> setoppid = new set<id>();
for(Opportunity Objopp : trigger.new)
{
if(Objopp.Stagename == 'Close lost')
{
setoppid.add(Objopp.id);
}
}
list<ChildObjectName> lstchildobject = new list<ChildObjectName>();
if(setoppid.size()>0)
{
for(Childobjectname instant_name : [select id,Childobject_Field from Childobjectname where oppid(OpportunityAPI_on_childObject) in: setoppid])
{
instant_name.Fieldname = 'Closed Lost';
lstchildobject.add(instant_name);
}
if(lstchildobject.size()>0)
update lstchildobject;
}
}
please try. let me know this is working or not.
I am not sure whether you have a step-by-step instructions on the whole scenario? If needed - I can give the actual object names and API
Thanks for all your help, so far!
The parent API is Opportunity and Stage
Trigger OppClosewonChangechildRecord on Opportunity(After Update)
{
Set<id> setoppid = new set<id>();
Set<id> setoppClosewon = new set<id>();
for(Opportunity Objopp : trigger.new)
{
if(Objopp.Stagename == 'Close lost' && trigger.oldmap.get(Objopp.id).StageName != Objopp.Stagename )
{
setoppid.add(Objopp.id);
}
if(Objopp.Stagename == 'Close Won' && trigger.oldmap.get(Objopp.id).StageName != Objopp.Stagename )
{
setoppClosewon.add(Objopp.id);
}
}
list<PET_Product__c> lstchildobject = new list<PET_Product__c>();
if(setoppid.size()>0)
{
for(PET_Product__c Petpro : [select id,Name,Status__c from PET_Product__c where Opportunity in: setoppid])
{
Petpro.Status__c = 'Closed Lost';
lstchildobject.add(Petpro);
}
if(lstchildobject.size()>0)
update lstchildobject;
}
if(setoppid.size()>0)
{
for(PET_Product__c Petpro : [select id,Name,Status__c from PET_Product__c where Opportunity in: setoppid and Status__c != 'Closed Lost'])
{
Petpro.Status__c = 'Closed Won';
lstchildobject.add(Petpro);
}
if(lstchildobject.size()>0)
update lstchildobject;
}
}
Scenario 1: If user changes the Selling stage in Opportunity to Closed Won, then none of the PET Products record should have status as Open. And at least one record should be Won.
Scenario 2: If user changes the Selling stage in Project Detail to Closed Lost, then none of the PET Products record should have status as Open or Won.
We want the user to manually change the status, for Scenario 1, instead of automatic trigger.
However, for Scenario 2 - trigger is okay.
Can you please suggest a solution?
Many Thanks again for your help!
Now if the user change the Opportunity stage to "Closed Won" - I need them to make sure that at least one record in PET_Product has Status as "Won" and none of the records are "Open"
Can you please advise what would the trigger do in this situation? And what would be the trigger?
I tried the trigger you sent earlier above but it is giving some errors....I believe these errors are because I did not provide you the API name in the first place and I dont know where to change the API names in the trigger script.
Please view this video it will help you- https://www.youtube.com/watch?v=ArxaE-CHnCM