function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sumesh ChandranSumesh Chandran 

update Opportunity record through apex controller class!

Hello All,
This is what I have got so far to update the Stage of an opportunity, unfortunately it doesn't work at all.
Helper.js
updateOppStage : function(component, selectedButtonLabel, selectedRecordId) {
        var updateOppCall = component.get("c.updateOppStage");
        console.log(selectedButtonLabel, selectedRecordId);
        updateOppCall.setParams(
            {
                oppId : selectedRecordId,
                oppStage : selectedButtonLabel
            }
        );
        updateOppCall.setCallback(this, function(response) {
            var state = response.getState();
            
            if (state === "SUCCESS") {
             	var result = response.getReturnValue();
                console.log(result);
            }            
        });
        $A.enqueueAction(updateOppCall);     
    }
Apex Class Controller
@AuraEnabled
    public static Opportunity updateOppStage(String oppId, String oppStage) {
        Opportunity opp = [Select Name, CloseDate, StageName, sumchans__OppOwner__c From Opportunity where Id:=oppId];
        opp.StageName = oppStage;
        update opp;
		return opp;
    }
Please advise !

Thanks all!

 
Best Answer chosen by Sumesh Chandran
Sumesh ChandranSumesh Chandran
Hey all I got it worked out, it was this part that I got it wrong:
[Select Name, CloseDate, StageName, sumchans__OppOwner__c From Opportunity where Id=:oppId];
The colon should have been on the other side.