Component
<aura:component controller="UnescalateController" implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,flexipage:availableForRecordHome,force:hasRecordId" access="global" >
<aura:at>tribute name="CaseObj" type="Case" default="{ 'sobjectType' : 'case'}"/>
<lightning:button label="Unescalate" onclick="{! c.unescalate}"/>
</aura:component
JS Controller
({
unescalate : function(component, event, helper) {
var caseObject = component.get("v.CaseObj");
caseObject.Admin_Escalation__c = FALSE;
var action = component.get("c.updateAdmin_Escalation__c");
action.setParams({
obj: caseObject,
oId : component.get("v.recordId")
});
// set call back
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
alert('This case has been unescalated!');
$A.get('e.force:refreshView').fire();
}
else if (state === "INCOMPLETE") {
alert("From server: " + response.getReturnValue());
} else if (state === "ERROR") {
var errors = response.getError();
if (errors) {
if (errors[0] && errors[0].message) {
console.log("Error message: " + errors[0].message);
}
} else {
console.log("Unknown error");
}
}
});
// enqueue the action
$A.enqueueAction(action);
}
})
Apex Controller
public class UnescalateController {
@AuraEnabled
public static void updateStatus(case obj,String oId){
system.debug('obj' + obj);
case cc = obj;
cc.Id = oId;
update cc;
}
}
I managed to solve it...was way off. <aura:component controller="UnescalateCaseController" implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,flexipage:availableForRecordHome,force:hasRecordId" access="global">
<aura:handler name="init" value="{!this}" action="{!c.init}"/>
<aura:attribute name="case" type="Case"/>
<ui:button aura:id="unescalatebtn" class="slds-button slds-button--brand" label="Unescalate" press="{!c.onclick}" disabled="{!v.case.Admin_Escalation__c == false ? 'true' : 'false'}"/>
</aura:component>
What i'm encountering now, is that this function can only be used once.public class UnescalateCaseController {
@AuraEnabled
public static Case getCase(Id recordId){
Case caseRec = [SELECT Id, Admin_Escalation__c FROM Case WHERE id=:recordId];
return caseRec;
}
@AuraEnabled
public static Case saveCase(Case caseRec){
caseRec.Admin_Escalation__c = FALSE;
update caseRec;
return caseRec;
}
}