Loading
Education Cloud
目錄
選取篩選

          沒有結果
          沒有結果
          以下是搜尋小祕訣

          檢查關鍵字的拼字。
          使用較常見的搜尋字詞。
          選取較少篩選條件以擴大您的搜尋。

          搜尋所有 Salesforce 說明
          在教育環境中的禮物項目網格範本中設定資料欄強制回應

          在教育環境中的禮物項目網格範本中設定資料欄強制回應

          透過設定互動式資料欄強制回應來自訂禮物項目體驗。您可以將標準欄位集或自訂 Lightning Web 元件 (LWC) 直接內嵌在網格中,以便在不離開主要工作流程的情況下,捕捉複雜的捐贈者詳細資料。

          必要版本

          所需版本
          提供版本:Lightning Experience

          提供版本:具備 Education Cloud 的 EnterprisePerformanceUnlimitedDeveloper Edition

          提供版本:具備 Nonprofit Cloud 的 EnterpriseUnlimitedDeveloper Edition

          所需的使用者權限
          若要設定資料欄強制回應:

          FundraisingAccess 權限集

          Education Cloud 完整存取權限集

          1. 在「顯示欄」中,針對您要設定的欄,按一下「編輯欄」。
          2. 按一下「強制回應」。
          3. 選取「Lightning Web 元件」作為強制回應類型。
            您可以使用您建立或從受管理封裝安裝的現有 LWC。或者,您可以透過選取要顯示的欄位

            $GiftEntryGrid.FieldsModal

            標準 LWC,然後在「強制回應中設定欄位」區段中新增欄位。
          4. 選取您的 Lightning Web 元件作為 Lightning Web 元件名稱。
          5. 輸入強制回應標籤。
          6. 輸入要為您的強制回應顯示的圖示。(預設值為:utility:expand_alt).
            預設圖示為 utility:expand_alt,但您可以從 SLDS 圖示庫 中選擇其他圖示。
          7. 或者,新增強制回應的替代標籤。
            如果符合顯示替代項目之條件,則會顯示替代項目,而非「強制回應標籤」值。

          禮物項目網格強制回應元件範例

          此 Lightning Web 元件程式碼片段範例顯示信用卡處理器,並可設定為「付款方式」欄位的強制回應。

          所需版本
          提供版本:Lightning Experience

          提供版本:具備 Education Cloud 的 EnterprisePerformanceUnlimitedDeveloper Edition

          提供版本:具備 Nonprofit Cloud 的 EnterpriseUnlimitedDeveloper Edition

          giftEntryGridPaymentAuthModal.html

          <template>
              <!--
              Sample Gift Entry Grid Modal Component
              There are no implementation requirements for this component, however the modal portal size is limited.
              -->
              <lightning-card title="Credit Card Authorization">
                  <div class="slds-p-around_medium">
                      <form onsubmit={handleSubmit} class="slds-form">
                          <!-- Row 1: PaymentMethod GiftEntry field -->
                          <lightning-record-edit-form object-api-name="GiftEntry" onsuccess={handleSuccess} class="slds-m-bottom_medium">
                              <div class="slds-grid">
                                  <div class="slds-col slds-size_1-of-1">
                                      <lightning-input-field
                                          field-name="PaymentMethod"
                                          value={paymentMethod}
                                          onchange={handleInputChange}
                                          required
                                      ></lightning-input-field>
                                  </div>
                              </div>
                          </lightning-record-edit-form>
          
                          <!-- Only show credit card fields if needed -->
                          <template if:true={showCreditCardFields}>
                              <!-- Row 2: NameOnCard and CardNumber -->
                              <div class="slds-grid slds-gutters slds-m-bottom_medium">
                                  <div class="slds-col slds-size_1-of-2">
                                      <lightning-input
                                          name="NameOnCard"
                                          label="Name on Card"
                                          value={nameOnCard}
                                          onchange={handleInputChange}
                                          required
                                      ></lightning-input>
                                  </div>
                                  <div class="slds-col slds-size_1-of-2">
                                      <lightning-input
                                          name="CreditCardNumber"
                                          label="Credit Card Number"
                                          value={creditCardNumber}
                                          placeholder="XXXX-XXXX-XXXX-XXXX"
                                          maxlength="19"
                                          inputmode="numeric"
                                          pattern="(?:\d{4}[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4}|\d{3}[-\s]?\d{6}[-\s]?\d{5}|\d{16}|\d{15})"
                                          message-when-pattern-mismatch="Enter a valid credit card number."
                                          onchange={handleInputChange}
                                          required
                                      ></lightning-input>
                                  </div>
                              </div>
                              <!-- Row 3: ExpiryMonth, ExpiryYear, CVV -->
                              <div class="slds-grid slds-gutters">
                                  <div class="slds-col slds-size_1-of-3">
                                      <lightning-input
                                          name="ExpiryMonth"
                                          label="Expiration Month"
                                          value={expiryMonth}
                                          onchange={handleInputChange}
                                          inputmode="numeric"
                                          pattern="\d{2}"
                                          required
                                      ></lightning-input>
                                  </div>
                                  <div class="slds-col slds-size_1-of-3">
                                      <lightning-input
                                          name="ExpiryYear"
                                          label="Expiration Year"
                                          value={expiryYear}
                                          onchange={handleInputChange}
                                          inputmode="numeric"
                                          pattern="\d{2}|\d{4}"
                                          required
                                      ></lightning-input>
                                  </div>
                                  <div class="slds-col slds-size_1-of-3">
                                      <lightning-input
                                          name="Cvv"
                                          label="CVV"
                                          value={cvv}
                                          onchange={handleInputChange}
                                          inputmode="numeric"
                                          pattern="\d{3,4}"
                                          required
                                      ></lightning-input>
                                  </div>
                              </div>
                          </template>
                      </form>
                  </div>
                  <template if:true={showCreditCardFields}>
                      <div class="slds-grid slds-grid_align-end slds-m-top_medium">
                          <lightning-button
                              variant="brand"
                              label="Charge Card"
                              onclick={handleChargeCardClick}
                              class="slds-m-right_none"
                              disabled={isChargeCardDisabled}
                          ></lightning-button>
                      </div>
                  </template>
              </lightning-card>
          </template>
          

          giftEntryGridPaymentAuthModal.js

          import { LightningElement, api, track } from 'lwc';
          
          const CONSTANTS = {
              CREDIT_CARD: 'Credit Card',
              ACH: 'ACH'
          }
          
          /**
           * Sample Gift Entry Grid Modal Component
           */
          export default class giftEntryGridPaymentAuthModal extends LightningElement {
              /**
               * Required input property.
               * Not generally used within a custom component
               */
              @api
              set modalFields(value) {
                  this._modalFields = value || [];
                  this.initializeFields();
              }
              get modalFields() {
                  return this._modalFields;
              }
          
              /**
               * Required input property.
               * Contains all the data for the row.
               */
              @api
              set rowData(value) {
                  this._rowData = value || {};
                  this.initializeFields();
              }
              get rowData() {
                  return this._rowData;
              }
          
          
              // ------------------------------------------------------------
              // Required Exposed API Functions for GiftEntryGrid
              // ------------------------------------------------------------
          
              /**
               * Validates the component fields.
               * @returns {Object} An object with properties for isValid (boolean) and an invalidFields collection with errors
               * - isValid: true if the component fields are valid, false otherwise.
               * - invalidFields: A Set of field names and errors to render
               */
              @api
              validate() {
                  let isValid = true;
                  let invalidFields = new Set();
                  if (!this.paymentMethod) {
                      isValid = false;
                      invalidFields.add('PaymentMethod');
                  }
                  if (this.showCreditCardFields) {
                      if (!this.chargeCardClicked) {
                          isValid = false;
                          invalidFields.add('ChargeCard');
                      }
                      if (!this.creditCardNumber || !this.validateCreditCardNumber()) {
                          isValid = false;
                          invalidFields.add('CreditCardNumber is invalid');
                      }
                      if (!this.nameOnCard) {
                          isValid = false;
                          invalidFields.add('NameOnCard is missing');
                      }
                      if (!this.expiryMonth || !this.validateExpiryMonth()) {
                          isValid = false;
                          invalidFields.add('ExpiryMonth is not valid');
                      }
                      if (!this.expiryYear || !this.validateExpiryYear()) {
                          isValid = false;
                          invalidFields.add('ExpiryYear is not valid');
                      }
                      if (!this.cvv || !this.validateCVV()) {
                          isValid = false;
                          invalidFields.add('CVV is not valid');
                      }
                  }
                  return { isValid, invalidFields };
              }
          
              /**
               * Returns values to be saved to the row. These are directly applied to the rowData object within the Grid
               * Properties in this object do not need to be actual GiftEntry fields. Dummy properties are allowed, but 
               * they will not persist to the GiftEntry row when the record is saved.
               * @returns {Object} An object with the values that represent GiftEntry fields.
               */
              @api
              getComponentValues() {
                  let result = {}
                  result['PaymentMethod'] = this.paymentMethod;
                  if (this.showCreditCardFields) {
                      result['Last4'] = this.creditCardNumber ? this.creditCardNumber.slice(-4) : null;
                      result['ExpiryMonth'] = this.expiryMonth;
                      result['ExpiryYear'] = this.expiryYear;
                      result['CCAuthCode__c'] = this.generateRandomString(16);
                      result['NameOnCard__c'] = this.nameOnCard;
                      result['Card_CVV__c'] = this.cvv;
                      result['GatewayTransactionFee__c'] = 0.12345;
                      result['GatewayReference__c'] = this.creditCardNumber;
                  } else {
                      result['Last4'] = null;
                      result['ExpiryMonth'] = null;
                      result['ExpiryYear'] = null;
                      result['CCAuthCode__c'] = null;
                      result['NameOnCard__c'] = null;
                      result['Card_CVV__c'] = null;
                      result['GatewayTransactionFee__c'] = null;
                      result['GatewayReference__c'] = null;
                  }
                  return result;
              }
          
              // ------------------------------------------------------------
              // Everything below this is generic custom code to illustrate the component behavior
              // ------------------------------------------------------------
              _modalFields = [];
              _rowData = {};
          
              @track paymentMethod = CONSTANTS.CREDIT_CARD;
              @track creditCardNumber = '';
              @track nameOnCard = '';
              @track expiryMonth = '';
              @track expiryYear = '';
              @track cvv = '';
              @track gatewaytransactionfee = null;
              @track gatewayreference = null;
              @track chargeCardClicked = false;
          
              connectedCallback() {
                  this.initializeFields();
              }
          
              initializeFields() {
                  this.paymentMethod = this._rowData['PaymentMethod'] || '';
                  this.creditCardNumber = (this._rowData['Last4'] ? "****-****-****-" + this._rowData['Last4'] : '');
                  if (this._rowData['NameOnCard__c']) {
                      this.nameOnCard = this._rowData['NameOnCard__c'];
                  } else if (this._rowData['FirstName'] && this._rowData['LastName']) {
                      this.nameOnCard = this._rowData['FirstName'] + ' ' + this._rowData['LastName'];
                  } else {
                      this.nameOnCard = '';
                  }
                  this.expiryMonth = this._rowData['ExpiryMonth'] || '';
                  this.expiryYear = this._rowData['ExpiryYear'] || '';
                  this.cvv = this._rowData['Card_CVV__c'] || '';
                  this.gatewayTransactionFee = this._rowData['GatewayTransactionFee__c'] || null;
                  this.gatewayReference = this._rowData['GatewayReference__c'] || null;
              }
          
              handleInputChange(event) {
                  let fieldName = event?.target?.fieldName || event?.target?.name;
                  if (fieldName) {
                      fieldName = fieldName.charAt(0).toLowerCase() + fieldName.slice(1);
                  }
          
                  const fieldValue = event?.target?.value;
                  this[fieldName] = fieldValue;
                  if (fieldName === 'paymentMethod') {
                      if (!this.showCreditCardFields) {
                          this.creditCardNumber = '';
                          this.nameOnCard = '';
                          this.expiryMonth = '';
                          this.expiryYear = '';
                          this.cvv = '';
                      }
                  }
                  if (fieldName === 'creditCardNumber') {
                      this.validateCreditCardNumber();
                  }
                  if (fieldName === 'expiryMonth') {
                      this.validateExpiryMonth();
                  }
                  if (fieldName === 'expiryYear') {
                      this.validateExpiryYear();
                  }
              }
          
              handleChargeCardClick() {
                  this.chargeCardClicked = true;
              }
          
              canChargeCard() {
                  if (this.chargeCardClicked) return false;
                  if (!this.showCreditCardFields) return false;
                  return (
                      !!this.creditCardNumber && this.validateCreditCardNumber() &&
                      !!this.nameOnCard &&
                      !!this.expiryMonth && this.validateExpiryMonth() &&
                      !!this.expiryYear && this.validateExpiryYear() &&
                      !!this.cvv && this.validateCVV()
                  );
              }
          
              validateCreditCardNumber() {
                  const regex = /^(?:\d{4}[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4}|\d{3}[-\s]?\d{6}[-\s]?\d{5}|\d{16}|\d{15})$/;
                  return this.creditCardNumber === '' || regex.test(this.creditCardNumber);
              }
          
              validateExpiryMonth() {
                  const month = parseInt(this.expiryMonth, 10);
                  return this.expiryMonth === '' || (month >= 1 && month <= 12);
              }
          
              validateExpiryYear() {
                  let year = parseInt(this.expiryYear, 10);
                  year = year < 99 ? 2000 + year : year;
                  const currentYear = new Date().getFullYear();
                  return this.expiryYear === '' || (year >= currentYear && year <= currentYear + 10);
              }
          
              validateCVV() {
                  return this.cvv === '' || /^\d{2}|\d{4}/.test(this.cvv);
              }
          
              generateRandomString(length) {
                  const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
                  let result = '';
                  for (let i = 0; i < length; i++) {
                      result += chars.charAt(Math.floor(Math.random() * chars.length));
                  }
                  return result;
              }
          
              get showCreditCardFields() {
                  return this.paymentMethod === CONSTANTS.CREDIT_CARD || this.paymentMethod === CONSTANTS.ACH;
              }
          
              get minExpiryYear() {
                  return new Date().getFullYear();
              }
          
              get maxExpiryYear() {
                  return new Date().getFullYear() + 10;
              }
          
              get isChargeCardDisabled() {
                  return !this.canChargeCard();
              }
          }
          
           
          正在載入
          Salesforce Help | Article