Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Subject and attachment name on Gendoc generated e-mails
#1
Hello,
Is there a way to change gendoc's default behavior for generating e-mails:
1. I want the e-mail subject to be the same as the entity subject(i work on Quotes but i gues it would be more or less the same for SO, INV, PO since they all have subject) by default
- i figured i could use the field set mapping but i really don't know what would be the source and destination in this case.
2. I want the name of the attached document to be the entity subject(Quote subject in this case)
- i mingled a bit with evvtgendoc.js and i noticed that i can alter the name in this variable:
var emailurl = 'index.php?module=Emails&action=EmailsAjax&file=EditView&attachment='+i18n+'_'+crmid+'.'+(format=='pdf' ? 'pdf' : 'odt');
but i don't know how to construct it properly.
Saving to folder and exporting is doing that by default and I would like send e-mail to behave the same
Any help is appreciated.

Thanks
Reply
#2
1.- you can use all the same variables you use in the body of the email in the subject, so you can set the email subject field to something like $subject

2.- have you tried with the global variable Workflow_Email_GenDoc_Attachment_Name ?
Joe
TSolucio
Reply
#3
(03-19-2021, 08:59 PM)joebordes Wrote: 1.- you can use all the same variables you use in the body of the email in the subject, so you can set the email subject field to something like  $subject

2.- have you tried with the global variable Workflow_Email_GenDoc_Attachment_Name ?

1. - I tried it on the online demo and is not working for Quotes (or I'm not doing it right). It works for contacts but it will not replace the variables for quotes. I left there a message template called Quote Template.
2.- I did not noticed that GV(again) Wink. However it does not seem to work. I left glb-0000019 on the online demo.

Thanks
Reply
#4
I don't know how you are testing in the demo as the workflow emails are not being sent from there nor is GenDoc installed, so you shouldn't be able to test these two things there

Give me some more information
Joe
TSolucio
Reply
#5
Photo 
(03-20-2021, 10:03 AM)joebordes Wrote: I don't know how you are testing in the demo as the workflow emails are not being sent from there nor is GenDoc installed, so you shouldn't be able to test these two things there

Give me some more information

here is the link:
https://demo.corebos.com/index.php?module=Contacts&parenttab=ptab&action=DetailView&record=43721

I setup GV glb-0000019 with the value Name



Gendoc seems installed, just not prepared for pdfs. I created a contact(gendoc was already activated on contacts, I activated it also on quotes and duplicated the contact template i found there, setting it to be applied on quotes. It doesn't matter if it generates a good file, i'm just checking to see what it wants to attach before sending).
I also created a message template(nr. 43723), i tested it with contacts and some field from there, I could set the e-mail subject. Later I modified it for quotes and tried with subject.
It did not work, you can check it out. the variable is not parsed i just get '$subject' string.

I do not need to actually send the mail, i'm just looking at what it composed when I click 'E-mail Document' from gendoc's widget. I should see the template being aplied there if I select it. I mean it works for Contacts. The generated document that is already attached is always module_name+crmid no matter of the module and that GV. The name of the attached document does not change for neither contacts or quotes

Did I do it wrong?
Reply
#6
No, you did it correctly, I didn't understand.

I looked into it and remembered that this is how it works. You are sending the email to the account/contact and only that module is supported for merging variables. This comes all the way back from vtiger crm where it was hard to do the merge for other modules. In coreBOS the email module has support for a Merge_Template_With list of IDs that will get their variables merged. So I added the quote (and other inventory modules) to that variable and it seems to be working. Update and give it a try.

Workflow_Email_GenDoc_Attachment_Name only applies to workflows, that is why there is no change in the template name

To make the change of the name you have to pass the subject to gendocAction() so you can substitute the crmid in the line you set in red above and then you have to apply this change in the GenDoc module


Code:
diff --git a/modules/evvtgendoc/gendocAction.php b/modules/evvtgendoc/gendocAction.php

index 1b8b841d2..4deec6d04 100644
--- a/modules/evvtgendoc/gendocAction.php
+++ b/modules/evvtgendoc/gendocAction.php
@@ -121,7 +121,7 @@ if ($mergetemplate=='1') {
                                }
                                break;
                        case 'email':
-                               $sname = 'storage/'.$modulei18n.'_'.$record.($format=='doc'?'.odt':'.pdf');
+                               $sname = 'storage/'.$modulei18n.'_'.$einfo[$record].($format=='doc'?'.odt':'.pdf');
                                if (file_exists($sname)) {
                                        unlink($sname);
                                }


you have to be sure to generate the same name in javascript and PHP.

The hard part is getting the information you want in the gendocaction call. I would prefer to use a business map to define how the name should be generated, but that is not a trivial task.

Let me know how it goes
Joe
TSolucio
Reply
#7
(03-21-2021, 12:27 AM)joebordes Wrote: No, you did it correctly, I didn't understand.

I looked into it and remembered that this is how it works. You are sending the email to the account/contact and only that module is supported for merging variables. This comes all the way back from vtiger crm where it was hard to do the merge for other modules. In coreBOS the email module has support for a Merge_Template_With list of IDs that will get their variables merged. So I added the quote (and other inventory modules) to that variable and it seems to be working. Update and give it a try.

Workflow_Email_GenDoc_Attachment_Name only applies to workflows, that is why there is no change in the template name

To make the change of the name you have to pass the subject to gendocAction() so you can substitute the crmid in the line you set in red above and then you have to apply this change in the GenDoc module




Code:
diff --git a/modules/evvtgendoc/gendocAction.php b/modules/evvtgendoc/gendocAction.php

index 1b8b841d2..4deec6d04 100644
--- a/modules/evvtgendoc/gendocAction.php
+++ b/modules/evvtgendoc/gendocAction.php
@@ -121,7 +121,7 @@ if ($mergetemplate=='1') {
                                }
                                break;
                        case 'email':
-                               $sname = 'storage/'.$modulei18n.'_'.$record.($format=='doc'?'.odt':'.pdf');
+                               $sname = 'storage/'.$modulei18n.'_'.$einfo[$record].($format=='doc'?'.odt':'.pdf');
                                if (file_exists($sname)) {
                                        unlink($sname);
                                }


you have to be sure to generate the same name in javascript and PHP.

The hard part is getting the information you want in the gendocaction call. I would prefer to use a business map to define how the name should be generated, but that is not a trivial task.

Let me know how it goes

Hello, sorry for the delay.
I can confirm that fields from inventory modules are available for the template. I have a further question: how do I apply a default e-mail template when generating e-mails with gendoc widget? I tried the GV Users_Default_Send_Email_Template but it does not load the specified template, user has to select it.

For the name of the attachment i don't know how to get it. I tried to include something like this:


Code:
var nm1 = document.getElementById('mouseArea_quote_no').value;
var emailurl = 'index.php?module=Emails&action=EmailsAjax&file=EditView&attachment='+nm1+'_'+i18n+'_'+crmid+'.'+(format=='pdf' ? 'pdf' : 'odt');
in evvtgendoc.js function gendocAction case 'email' but it does not fill nm1 variable, the result is populated with 'unspecified' in nm1 place.
Reply
#8
I fixed the default template in inventory emails, update and give it a try.

as to the gendoc name, as I said above it is non-trivial, send me an email and I will get it done for you
Joe
TSolucio
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)