如何使用 Apex 将案例发送到 Lightning cmp

问题描述

我需要将当前案例发送到闪电组件并在顶点下方写入,但似乎我无法将当前案例记录 ID 发送到闪电组件,任何解决方

public static Case getCaseFromId(Id caseID) { 


   if(caseID == null) {
        return [SELECT ID,Subject,Description,STATUS from Case LIMIT 1];
    }

   List<Case> cases = [ SELECT Id,Status from CASE where ID = :caseID ];
    
      if(cases.size() == 0) {
          return [SELECT ID,STATUS from Case LIMIT 1];
      } else {
         return cases[0];
      }        

    }

cmp 文件

  <aura:attribute name="record" type="case[]"/>

控制器文件

var action = component.get("c.getCaseFromId");
 action.setCallback(this,function(response){
    var state = response.getState();
    if (state === "SUCCESS") {
      
        var navEvent = $A.get("e.force:navigatetoSObject");
         alert("hello there!"+ component.get("v.record",response.getReturnValue())); 
        navEvent.setParams({

           "recordId": component.get("v.record",response.getReturnValue())

        });
        navEvent.fire();

问题是浏览器中的警报显示“未定义”,这意味着有问题,任何建议

谢谢, 卡罗琳

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)