无法使简单的Apex类可调用-根据坐标输入查找自定义位置记录

我有一个简单的类,其中包含一个SOQL查询,该查询根据2个坐标的输入来查找最近的自定义位置记录:

public with sharing class NearestLocation {

@InvocableMethod(label='Get Nearest location' description='From given coordinates the nearest location is returned')
public static List<custom__Location__c> getLocation(List<FlowInput> requests)
{

    List<custom__Location__c> locList =
    [SELECT  id,Name
    FROM custom__Location__c  WHERE RecordType.Name = 'Synced' AND 
    DISTANCE(custom__GeoLocation__c,GEOLOCATION(:requests[0].coordlat,:requests[0].coordlng),'km')<1
    ORDER BY DISTANCE(custom__GeoLocation__c,'km')
                     LIMIT 1];

  for(custom__Location__c lc : locList)
  {
      system.debug('~~!~~!~~' + lc.id);
      system.debug('~~!~~!~~' + lc.name);
  }
        return locList;
}

    public class FlowInput 
    {
        @InvocableVariable(required=true)
        public decimal coordlat;
        @InvocableVariable(required=true)
        public decimal coordlng;
 }   }

从Execute Anon运行时,以上代码按预期工作:

list <NearestLocation.FlowInput> fi = new list<NearestLocation.FlowInput>();
NearestLocation.FlowInput x1 = new NearestLocation.FlowInput();
x1.coordlat = 53.243213;
x1.coordlng = -1.475886;
fi.add(x1);
NearestLocation.getLocation(fi);

但是,我试图从闪电流中对其进行“调用”,但是由于失败,并显示一条通用的“流中有验证错误”消息。

闪电流-顶点动作

无法使简单的Apex类可调用-根据坐标输入查找自定义位置记录





执行日志-流程有验证错误

无法使简单的Apex类可调用-根据坐标输入查找自定义位置记录

我显然缺少一些东西,想知道是否有人可以提供一些指导/想法?

dongchenxiapril 回答:无法使简单的Apex类可调用-根据坐标输入查找自定义位置记录

如果将输出分配给集合变量,请

尝试返回List>。

,

已解决。

代码没有任何天生的错误……问题归因于雷电流中无关的公式!嗯...自我介绍...从一块空白的画布开始!

感谢艾哈迈德的回应。它正在返回一个列表: 公共静态列表 返回locList;

本文链接:https://www.f2er.com/2684118.html

大家都在问