Logic Hook for using custom field email?

Hey guys,

there is one thing I need some advice with. I have a custom module and it contains some info and it also has its own custom email field (email_c) and what I need to do is:

  • I will create a custom file type field (I think I know how to do that)
  • when you upload something then I need to send an email to adress in email_c (custom email field) and attach this file to it

Not really sure where to start though :frowning: Will you please help me a bit? Maybe someone here does have a similar hook?

Guess its a bit more tough one right :hushed:

You might br able to do it with a workflow if it was to send a generic file, but sending the specific file in that record won’t be possible.

You could do it with my PowerReplacer add-on, the dynamic attachments let you do that from templates.

The way forward (without add-ons) is to use an after_savelogic hook that detects the change in the file field, sets up the email to send using the email_c address and the file, and sends it.

Hey @pgr thank you! I was able to create it with logic hooks. I stills truggle with one thing. My logic hook is after_save and each attachment (each one is different) has 3MB.

When I set the logic hook in a way where it triggers during file upload (after save and then condition - file field not empty) it sends email OK but the file has no .pdf extension and the name has UUID.

BUT - when I upload the attachment first and THEN change anything in any other field it send the email with attachment in correct format with pdf extension.

Now - I think that the problem here is that the logic hook triggers immediately when I am still uploading the big file and although it sends it correctly it probably fails to correctly get filename and file_mime_type from its bean.

And I also found another issue - but this one seems to be related to SuiteCRM native behaviour. I can’t upload files in listview. It simply fails (field stays empty after upload). I have to do it in edit view. :open_mouth:

For a new file field I used this:


Normally I just use a file field created directly in Studio, then added to views, it works just fine.

Seems way easier than that tutorial…

Except I have a custom module (already created and in use - can’t change it now to different type) that has no file field type :frowning:


if Studio has the field type, and there’s a SugarField class for it, I don’t think it should be hard to just add it to a custom module… I can’t go and figure it out right now, sorry

1 Like

Not to worry I will figure it out myself :wink: Will post a result here and if there is an interest I can also post a logic hook for sending mail with attachment.

See here

1 Like