Create mail replies from FlowerDocs
Displaying content creation action on task attachments
To begin with, we will simply configure the plugin to allow us to view the metadata of each attachment to a GEC_Step2_ToBeProcessed
class task.
Add the following script:
new CreateHTMLAttachmentPlugin({
classId: ‘GEC_Step2_ToBeProcessed'
}).bind();
Restricting response attachments
We want to restrict the display of the action to the attachment identified as Response
, for which the attachmentId
option is available.
Add the following option to the plugin script:
We therefore obtain the following script:
Instantiating the document in FlowerDocs
We now have an action in the Response
attachment that opens the content editor in an OffMenu. Now we need to be able to save the content created in a document of the OutgoingMail
class
To do this, we will add the instantiator
option to index the component as required. Without this configuration, the document will be created with the default class, i.e. Document
.
The TagOracle.predict
method is used to harness tags shared by the task and the document.
Instantiating an OutgoingMail
class document
new CreateHTMLAttachmentPlugin({
attachmentId: ‘Response',
classId: 'GEC_Step2_ATraiter',
instantiator:
function(file) {
var doc = new Document();
//The document created will be named in the same way as its contents
doc.setName(file.Name);
// Adding content to the document
doc.addFile(file.id);
doc.setClassId('CourrierSortant');
; /harnessing the tags of the document to be created using data from the open task
TagOracle.predict(this.formAPI.getComponent(), doc);
return doc;}
}).bind();
Displaying the action according to context
The action is only displayed if the attachment is not already associated with a document. You can further restrict the action display according to context. In our example, we want the action to be displayed only if the task is assigned to the user. To do this, we’ll add the canAttach
option to our plugin.
Restricting action display to the user assigned to the task
new CreateHTMLAttachmentPlugin({
attachmentId: ‘Response',
classId: 'GEC_Step2_ATraiter',
instantiator:
function(file) {
var doc = new Document();
//The document created will be named in the same way as its contents
doc.setName(file.Name);
// Adding content to the document
doc.addFile(file.id);
doc.setClassId('CourrierSortant');
; /harnessing the tags of the document to be created using data from the open task
TagOracle.predict(this.formAPI.getComponent(), doc);
return doc;},
canAttach:
function(card, definition, formAPI) {
return formAPI.getComponent().getAssignee() == JSAPI.get().getUserAPI().getId();
}
}).bind();
To go further: customize your action
Now we want to customize the content creation action. We are going to add options for customizing the action title and icon to our script:
With this script, the content creation action is fully customized:
Personalizing the content creation action
new CreateHTMLAttachmentPlugin({
attachmentId: ‘Response',
classId: 'GEC_Step2_ATraiter',
instantiator:
function(file) {
var doc = new Document();
//The document created will be named in the same way as its contents
doc.setName(file.Name);
// Adding content to the document
doc.addFile(file.id);
doc.setClassId('CourrierSortant');
; /harnessing the tags of the document to be created using data from the open task
TagOracle.predict(this.formAPI.getComponent(), doc);
return doc;},
canAttach:
function(card, definition, formAPI) {
return formAPI.getComponent().getAssignee() == JSAPI.get().getUserAPI().getId();
},
title: 'Writing an reply',
icon:'fa-reply'
}).bind();