We have a question for Alfresco 5.2
Using javascript (API) we want to send some emails for a CronJobs that we are developing.
We have seen that if we use "mail.parameters.to_many" we cannot send "CC".
We need to send
To: "email1#xxx.com", "email2#xxx.com"
cc: "email3#xxx.com"
If we use:
mail.parameters.to = "email1#xxx.com"
mail.parameters.cc = "email3#xxx.com"
we correctly receive the "to" and the "CC"
But if we use:
mail.parameters.to_many = ["email1#xxx.com", "email2#xxx.com"]
mail.parameters.cc = "email3#xxx.com"
We received in the "to" "email1#xxx.com", "email2#xxx.com" but "CC" empty.
How can you send multiple emails "to" with "CC"?
Example with "to" and "CC":
var subj= "prueva de multiples";
var mail = actions.create("mail");
mail.parameters.to ="email1#xxx.com";
mail.parameters.cc = "email3#xxx.com";
mail.parameters.subject = subj;
mail.parameters.from = "serverMail.com";
mail.parameters.text = "This test is OK";
mail.executeAsynchronously(node);
(Works correctlym It works fine, but a "to" and a "CC")
Example 2:
var subj= "prueva de multiples";
var mail = actions.create("mail");
var emails = ["email1#xxx.com","email2#xxx.com","email3#xxx.com"];
mail.parameters.to_many = emails;
mail.parameters.cc = ""email4CC#xxx.com";
mail.parameters.subject = subj;
mail.parameters.from = "serverMail.com";
mail.parameters.text = "This test is not Ok";
mail.executeAsynchronously(node);
(Sends the "to_many", but the "CC" does not send it)
We want to send multiple emails in "to" and multiple in "CC".
The most important thing for us is to be able to send one "to" and multiple "CC"
Thanks guys
I looked at the source code for the MailActionExecuter and it looks to me like the CC param is only used if the TO is set (not the TO_MANY):
// set recipient
String to = (String)ruleAction.getParameterValue(PARAM_TO);
String toRecipients = null;
if (to != null && to.length() != 0)
{
messageRef[0].setTo(to);
toRecipients = to;
// Note: there is no validation on the username to check that it actually is an email address.
// TODO Fix this.
Serializable ccValue = (String)ruleAction.getParameterValue(PARAM_CC);
Based on that, I don't think you can use TO_MANY in combination with CC.
You can always just write your own action and have it work exactly like you need it to. You might start with the MailActionExecuter source to save some time.
Related
please dont mind my ignorance. Currently I am a "Make your office life easier DIYer" and I am trying to build a pdf generator using GoogleForms, whereby, I had already successfully ran a script and produced a pdf file from it.
By using GoogleForms, and the answers to the questions are used to fill up a GoogleDoc template where it automatically changes/replaces the specified values in it. However, the dilemma I am having now is how to capture the 'Timestamp' created after submitting the form.
This was the code I am using:
function onFormSubmit(e) {
const info = e.namedValues;
createPDF(info)
}
function createPDF(info){
const pdfFolder = DriveApp.getFolderById("19Mbse07Dh03SXhCMDCuUHwP1oNqfhul_");
const tempFolder = DriveApp.getFolderById("1ye9x0l_izDGku91g4ekxDMH8JDIyxdB1");
const tempDoc = DriveApp.getFileById("1p2nCjS4z_4MEGSud833DBRf9Lcby0zPWT_k3SjLiMoo");
const newTempFile = tempDoc.makeCopy(tempFolder)
const openDoc = DocumentApp.openById(newTempFile.getId());
const body = openDoc.getBody();
body.replaceText("{q3}", info['Timestamp'][0]);
body.replaceText("{q1}", info['1. Description'][0]);
body.replaceText("{q2}", info['2. Description'][0]);
openDoc.saveAndClose();
const blobPDF = newTempFile.getAs(MimeType.PDF);
const pdfFile = pdfFolder.createFile(blobPDF).setName("My PDF")
}
The problem I have now is how to get the 'Timestamp' created after submitting a form.
The form successfully captures the "1. Description' and "2. Description" and changes the form in GoogleDoc template which I used to create the pdfFile.
I had followed the documentation under the "Form Submit", particularly namedValues to try to return the 'Timestamp'
{
'First Name': ['Jane'],
'Timestamp': ['6/7/2015 20:54:13'],
'Last Name': ['Doe']
}
The documentation, mentioned 'Timestamp', however I cannot extract it.
Can anybody help me out on this? I am certain that I am missing something.
To extract the timestamp use e.namedValues["Timestamp"][0], i.e.
var timestamp = e.namedValues["Timestamp"][0];
I suggest you to spend some time learning about data structures in JavaScript (objects, Arrays)
Resources
JavaScript data types and data structures
I'm trying to capture the GCLID and MSCKLID values from the URL, and pass them into the appropriate GF form fields. I found a way to pull them from the url, but I'm running into the DRY thing when trying to pass them into their field values.
Code that pulls them from the URL:
function getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi,
function(m,key,value) {
vars[key] = value;
console.log(value);
});
return vars;
}
var gclid = getUrlVars()["gclid"];
var mscklid = getUrlVars()["mscklid"];
Then this is the way I'm trying to pass them into the field values currently:
var selectorGCLID = "input[name='input_25']";
var selectorMSCKLID = "input[name='input_31']";
var fieldGCLID = document.querySelector(selectorGCLID);
var fieldMSCKLID = document.querySelector(selectorMSCKLID);
if(fieldGCLID) { fieldGCLID.value = gclid; }
if(fieldMSCKLID) { fieldMSCKLID.value = mscklid; }
What's a way where I can just check to see if the field selector is GCLID or MSCKLID, and then pass it to the appropriate field, instead of doing it 1x1 like this?
Can you just use the feature built into Gravity Forms to grab the URL parameter values?
If so, you can just go to the advanced tab of field 25 and click "Allow field to be populated dynamically" and then add: gclid. Go to field 31 and add: mscklid
Was able to capture UTM parameters without any add-on or coding by following these instructions: https://docs.gravityforms.com/using-dynamic-population/.
Added utm_source, utm_medium, utm_campaign as hidden fields and checked "Allow field to be populated dynamically" in the field settings.
On CRM 2013 I'm trying to insert multiple participants into the email "to" field when users click on "Reply All". However I need to remove certain email addresses from the To line. So I created an array to loop and get all the email addresses except the one that needs to be removed.
However the problem here is that it only works if there is only one participant left after removing the unwanted participants. If there are two or more participants the script will not populate any participants at all.
Is there a way to populate multiple email participants? Or is there a better approach than what I'm trying to do here?
Here's my code:
var toParty = Xrm.Page.getAttribute("to").getValue();
var partyListArray = new Array();
for (var indxAttendees = 0; indxAttendees < toParty.length; indxAttendees++) {
// using oData to get participant email address
var email = getParticipantEmail(
toParty[indxAttendees].entityType,
toParty[indxAttendees].id
);
if (email != "test#test.com") {
partyListArray[indxAttendees] = new Object();
partyListArray[indxAttendees].id = toParty[indxAttendees].id;
partyListArray[indxAttendees].name = toParty[indxAttendees].name;
partyListArray[indxAttendees].entityType = toParty[indxAttendees].entityType;
}
}
Xrm.Page.getAttribute("to").setValue(null);
Xrm.Page.getAttribute("to").setValue(partyListArray);
Instead of creating a whole new array, you can delete what you want from the array itself. Try this:
var emails = [{email: "add1#domain.com"}, {email: "add2#domain.com"}, {email: "address#toBe.Removed"}, {email: "add3#domain.com"}, {email: "add4#domain.com"}];
var removeIndex = emails.map(function(item) { return item.email; }).indexOf("address#toBe.Removed");
removeIndex > -1 && emails.splice(removeIndex, 1);
I am trying to have a drop down form that is populated with contacts populate a text box that contains the company information and address of that contact.
I have a small amount of knowledge in Javascript and have tried the following code:
var one = this.getField("Contact");
var two = this.getField("Company");
if (one.value == 'John Doe') {
two.value = 'Company1';
} else if (one.value == 'Jane Doe') {
two.value = 'Company2';
}
Is there anyone that can point me in the right direction? I have looked for similar questions but none I could find offered a solution for this specific issue.
Bluebeam is a relatively smart PDF viewer, and it should be possible to do some JavaScripting. You'd have to check whether it works, however; I don't have access to Bluebeam, and can not test it myself). A possible solution would look like this:
a) you create a document-level JavaScript which contains an array of the contact info (which may contain more than just the company name, but also address etc.. This array could look like this:
var contarr = new Array() ;
contarr[0] = ["Contact Person", "Company", "Address", "City", "State", "Zip"] ;
contarr[1] = ["John Doe", "Does and Donz", "Main Street", "Doetown", "TX", "99999"]
// and so on
b) In your Dropdown, you add the contact person name, and as return value, you add the index number of its entry in the contarr array. Let's assume we call the dropdown "Contact".
c) In an independent text field, you add the following Calculation script:
var sele = this.getField("Contact").value ;
this.getField("Company").value = contarr[sele][1] ;
this.getField("Address").value = contarr[sele][2] ;
this.getField("City").value = contarr[sele][3] ;
this.getField("State").value = contarr[sele][4] ;
this.getField("Zip").value = contarr[sele][5] ;
If everything is set up correctly, and you reopened the document, you should be able to select a contact, and the rest of the information would fill the according fields.
I'm stuck on this web form after submitting. The below code worked in a previous web form I created with the help of Serge and a few others here some time ago. I'm attempting to re-purpose the code to make a PTO request web form. Right now, when submitting it spits out a "unexpected error encountered error and I'm lost on attempting to locate the issue. I'm thinking it may be how I've added panels together and their relationship? This is a work in progress, so i know clickhandlers will be added to provide response after submit etc. At the moment I'm looking to make sure it's passing entries in form to the spreadsheet. Thanks for any assistance.
//Setting the spreadshet ID and style of the form
var submissionSSkey = 'PUT YOUR KEY HERE'
var PanelStyle = {'background':'#c0d6e4','padding':'40px','borderStyle':'ridge','borderWidth':'15PX','borderColor':'#31698a'}
// Script-as-app template.
function doGet(e) {
//Creating the Appplication
var app = UiApp.createApplication();
//Creating panels to house the web form, instructional text, data pickers and setting style
var vertPanel = app.createVerticalPanel().setTitle('XYX Company PTO Request Form').setStyleAttributes(PanelStyle).setPixelSize(350,250);
var mainPanel = app.createFormPanel().setPixelSize(350,150);
var grid = app.createGrid(4,4).setId('ptogrid');
var ptoStart = app.createDateBox().setWidth('200').setName('ptoStartDate');
var ptoEnd = app.createDateBox().setWidth('200').setName('ptoEndDate');
var submitButton = app.createSubmitButton('<B>Submit</B>');
//Assigning widgets to the grid for positioning
grid.setText(1, 0, 'PTO Start Date')
.setWidget(1, 1, ptoStart)
.setText(2, 0, "PTO End Date")
.setWidget(2, 1, ptoEnd)
.setText(3, 0, '')
.setWidget(3, 1, submitButton)
//Instructions for completion of the PTO form by users.
vertPanel.add(app.createHTML("<b>PTO Request Form</b>"));
vertPanel.add(mainPanel);
vertPanel.add(app.createHTML("<br><b>Instructions:</b></br>" +
"<p>Select the starting date and the ending date for your PTO request. "+
"If you are taking a single day of PTO enter the starting and ending date as the same date. "+
"Click Submit once you've enter the dates. A request will be sent to your manager for reivew / approval.</p>"));
//Grabbing active users session information in order to look up user group assignment and manager
var employee = Session.getActiveUser().getEmail();
//Uses the UserManager class to get info by passing in the getActive user from base class
var userFirst = UserManager.getUser(Session.getActiveUser()).getGivenName();
var userLast = UserManager.getUser(Session.getActiveUser()).getFamilyName();
var wholeName = userFirst +" "+ userLast;
mainPanel.add(grid);
app.add(vertPanel);
return app;
}
function doPost(e) {
var app = UiApp.getActiveApplication();
var ptoStart = e.parameter.ptoStartDate;
var ptoEnd = e.parameter.ptoEndDate;
//var wholeName = e.parameter;
var timeStamp = new Date();
//Access spreadsheet store values
var sheet = SpreadsheetApp.openById(submissionSSkey).getSheetByName('PTO Requests');
var lastRow = sheet.getLastRow();
var targetRange = sheet.getRange(lastRow+1, 1, 1, 11).setValues([[timeStamp,ptoStart,ptoEnd]]);
app.close();
return app;
}
I'm pretty sure the error comes from the spreadsheet ID, the sheet name or the range definition, please double check these parameters and see if it solves the issue.
I checked on my account with wrong values and it generated the same issue you have, it works as expected with correct values.
Edit: your comment seems to confirm that...( didn't see it when I answered...)
Note: the error was easy to find by looking at the execution transcript in the script editor UI, it would even give you the line of code where the error occured.