Signature

global static List<DocGenTemplateList> getDocGenTemplates(
  List<Types.ListDocTemplatesInput> inputs,
  String runAs
)
Parameters
ParameterDescription
inputs requiredOne entry per template search. Each Types.ListDocTemplatesInput filters by object type, by tags, or by both.
runAs
String
optionalEmail Id of the user on whose behalf the function should run. To run the action as the automation user, supply integrationUser.

Return Type

List<DocGenTemplateList>. One list per input, in the same order as the inputs. Identical searches in one call are run once and the result is returned for each of them.

Example

// Templates for the Opportunity object
cldfs.Types.ListDocTemplatesInput byObject = new cldfs.Types.ListDocTemplatesInput('Opportunity');

// Templates tagged both 'Quote' and 'EMEA', on any object
cldfs.Types.ListDocTemplatesInput byTags = new cldfs.Types.ListDocTemplatesInput(
  null,
  new List<String>{ 'Quote', 'EMEA' },
  'ALL'
);

List<cldfs.DocGenTemplateList> results = cldfs.Client.getDocGenTemplates(
  new List<cldfs.Types.ListDocTemplatesInput>{ byObject, byTags },
  'integrationUser'
);
for (cldfs.DocGenTemplate template : results[0].templates) {
  System.debug(template.name + ' ' + template.id);
}
Always set an object type or tagsThe Get Doc-Gen Templates Flow action returns an empty list when an input has neither an object type nor tags, so a flow never receives the whole template library. This method sends the input as you built it, so check for an empty filter before you call it.
Tags from ApexTag matching ignores case, and the Flow action trims each tag, drops blank ones and removes duplicates before it sends them. This method does not, so do the same yourself: CloudFiles accepts at most 50 tags per search. The runtime variables option on the Flow action cannot be set from Apex, so variables on each DocGenTemplate is empty when you call this method.