The query used is standard AxdCustCollectionLetterJour. And this is the code I put into the “SendElectronically” method. _collectionRecIdSet is a Set of recIds.
AIFSendActionType sendActionType = AifSendActionType::SendByQuery;
AifConstraint aifConstraint = new AifConstraint() ;
AifConstraintList aifConstraintList = new AifConstraintList();
AifActionId aifactionId;
AifEndpointList endpointList;
Query query;
QueryBuildDataSource custCollectionLetter_ds;
QueryBuildRange recIdRange;
SetEnumerator setEnum;
Str rangeStr;
query = new Query(queryStr(AxdCustCollectionLetter));
custCollectionLetter_ds = query.dataSourceTable(tablenum(CustCollectionLetterJour));
recIdRange = custCollectionLetter_ds.addRange(fieldNum(CustCollectionLetterJour, RecId));
if (_collectionRecIdSet.elements())
{
setEnum = _collectionRecIdSet.getEnumerator();
while (setEnum.moveNext())
{
rangeStr += int2str(setEnum.current()) + ‘,’;
}
}
else
return false;
recIdRange.value(rangeStr);
aifActionId = AifSendService::getDefaultSendAction(classnum(CustCollectionLetterService), sendActionType);
aifConstraint.parmType(AifConstraintType::NoConstraint);
aifConstraintList.addConstraint(aifConstraint);
endPointList = AifSendService::getEligibleEndpoints(aifActionId, aifConstraintList);
AifSendService::submitFromQuery(aifActionId, endPointList,query,AifSendMode::Async);