Loading
Salesforce now sends email only from verified domains. Read More
Salesforce Contracts
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Create Lightning Component for Update Contracts Action Button

          Create Lightning Component for Update Contracts Action Button

          To configure a update contracts action button, the system admin must create a lightning component that will call the connected API called Update Contracts.

          1. Create an Apex class.
            1. Click File | New | Apex Class.
            2. Enter a name for the apex class.
              For example, UpdateContract.
            3. Click OK.
            4. Paste the code.
              public class UpdateContractController {
              @AuraEnabled
                  public static List<String> getUpdatedRecord(String sourceRecordId, Boolean autoDocgen) {
                      ConnectApi.ContractInputRepresentation objInput = new ConnectApi.ContractInputRepresentation();
                      objInput.sourceObjectId = sourceRecordId;
                      objInput.isAutoDocgenRequired = autoDocgen;
                      ConnectApi.ContractOutputRepresentation objOutput = ConnectApi.Clm.updateContract(objInput);
                       List<String> contractData = new List<String>();
                      contractData.add(objOutput.data[0]);
                      return contractData;
                      
                  }
              }
              
            5. Save your changes.
          2. Open the developer console.
          3. Create a lightning component:
            1. Click File | New | Lightning Component.
            2. Enter a name for the lightning component.
              For example, <UpdateContractFromCustomObject>.
            3. Select Lightning Quick Action.
            4. Click Submit.
              The lightning component class page opens.
            5. Paste the code.
              <aura:component controller="UpdateContractController" implements="force:lightningQuickAction,force:hasRecordId">
              <aura:html tag="style">
                  .modal-body.spinnerHeight{
                  height: 25%
                  }
              </aura:html>
              <aura:handler name="init" value="{!this}" action="{!c.onInit}"/>
              <aura:attribute name="recordId" type="String" description="stores the record id"/>
              <lightning:navigation aura:id="navLink"/>
              <aura:attribute name="Spinner" type="boolean" default="true"/>
                  <aura:if isTrue="{!v.Spinner}">
                  <div style="height:6rem;position:relative">
                          <lightning:spinner variant="brand" alternativeText="Loading..." size="large"/>
                  </div>
                  </aura:if>
              
              </aura:component>
              
            6. Save your changes.
          4. Create a controller.
            1. Click CONTROLLER.
            2. Paste the code.
              ({
              
                  onInit: function (cmp, event, helper) {
                      
                      var updateContractAction = cmp.get("c.getUpdatedRecord");
                      cmp.set("v.Spinner", true);
                      updateContractAction.setParams({
                          sourceRecordId : cmp.get("v.recordId"),
                          autoDocgen : "true"
                      });
              
                      updateContractAction.setCallback(this, function(result) {
                          var state = result.getState();
                          var response;
                          if (state === 'SUCCESS') {
                              cmp.set("v.Spinner", false);
                              
                              response = result.getReturnValue();
                              $A.get("e.force:showToast").setParams({
                                  mode: 'dismissible',
                                  type: "success",
                                  message: "Contracts Updated Succesfully"
                              }).fire();
                          }else{
                              cmp.set("v.Spinner", false);
                              
                              $A.get("e.force:showToast").setParams({
                                  mode: 'dismissible',
                                  type: "error",
                                  message: result.getError() && result.getError()[0] && result.getError()[0].message ? result.getError()[0].message :"Error while updating contracts",
                                  duration: 10000,
                              }).fire();
                          }
                          $A.get("e.force:closeQuickAction").fire();
                      });
                      $A.enqueueAction(updateContractAction);
                  }
              })
              
            3. Save your changes.
           
          Loading
          Salesforce Help | Article