• Neetu Goyal
  • NEWBIE
  • 5 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 2
    Replies
Hi! I am working on a lightning component action to update a checkbox if the opportunity is won. The button is working fine, but there is an extra blank pop up with the alert message. I need to show just the alert message, not the blank screen. Can anyone help. Thank you!

({
 doInit : function(component,event,helper){
        $A.get("e.force:closeQuickAction").fire();
      var id = component.get("v.recordId");
      var action = component.get("c.updateOpportunity");
        action.setParams({
               "opportunityId" : id
        });
        
        action.setCallback(this, function(response) {
            if (response.getState() == "SUCCESS") {
                console.log("Save completed successfully.");
               //$A.get("e.force:closeQuickAction").fire();
                alert('Contracted!!Please refresh your screen');
             $A.get("e.force:closeQuickAction");
                  $A.get('e.force:refreshView').fire();
            }else{
                alert('Opportunity is not won!!!');
            }
             var dismissActionPanel = $A.get("e.force:closeQuickAction");
             dismissActionPanel.fire();
        });   
             $A.enqueueAction(action);
      },
     cancel : function(component, event, helper){  
     //$A.get('e.force:refreshView').fire();
      $A.get("e.force:closeQuickAction").fire();
}, 
})

Component-

<aura:component controller="generateContractClass" implements="flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickActionWithoutHeader" access="global">
    <aura:attribute name="recordId" type="String" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>     
   </aura:component>

Blank pop up that I need to remove-
Blank Screen
 
Hi! I've a javascript button that I need to move to lightning. The converter tool is not able to help.
So, there is a custom  button that marks a checkbox selected if the opportunity is won, else shows an error message.  
 
{!REQUIRESCRIPT("/soap/ajax/39.0/connection.js")}
var o = new sforce.SObject("Opportunity");
o.id = "{!Opportunity.Id}";
if ({!Opportunity.IsWon}){
o.SBQQ__Contracted__c = true;
result = sforce.connection.update([o]);
window.location.reload();
} else {
alert("This opportunity has not been marked as won.")
}

I tried converting it into lightning component, but not getting the desired functionality. 
Class-
public class generateContractClass{
@AuraEnabled

public static void updateOpportunity(string recId){
Opportunity obj ;

for(Opportunity temp : [select id,SBQQ__Contracted__c,StageName from Opportunity where id =: recId LIMIT 1]){
obj = temp;
}
Opportunity IR = new Opportunity();
IR.id = obj.Id;
if(IR.StageName == '6. Won'){
IR.SBQQ__Contracted__c = true;
}
update IR;

}
}

Component -
<aura:component controller="generateContractClass" implements="flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" access="global">
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<lightning:spinner variant="brand" size="large"/>
</aura:component>

Controller-
({
doInit : function(component,event,helper){
var action = component.get("c.updateOpportunity");
action.setParams({
"recId": component.get("v.recordId")
});

action.setCallback(this, function(response) {
if (response.getState() == "SUCCESS") {
alert("You did it!!!!!!");
$A.get('e.force:refreshView').fire();
}else{
alert('Opportunity is not won!!!');
}
});
$A.enqueueAction(action);
},

})
Hello,
 I am palnning to give ADM 201 exam next month. Can anyone please help me with recent exam questions or any material which can help me to 
clear the certification.
Thank you!!
Hello,
 I am palnning to give ADM 201 exam next month. Can anyone please help me with recent exam questions or any material which can help me to 
clear the certification.
Thank you!!