我有一个简单的类,其中包含一个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);
但是,我正试图从闪电流中“吸引”它,但是它失败,并显示一条通用的“流有验证错误”消息。
execution log - flow has validation errors
我显然缺少某些东西,想知道是否有人可以提供一些指导/想法?
非常感谢,Dom