我有一个简单的类,其中包含一个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);
但是,我试图从闪电流中对其进行“调用”,但是由于失败,并显示一条通用的“流中有验证错误”消息。
闪电流-顶点动作
执行日志-流程有验证错误
我显然缺少一些东西,想知道是否有人可以提供一些指导/想法?