Announcement

Collapse
No announcement yet.

Extracting the name of attachments from email

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Extracting the name of attachments from email

    Hello,
    I need to extract the names of attachments from an email.
    The attachmentIds extraction is working fine:
    HTML Code:
    $list = record\attribute('Email', '65fd41542cce03aba', 'attachmentsIds');
    where am I going wrong in extracting the names?​
    HTML Code:
    $list = record\attribute('Email', '65fd41542cce03aba', 'attachmentsNames');
    Thanks

  • #2
    attachmentsNames is a a not storable field. you would have to loop through the attachments and get the name of each one of them as below

    PHP Code:
    $ids record\attribute('Email''65fd41542cce03aba''attachmentsIds');

    $names = list();

    $i 0;

    while(
    $i array\length($ids)){
        
        
    $o record\fetch('Attachment'array\at($ids$i));
        
        if (
    $o) {
            
    $name object\get($o'name');
            
    $names array\push($names$name);
        }

        
    $i $i 1;
    }

    $names array\join($names' - ');​​ 
    Rabii
    Web Dev

    Comment


    • #3
      Thank you rabii.
      However, I have a little problem. I don't know why your formula works in sandbox, but when I try to use it in bpm or workflow it doesn't work:
      Click image for larger version

Name:	invoice.jpg
Views:	104
Size:	92.5 KB
ID:	104026
      I am sending an attachment called Invoice, but the process goes through the right side :/

      Comment


      • rabii
        rabii commented
        Editing a comment
        Can you share more details maybe some code is blocking the execution.

    • #4
      I don't know why the $names variable in workflow or bpm always returns an empty value even though the same script in the sandbox returns the correct value.
      For example, below is the workflow which also does not work, and when testing the same script, it returns 'true' on the same email in the sandbox​:
      Click image for larger version

Name:	1.jpg
Views:	96
Size:	74.2 KB
ID:	104075

      Comment


      • #5
        Hey,

        I have noticed that you are using trigger type => After record saved (This will always trigger on update as default) i would suggest to change that to After record created which will be triggered only when the parent is opportunity. i have tested this and it works on a bpmn - on workflow won't work as the formula condition will always return null while it should return a boolean. I suggest that you use bpmn. please find attached a flowchart you can import and test with it and also build on it.

        I hope this helps
        Attached Files
        Rabii
        Web Dev

        Comment

        Working...
        X