在创建新的Salesforce案例时自动填充字段

时间:2019-02-18 23:31:41

标签: apex force.com salesforce-lightning

我们正从“经典”过渡到“闪电”,但URL转换按钮转换后出现问题。我使用了Salesforce提供的工具,按钮可以很好地转换,但字段不会自动填充。该按钮应从现有案例创建一种新的案例,并自动填充AccountId和ContactId。我正在尝试编写代码以从头开始执行此操作,但是我是Salesforce开发的新手。我有以下代码。

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" access="global" >
<aura:attribute name="recordId" type="String" /> 
<aura:attribute name="record" type="Case"/>
<aura:attribute name="caseFields" type="String[]" default="['Description', 'AccountId', 'Status']"/>
<aura:attribute name="newCaseFields" type="String[]" default="['Subject', 'Priority', 'Status']"/>

<lightning:recordForm recordId="{!v.recordId}" 
                      objectApiName="Case"
                      fields="{!v.caseFields}"
                      mode="Edit"
                      onsuccess="{!c.myAction}">
</lightning:recordForm>

<lightning:recordForm
     objectApiName="Case"
     fields="{!v.newCaseFields}"
     mode="edit"
     onsubmit="{!c.handleSubmit}" />

控制器

({
myAction : function(component, event, helper) {
 var toastEvent = $A.get("e.force:showToast");  
 toastEvent.setParams({  
   "title": "Success!",  
   "message": "Record is successfully updated!",  
   "type": "success"  
 });  
 toastEvent.fire();
}

})

通过单击按钮并弹出一些内容,从现有案例创建新案例(从支持中收取费​​用)的最佳方法是什么?我更喜欢将其构建为Web组件,但是由于我是Salesforce开发的新手,因此我认为将会有关于Aurora组件的更多信息。我更喜欢将这两个组件组合为一个组件,以便可以将它们放在模式中,因为当我不将代码直接放在模式中时,我将很难提取数据。

0 个答案:

没有答案