我有一个闪电组件(用于联系的自定义销售路径)。但是当我导航到其中一个阶段时,它给了我这个错误:
未捕获的操作失败:c:SalesPath $ controller $ handleInactive [无法读取未定义的属性'fieldApiName']
我尝试调试,这使我相信在帮助器中解析JSON结果存在问题。
按钮:
<button class="slds-button slds-button_neutral slds-path__mark-complete background" onclick="{!c.handleInactive}">
{!$Label.c.Inactive_Stage}
</button>
JS控制器:
handleInactive : function (component, event, helper) {
let currentStage = component.get("v.currentStage");
let inactiveStage = $A.get("$Label.c.Inactive_Client");
helper.fetchClickedStageFields(component,inactiveStage);
if(currentStage != inactiveStage)
helper.setStageInactive(component,inactiveStage);
}
助手:
fetchClickedStageFields : function(component,stage) {
component.set("v.disabled",false);
let mapFieldAPIs = component.get("v.stageToFieldAPI");
let mapGuidance = component.get("v.stageToGuidance");
for(var key in mapGuidance) {
if('"'+stage+'"' == JSON.stringify(mapGuidance[key].key))
component.set("v.guidanceForSuccess",JSON.stringify(mapGuidance[key].value));
}
for(var key in mapFieldAPIs) {
if('"'+stage+'"' == JSON.stringify(mapGuidance[key].key)) {
component.set("v.criteriaFields",JSON.parse(JSON.stringify(mapFieldAPIs[key].value)));
}
}
}