Snippet Placeholder for First Name - FogBugz Knowledge Exchange most recent 30 from http://fogbugz.stackexchange.com 2013-05-22T17:11:47Z http://fogbugz.stackexchange.com/feeds/question/6167 http://www.creativecommons.org/licenses/by-nc/2.5/rdf http://fogbugz.stackexchange.com/questions/6167/snippet-placeholder-for-first-name Snippet Placeholder for First Name Jules 2010-12-03T02:03:02Z 2013-01-15T22:23:30Z <p>Every email reply begins with:</p> <p><code>Hello Sarah,</code></p> <p>Is there a snippet placeholder which would allow this? i.e.</p> <p><code>Hello {firstname},</code></p> <p>Browsing the questions here, it seems that there are undocumented snippets available.</p> <p>I'm using FB on demand.</p> http://fogbugz.stackexchange.com/questions/6167/snippet-placeholder-for-first-name/6171#6171 Answer by Michel de Ruiter for Snippet Placeholder for First Name Michel de Ruiter 2010-12-03T13:51:48Z 2010-12-03T13:51:48Z <p>I think these are all available placeholders:</p> <pre><code>case ID: {case} message subject: {subject} FogBugz URL: {url} external ticket: {ticket} single case ticket: {ticket_singlecase} external link: {ticketurl} single case link: {ticketurl_singlecase} sender email: {sender} my name: {username} my email: {useremail} mailbox name: {fullname} (empty in snippets) mailbox email: {email} (empty in snippets) </code></pre> <p>See also <a href="http://fogbugz.stackexchange.com/questions/1755/is-there-a-complete-list-of-snippet-expansions-and-prerequisites" rel="nofollow">this question</a>.</p> <p>What undocumented snippets do you refer to?</p> <p>Maybe you could use BugMonkey to hack something around {sender}...</p> http://fogbugz.stackexchange.com/questions/6167/snippet-placeholder-for-first-name/6174#6174 Answer by Rich Armstrong for Snippet Placeholder for First Name Rich Armstrong 2010-12-03T14:34:03Z 2013-01-15T22:23:30Z <p>Here's my custom placeholders BugMonkey script:</p> <pre><code>name: Custom Placeholders description: Adds some helpful values to the rgPlaceholders list. author: Rich Armstrong version: 1.0.0.4 js: $(function(){ // if we're not on the case page, don't do anything if (!$('#bugviewContainer').length) return; /* To Title Case 1.1.1 * David Gouch &lt;http://individed.com&gt; * 23 May 2008 * License: http://individed.com/code/to-title-case/license.txt * * In response to John Gruber's call for a Javascript version of his script: * http://daringfireball.net/2008/05/title_case */ String.prototype.toTitleCase = function() { return this.replace(/([\w&amp;`'‘’"“.@:\/\{\(\[&lt;&gt;_]+-? *)/g, function(match, p1, index, title) { if (index &gt; 0 &amp;&amp; title.charAt(index - 2) !== ":" &amp;&amp; match.search(/^(a(nd?|s|t)?|b(ut|y)|en|for|i[fn]|o[fnr]|t(he|o)|vs?\.?|via)[ \-]/i) &gt; -1) return match.toLowerCase(); if (title.substring(index - 1, index + 1).search(/['"_{(\[]/) &gt; -1) return match.charAt(0) + match.charAt(1).toUpperCase() + match.substr(2); if (match.substr(1).search(/[A-Z]+|&amp;|[\w]+[._][\w]+/) &gt; -1 || title.substring(index - 1, index + 1).search(/[\])}]/) &gt; -1) return match; return match.charAt(0).toUpperCase() + match.substr(1); }); }; var addCustomPlaceholders = function(){ if (!window.goBug) return; var oMyFirstName = new Object(); oMyFirstName.sPlaceHolder = "{myfirstname}"; var oMyLastName = new Object(); oMyLastName.sPlaceHolder = "{mylastname}"; var oMyName = new Object(); oMyName.sPlaceHolder = "{myname}"; oMyName.sValue = GetFullName(); // this placeholder already exists as {username} // I just did this for consistency. sMyName = GetFullName().match(/(\w+) (\w+)/); if (sMyName[1]) { oMyFirstName.sValue = sMyName[1]; oMyLastName.sValue = sMyName[2]; } rgPlaceHolders.push(oMyFirstName); rgPlaceHolders.push(oMyLastName); if (window['goBug'] != undefined) { if (goBug.sCustomerEmail == "") { return; } var oFirstName = new Object(); oFirstName.sPlaceHolder = "{firstname}"; sFirstName = goBug.sCustomerEmail.match(/^"?(([\w'\-\(\)]+), )?([\w\'\-]+)( [\w'\-\(\)\.]+)*(, [SsJj]r.)?"? &lt;[a-zA-Z0-9._+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}(\.[a-zA-Z]{2,4})?&gt;$/); if (sFirstName) { oFirstName.sValue = sFirstName[3].toTitleCase(); } else { oFirstName.sValue = "[[name]]"; } rgPlaceHolders.push(oFirstName); } } //end function addCustomPlaceholders addCustomPlaceholders(); }); </code></pre> <p>It adds <code>{name}</code>, <code>{myfirstname}</code>, <code>{mylastname}</code>.</p> <p>Notes:</p> <ul> <li>If we don't know the first name, we replace with <code>[[name]]</code> which will be highlighted for you to replace.</li> </ul> <p>Caveats:</p> <ul> <li>Not tested in IE. Works in Chrome and Firefox.</li> <li>Sometimes when we start typing, this script hasn't run yet.</li> <li>Doesn't work with "Last, First" yet.</li> <li>Is broken by names with accents in them.</li> <li>Only works with snippets, not with autoresponses.</li> <li>It pulls from the Correspondent every time. If others chime in, it'll still fill in the correspondent name.</li> </ul>