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

问题描述 投票:0回答:2

我有一个简单的类,其中包含一个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, GEOLOCATION(:requests[0].coordlat, :requests[0].coordlng), '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);

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

雷电-顶点动作“执行日志-流程有验证错误“

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

geolocation salesforce apex flow
2个回答
0
投票

0
投票
© www.soinside.com 2019 - 2024. All rights reserved.