SHARE
TWEET

Untitled

a guest Aug 19th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class updateCheckBoxPlan {
  2.  
  3.     @AuraEnabled
  4.     public static void updateChk(String key){
  5.         Opportunity acc = [SELECT Id, Name, Submit_Go_No_Go_Question__c FROM Opportunity WHERE Id=:key];
  6.         if(acc.Submit_Go_No_Go_Question__c == false){
  7.             acc.Submit_Go_No_Go_Question__c = true;
  8.         }
  9.         /* else{
  10.              acc.Submit_Go_No_Go_Question__c = false;
  11.         } */
  12.         UPDATE acc;
  13.     }
  14.  
  15.         @AuraEnabled
  16.     public static boolean getOppty(String key){
  17.         Opportunity acc = [SELECT Id, Product_Family__c FROM Opportunity WHERE Id=:key];  
  18.         if(acc.Product_Family__c!=''){
  19.         return false;
  20.         }else{
  21.         return true;
  22.         }
  23.     }
  24.  
  25. }
  26.      
  27. <aura:component controller="updateCheckBoxPlan"
  28.                 implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
  29.  
  30.     <aura:attribute name="opp" type="Boolean" />
  31.          <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
  32.     <aura:handler event="force:refreshView" action="{!c.isRefreshed}" />
  33.     <aura:if isTrue="{!v.opp}">
  34.         <div aura:id="myDiv" class="slds-align_absolute-center" style="color:red">
  35.             <p><b>Test</b></p>
  36.         </div>
  37.     </aura:if>
  38.  
  39.     <div class="slds-align_absolute-center" style="height:8rem">        
  40.         <lightning:button label="Confirm Submission"
  41.                           variant="brand"
  42.                           onclick="{!c.updateCheck }"/>
  43.     </div>
  44. </aura:component>
  45.      
  46. ({
  47.  
  48.      doInit : function(component, event) {
  49.          var action = component.get("c.getOppty");
  50.                  action.setParams({ key :component.get("v.recordId") });
  51.  
  52.          action.setCallback(this, function(a) {
  53.              component.set("v.opp", a.getReturnValue());
  54.          });
  55.          $A.enqueueAction(action);
  56.      },
  57.  
  58.     updateCheck : function(component, event, helper) {
  59.         var rid = component.get("v.recordId");
  60.         var action = component.get("c.updateChk");
  61.         action.setParams({key : rid});
  62.         action.setCallback(this, function(response) {
  63.             var state = response.getState();
  64.  
  65.  
  66.             if (state === "SUCCESS") {
  67.                 component.set("v.opp",true );
  68.                 $A.get('e.force:refreshView').fire();  
  69.             }
  70.             else if (state === "ERROR") {
  71.                 var errors = response.getError();
  72.                 if (errors) {
  73.                     if (errors[0] && errors[0].message) {
  74.                         console.log("Error message: " +
  75.                                     errors[0].message);
  76.                     }
  77.                 }
  78.                 else {
  79.                     console.log("Unknown Error");
  80.                 }
  81.             }
  82.         });
  83.         $A.enqueueAction(action);
  84.     },
  85.  
  86.     isRefreshed: function(component, event, helper) {
  87.         location.reload();
  88.     },
  89. })
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top