Apex
CloudFiles Client
Merge Documents (Sync)
the merge documents (sync) apex action allows you to combine multiple files—pdf, docx, png, or jpeg—into a single consolidated document directly through apex this synchronous action is ideal for scenarios where you need the merged file immediately for further processing within your automation or custom logic we assume you’ve already explored the merge documents (sync) docid\ akbaey1ytn5miwrzxe1tl flow action global static list\<generateddocument> mergedocumentssync( list\<types mergedocumentsrequestinput> payloads, string runas ) parameters payloads list of types mergedocumentsrequestinput docid m m7jkk0 httksvvje0j runas runas, usually this would be a static value integrationuser return type list of generateddocument docid 5kuzh0qybdpcwxpem yjh example in this example, we will show how to merge documents stored in external storage you can also merge documents stored in salesforce and save the merged files into salesforce storage cldfs resource destination = new cldfs resource('01kehakuvatuh5r5qrkjblr3itm3e6vcxn', null, null, 'sharepoint', 'b!njbtpq z5uejtfrj f24xeqqlpud8vtfsg7gbcrxjepiun9bkb 7qbdptqhvd cp'); list\<cldfs resource> resourcestomerge = new list\<cldfs resource>{ new cldfs resource('01kehakuvvzcavrdfctjazgehhviecee5s', 'file', 'empty doc docx', 'sharepoint', 'b!njbtpq z5uejtfrj f24xeqqlpud8vtfsg7gbcrxjepiun9bkb 7qbdptqhvd cp'), new cldfs resource('01kehakuq6hptoxbhsbvalo5n4de6vxntt', 'file', 'empty pdf pdf', 'sharepoint', 'b!njbtpq z5uejtfrj f24xeqqlpud8vtfsg7gbcrxjepiun9bkb 7qbdptqhvd cp') }; list\<cldfs types mergedocumentsrequestinput> payloads = new list\<cldfs types mergedocumentsrequestinput>{ new cldfs types mergedocumentsrequestinput( resourcestomerge, 'test merge', destination ) }; list\<cldfs generateddocument> generateddocument = cldfs client mergedocumentssync(payloads, 'integrationuser');