+ Start a Discussion
Stéphane C.Stéphane C. 

how to update opportunity stage from a parent object

Hi,

I want to update opportunity stage from a parent object on a Professional Edition org.

Could you think, it is possible?

I have try by using the Process Builder with no success. Perhaps I have miss something.

Any other idea?

Thank you.
raz rraz r
Hi Stephane,

Could you please provide the logic, so that we would look into it and will help you.

Regards,
razr.
David HalesDavid Hales
Hi Stéphane,

You can easily do this with the help of trigger.You have to write a trigger on parent object, After meet the criterion in trigger then the corresponding opportunity stage will be update.
Please share your full requirement so that we can give you the exact solution.

Thanks & Regards
David Hales(1021)
Stéphane C.Stéphane C.
Ok.

On the opportunity, I have this stages (information in progress, Admission in progress, Inscription in progress, closed won and closed lost). On the custom object, I have 3 related date field (information date, admission date and inscription date) and 1 picklist with 2 related value (inscription ok and inscription nok).

Perhaps I have to write two triggers, one dedicated to the stages (information, Admission, Inscription) and one dedicated to the stages (closed won and closed lost) ?

Do I have to go further in the explication?

Thank you.
David HalesDavid Hales
Hi Stephane,


I guess you want to this type of critreion in the trigger.
Here I have write a trigger on Parent Object and update the child record maen Opportunity.
Have a look in below code.
 
trigger TriggeronOppParent on OppParent__c (after insert,after update) {

    List<Opportunity> lstOpp = new List<Opportunity>();
    set<OppParent__c> setOppParent = new set<OppParent__c>();
    
    for( OppParent__c OppParentEach : Trigger.New )
    {
        if(OppParentEach.PiclistValue__c == 'Inscription ok')
        {
            setOppParent.add(OppParentEach);
        }
            
    }
    
    lstOpp = [SELECT Id,StageName,Opp_Parent__c FROM Opportunity WHERE Opp_Parent__c IN : setOppParent];
    
    if( lstOpp != null && lstOpp.size() > 0 )
    {
        for(Opportunity eachlistedOpp : lstOpp)
        {
            eachlistedOpp.StageName = 'Closed Won';
        }
        
        update lstOpp;
    }
    
    
   
    
}

Please provide the more specific information related to your requirement.
Like on which condtion Opportunity stages will change ​.

Happy to help you

Thanks & Regards
David Hales(1021)
Stéphane C.Stéphane C.
Thank you very much.

First Step
On the Opp_Parent__c objet, I have three date fields:
When an user put a date value to the "information date" fiel of the Opp_Parent__c objet then I want the Opportunity stage was set to the "information in progress" value.
When an user put a date value in the "admission date" field in the Opp_Parent__c objet then I want the Opportunity stage was set to the "Admission in progress" value.
When an user put a date value in the "inscription date" field in the Opp_Parent__c objet then I want the Opportunity stage was set to the "Inscription in progress" value.

Second Step
On the Opp_Parent__c objet, I have one picklist:
When an user select the "inscription Ok" from the picklist of the Opp_Parent__c objet then I want the Opportunity stage was set to the "Closed Won" value.
When an user select the "inscription Nok" from the picklist of the Opp_Parent__c objet then I want the Opportunity stage was set to the "Closed Lost" value.

I wish I'm clearer.

Thank you.
David HalesDavid Hales
Hi Stéphane,

Thank you for more clarification.
Could you please provide the more conditional use cases.Because of the Opportunity stage change on the basis of total four fields and five values.In that case 5*5 permutation will be create.So please provide all the use cases.


Example:- 
//Pseudocode
        If( OppParent.InformationDate != null )
        {
            then set OppStage = 'Information In Progress';
        }


        if( OppParent.AadmissionDate != null && OppParent.InformationDate  != null )
        {
            then set OppStage = 'Admission In Progress';
        }

        if( OppParent.InscriptionDate != null && OppParent.AadmissionDate != null && OppParent.InformationDate != null )
        {
            then set OppStage = 'Inscription In Progress';
        }

        if(OppParent.PiclistValue__c == 'Inscription ok')
        {
            then set OppStage = 'Closed Won';
        }
        if(OppParent.PiclistValue__c == 'Inscription not ok')
        {
            then set OppStage = 'Closed Lost';
        }


may be these some Pseudocode use cases will help you.
Waiting for your response.

Thanks & Regards
David Hales(1021)
 
Stéphane C.Stéphane C.
Thank you David.

Here is all the use cases (but you have already done a great job) :   :-)
 
        If( OppParent.InformationDate != null )
        {
            then set OppStage = 'Information In Progress';
        }

        if( OppParent.AdmissionDate != null && OppParent.InformationDate  != null )
        {
            then set OppStage = 'Admission In Progress';
        }

        if( OppParent.InscriptionDate != null && OppParent.AadmissionDate != null && OppParent.InformationDate != null )
        {
            then set OppStage = 'Inscription In Progress';
        }

        if(OppParent.PicklistValue__c == 'Inscription ok')
        {
            then set OppStage = 'Closed Won';
        }

        if(OppParent.PicklistValue__c == 'Inscription not ok')
        {
            then set OppStage = 'Closed Lost';
        }

 
Stéphane C.Stéphane C.
Hello,

I try to go further but I can't see how.

Any idea or any help?

Thank you.
Stéphane C.Stéphane C.
I stop this thread because Professional Edition org don't have Trigger options.

I solve it using a process builder.