我正在尝试将 HTML 输入中的值传递到 JavaScript 函数中,然后传递到 apex 控制器以在 salesforce 中创建潜在客户

I am trying to pass values from HTML input into a JavaScript function and then to an apex controller to create a lead in salesforce

提问人:Greg Fury 提问时间:9/17/2021 更新时间:9/17/2021 访问量:217

问:

  • HTML(这是我在体验构建器页面上收集信息的地方)

             <div class="slds-form-element__control ">
            <input type="text"
             id="firstName"
             placeholder="First Name"
             class="first_name_input slds-input"
              />                 
             </div>
    
             <div class="slds-form-element__control ">
             <input type="text"
              id="lastName"
              placeholder="Last Name"
              class="last_name_input slds-input"
              />     
    
             </div>
    
             <div class="slds-form-element__control ">
             <input type="text"
              id="email"
              placeholder="Email Address"
              class="email_input slds-input"
              />                 
             </div>
    

-JavaScript(值被传递给有多个函数的 java 脚本,这是旨在将值传递给 apex 以创建潜在客户的函数)

createLead(firstName,lastName, email) {
            var firstName = firstName
            var lastName = lastName
            var email = email
            this.createOrObtainExistingLead()
            this.navigateToFAPage()
            }

-apex(一旦将值传递到顶点控制器,就应该使用从 JavaScript 传递的值创建潜在客户)

公共类 VOQuickQuoteController {

@AuraEnabled
@future
public static void createOrObtainExistingLead(string firstName, string lastName, string email,) {    
    
    Lead l = new Lead(
        firstName=firstName,
        lastName=lastName,
        email=email,       
    );
    insert l;    
}    

}

JavaScript HTML Salesforce 参数传递 APEX

评论


答: 暂无答案