Need Help with Posting Attachments and Text to Note Section via Workflow
Collapse
X
-
rabii
here is the code
// now let try and see if this will work - if it doesn't it will confirm that the issue is with the workflow
$documentIds = workflow\targetEntity\attribute('documentIds');
$newAttachments = list();
$i = 0;
while(
$i < array\length($documentIds),
(
$newAttachments = array\push(
$newAttachments,
record\create('Attachment',
'role', 'Attachment',
'type', record\attribute('Attachment', array\at($documentIds, $i), 'type'),
'size', record\attribute('Attachment', array\at($documentIds, $i), 'size'),
'global', record\attribute('Attachment', array\at($documentIds, $i), 'global'),
'name', record\attribute('Attachment', array\at($documentIds, $i), 'name'),
'sourceId', $fileId,
'storage', record\attribute('Attachment', array\at($documentIds, $i), 'storage'),
'field', 'attachments',
'parentType', 'Note'
)
);
$i = $i + 1;
)
);
record\create('Note',
'post', 'Howdy Old file has been updated with a new one!',
'attachmentsIds', $newAttachments,
'type', 'Post',
'parentType', 'Document',
'parentId', workflow\targetEntity\attribute('id'),
'createdById', modifiedById
);Comment
-
I pasted your code and got the same error as you. You should use this code:
Code:$attachmentsIds = workflow\targetEntity\attribute('documentIds'); $i = 0; $documentIds = list(); while( $i < array\length($attachmentsIds), $attachmentId = array\at($attachmentsIds, $i); $documentId = record\create('Attachment', 'role', 'Attachment', 'type', record\attribute('Attachment', $attachmentId, 'type'), 'size', record\attribute('Attachment', $attachmentId, 'size'), 'global', record\attribute('Attachment', $attachmentId, 'global'), 'name', record\attribute('Attachment', $attachmentId, 'name'), 'sourceId', $attachmentId, 'storage', record\attribute('Attachment', $attachmentId, 'storage'), 'parentName', targetEntity\attribute('name'), 'parentId', targetEntity\attribute('id'), 'parentType', 'Note', 'field', 'attachments' ); $documentIds = array\push($documentIds, $documentId); entity\addLinkMultipleId( 'attachments', $documentIds ); $i = $i + 1; ); post = 'Howdy Old file has been updated with a new one!'; type = 'Post'; parentType = 'Document'; parentId = workflow\targetEntity\attribute('id'); createdById = workflow\targetEntity\attribute('modifiedById');
Comment
-
victor
after pasting the code you have provided . no any result or no any record has created in note section
Comment
Comment