Example script for showing Mail Envelope based on User’s Role
The option to “Submit as Email” doesn’t include the form in the body of the mail, so here’s another way to encourage your form-fillers to send their forms as email and include that body.
This script could be used in a Blogger form to turn on the Mail Envelope when the user switches to the “Email” view. That event could be triggered by the form-filler using the View menu, or even by a Rule on a button. It also makes some decisions based on the user’s current role so you can see how to do that.
function XDocument::OnSwitchView(eventObj) {
var mail = XDocument.View.Window.MailEnvelope;
if (XDocument.View.Name == "Email") {
// get nodes from DOM
var blog = XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/d:blog");
var id = blog.selectSingleNode("@ID");
var title = blog.selectSingleNode("@Title");
var blogger = blog.selectSingleNode("@BloggerName");
var replies = blog.selectNodes("d:reply/@ReplyName");
// Set To field to include blog and the original blogger
mail.To = "blog; " + blogger.text;
// Set CC field to include all the replies (minus the current one)
if (replies != null) {
var cc = "";
for (var i = 0; i < replies.length - 1; i++) {
cc += replies(i).text + "; ";
}
mail.CC = cc;
}
// Set subject to look like a thread
var subject = "Blog " + id.text + " - " + title.text;
if (XDocument.Role != "Create")
subject = "RE: " + subject;
mail.Subject = subject;
// Show the mail envelope
mail.Visible = true;
}
else {
mail.Visible = false;
}
Comments
- Anonymous
June 12, 2009
PingBack from http://besteyecreamsite.info/story.php?id=1741