How to add country selection field to Jira? - jira

How can I add a country selection field to Jira?

I've posted the the answer hoping it will help others, as well as hearing your thought on it..
Add a test field and get it's ID, for example let's say it's "customfield_11111". Than add it the following description:
<script src="https://jira.com/getCountrySelect.js">
</script>
You can write the code directory in the description, but I found it easier to backup and update the scripts this way. Then, in you app-data folder create the file getCountrySelect.js (replace the fieldID with your filed id):
var fieldId = "customfield_11111";
AJS.$(document).ready(function() {
var country = AJS.$("#" + fieldId).val();
AJS.$("#" + fieldId).parent().append("<select class='select' id='" + fieldId + "' name='" + fieldId + "'></select>");
var select = AJS.$("select#" + fieldId);
select.append("<option>Afghanistan</option>");
select.append("<option>Albania</option>");
select.append("<option>Algeria</option>");
select.append("<option>Andorra</option>");
select.append("<option>Angola</option>");
select.append("<option>Antigua & Deps</option>");
select.append("<option>Argentina</option>");
select.append("<option>Armenia</option>");
select.append("<option>Australia</option>");
select.append("<option>Austria</option>");
select.append("<option>Azerbaijan</option>");
select.append("<option>Bahamas</option>");
select.append("<option>Bahrain</option>");
select.append("<option>Bangladesh</option>");
select.append("<option>Barbados</option>");
select.append("<option>Belarus</option>");
select.append("<option>Belgium</option>");
select.append("<option>Belize</option>");
select.append("<option>Benin</option>");
select.append("<option>Bhutan</option>");
select.append("<option>Bolivia</option>");
select.append("<option>Bosnia Herzegovina</option>");
select.append("<option>Botswana</option>");
select.append("<option>Brazil</option>");
select.append("<option>Brunei</option>");
select.append("<option>Bulgaria</option>");
select.append("<option>Burkina</option>");
select.append("<option>Burundi</option>");
select.append("<option>Cambodia</option>");
select.append("<option>Cameroon</option>");
select.append("<option>Canada</option>");
select.append("<option>Cape Verde</option>");
select.append("<option>Central African Rep</option>");
select.append("<option>Chad</option>");
select.append("<option>Chile</option>");
select.append("<option>China</option>");
select.append("<option>Colombia</option>");
select.append("<option>Comoros</option>");
select.append("<option>Congo</option>");
select.append("<option>Congo {Democratic Rep}</option>");
select.append("<option>Costa Rica</option>");
select.append("<option>Croatia</option>");
select.append("<option>Cuba</option>");
select.append("<option>Cyprus</option>");
select.append("<option>Czech Republic</option>");
select.append("<option>Denmark</option>");
select.append("<option>Djibouti</option>");
select.append("<option>Dominica</option>");
select.append("<option>Dominican Republic</option>");
select.append("<option>East Timor</option>");
select.append("<option>Ecuador</option>");
select.append("<option>Egypt</option>");
select.append("<option>El Salvador</option>");
select.append("<option>Equatorial Guinea</option>");
select.append("<option>Eritrea</option>");
select.append("<option>Estonia</option>");
select.append("<option>Ethiopia</option>");
select.append("<option>Fiji</option>");
select.append("<option>Finland</option>");
select.append("<option>France</option>");
select.append("<option>Gabon</option>");
select.append("<option>Gambia</option>");
select.append("<option>Georgia</option>");
select.append("<option>Germany</option>");
select.append("<option>Ghana</option>");
select.append("<option>Greece</option>");
select.append("<option>Grenada</option>");
select.append("<option>Guatemala</option>");
select.append("<option>Guinea</option>");
select.append("<option>Guinea-Bissau</option>");
select.append("<option>Guyana</option>");
select.append("<option>Haiti</option>");
select.append("<option>Honduras</option>");
select.append("<option>Hungary</option>");
select.append("<option>Iceland</option>");
select.append("<option>India</option>");
select.append("<option>Indonesia</option>");
select.append("<option>Iran</option>");
select.append("<option>Iraq</option>");
select.append("<option>Ireland {Republic}</option>");
select.append("<option>Israel</option>");
select.append("<option>Italy</option>");
select.append("<option>Ivory Coast</option>");
select.append("<option>Jamaica</option>");
select.append("<option>Japan</option>");
select.append("<option>Jordan</option>");
select.append("<option>Kazakhstan</option>");
select.append("<option>Kenya</option>");
select.append("<option>Kiribati</option>");
select.append("<option>Korea North</option>");
select.append("<option>Korea South</option>");
select.append("<option>Kosovo</option>");
select.append("<option>Kuwait</option>");
select.append("<option>Kyrgyzstan</option>");
select.append("<option>Laos</option>");
select.append("<option>Latvia</option>");
select.append("<option>Lebanon</option>");
select.append("<option>Lesotho</option>");
select.append("<option>Liberia</option>");
select.append("<option>Libya</option>");
select.append("<option>Liechtenstein</option>");
select.append("<option>Lithuania</option>");
select.append("<option>Luxembourg</option>");
select.append("<option>Macedonia</option>");
select.append("<option>Madagascar</option>");
select.append("<option>Malawi</option>");
select.append("<option>Malaysia</option>");
select.append("<option>Maldives</option>");
select.append("<option>Mali</option>");
select.append("<option>Malta</option>");
select.append("<option>Marshall Islands</option>");
select.append("<option>Mauritania</option>");
select.append("<option>Mauritius</option>");
select.append("<option>Mexico</option>");
select.append("<option>Micronesia</option>");
select.append("<option>Moldova</option>");
select.append("<option>Monaco</option>");
select.append("<option>Mongolia</option>");
select.append("<option>Montenegro</option>");
select.append("<option>Morocco</option>");
select.append("<option>Mozambique</option>");
select.append("<option>Myanmar, {Burma}</option>");
select.append("<option>Namibia</option>");
select.append("<option>Nauru</option>");
select.append("<option>Nepal</option>");
select.append("<option>Netherlands</option>");
select.append("<option>New Zealand</option>");
select.append("<option>Nicaragua</option>");
select.append("<option>Niger</option>");
select.append("<option>Nigeria</option>");
select.append("<option>Norway</option>");
select.append("<option>Oman</option>");
select.append("<option>Pakistan</option>");
select.append("<option>Palau</option>");
select.append("<option>Panama</option>");
select.append("<option>Papua New Guinea</option>");
select.append("<option>Paraguay</option>");
select.append("<option>Peru</option>");
select.append("<option>Philippines</option>");
select.append("<option>Poland</option>");
select.append("<option>Portugal</option>");
select.append("<option>Qatar</option>");
select.append("<option>Romania</option>");
select.append("<option>Russian Federation</option>");
select.append("<option>Rwanda</option>");
select.append("<option>St Kitts & Nevis</option>");
select.append("<option>St Lucia</option>");
select.append("<option>Saint Vincent & the Grenadines</option>");
select.append("<option>Samoa</option>");
select.append("<option>San Marino</option>");
select.append("<option>Sao Tome & Principe</option>");
select.append("<option>Saudi Arabia</option>");
select.append("<option>Senegal</option>");
select.append("<option>Serbia</option>");
select.append("<option>Seychelles</option>");
select.append("<option>Sierra Leone</option>");
select.append("<option>Singapore</option>");
select.append("<option>Slovakia</option>");
select.append("<option>Slovenia</option>");
select.append("<option>Solomon Islands</option>");
select.append("<option>Somalia</option>");
select.append("<option>South Africa</option>");
select.append("<option>Spain</option>");
select.append("<option>Sri Lanka</option>");
select.append("<option>Sudan</option>");
select.append("<option>Suriname</option>");
select.append("<option>Swaziland</option>");
select.append("<option>Sweden</option>");
select.append("<option>Switzerland</option>");
select.append("<option>Syria</option>");
select.append("<option>Taiwan</option>");
select.append("<option>Tajikistan</option>");
select.append("<option>Tanzania</option>");
select.append("<option>Thailand</option>");
select.append("<option>Togo</option>");
select.append("<option>Tonga</option>");
select.append("<option>Trinidad & Tobago</option>");
select.append("<option>Tunisia</option>");
select.append("<option>Turkey</option>");
select.append("<option>Turkmenistan</option>");
select.append("<option>Tuvalu</option>");
select.append("<option>Uganda</option>");
select.append("<option>Ukraine</option>");
select.append("<option>United Arab Emirates</option>");
select.append("<option>United Kingdom</option>");
select.append("<option>United States</option>");
select.append("<option>Uruguay</option>");
select.append("<option>Uzbekistan</option>");
select.append("<option>Vanuatu</option>");
select.append("<option>Vatican City</option>");
select.append("<option>Venezuela</option>");
select.append("<option>Vietnam</option>");
select.append("<option>Yemen</option>");
select.append("<option>Zambia</option>");
select.append("<option>Zimbabwe</option>");
AJS.$("input#" + fieldId).remove();
AJS.$('#' + fieldId + ' option:contains('+country+')').attr('selected', 'selected');
});
Hope it will help you too :)

Related

Auto Email Google Form Submissions based on Keywords in a String Cell Value

I'm receiving a gmail from the below code, but NOT the form values that I want to be included. I'm trying have a Google Form (Sheet) send an email to me (a teacher) when a student would type an important or alarming keyword in one of the form's fields (col J).
Picture a Google form with essentially the following fields:
A - Date/time stamp
B - email address collection
C - Name (short answer text)
D - what did you learn or work on yesterday? (long answer text)
E - How are you generally feeling today? (multiple choice)
F - Are you tired today? (multiple choice)
G - Are you stressed out today? (multiple choice)
H - What have you going on today? (bunch of checkboxes)
I - What could be "cool" or "good" about today? (long answer text)
J - (optional) Feel free to tell me anything more (long answer text)
If the student types any alert words, like "die" or "drugs" and so on in the last column (column J), I'd like to get a gmail with a summary of all the info on the row. So far, I've set up a trigger and am only getting a gmail with a subject and message, but the message DOES NOT contain the concatenated vars values.
ALSO, the gmail's subject DOES NOT contain the concatenated studname, which would be helpful. I'm curious how you'd fix this code.
THANK YOU!!
function checkComments(){
var commentsRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet2").getRange("J2");
var sheet = SpreadsheetApp.getActive().getSheetByName("Sheet2");
var lastrow = sheet.getLastRow();
var comments = sheet.getRange('J' + lastrow).getValue();
if (comments === '.*drug.*'||'.*die.*'||'.*emotion.*'||'.*suicide.*'||) //many more root key words will be added in here in this |OR| format
{
// Send Alert Email.
var timestamp = sheet.getRange('A' + lastrow).getValue();
var studname = sheet.getRange('C' + lastrow).getValue();
var studemail = sheet.getRange('B' + lastrow).getValue();
var feelings= sheet.getRange('E' + lastrow).getValue();
var tired= sheet.getRange('F' + lastrow).getValue();
var stressed= sheet.getRange('G' + lastrow).getValue();
var studwork = sheet.getRange('H' + lastrow).getValue();
var cool = sheet.getRange('I' + lastrow).getValue();
var results = timestamp + ' \n ' + studname + ' \n ' + studemail + ' \n ' + feelings + ' \n ' + tired + ' \n ' + stressed + ' \n ' + studwork + ' \n ' + cool + ' \n ' + comments;
var emailAddress = 'my email address';
var message = 'Alert from the daily survey!\n' + results;
var subject = 'Daily Survey Alert from ' + studname;
MailApp.sendEmail(emailAddress, subject, message);
}
}```
To match a keyword, replace the
if (comments === '.*drug.*'||'.*die.*'||'.*emotion.*'||'.*suicide.*'||)
with
if(!!comments.match(/drug|die|emotion|suicide/))
I've fixed a bit your code and it seems work for me:
function checkComments() {
var sheet = SpreadsheetApp.getSheetByName('Sheet2');
var lastRow = sheet.getLastRow();
// it works faster when you grab all the row at once
var row = sheet.getRange('A'+lastRow+':J'+lastRow).getValues().flat();
var comments = row[9];
var words = ['drug','die','emotion','suicide'];
if (words.filter(w => comments.includes(w)).length == 0) return;
var emailAddress = 'your#mail.com';
var subject = row[2];
var message = row.join('\n');
MailApp.sendEmail(emailAddress, subject, message);
}
Probably it makes sense to use RegEx to search these words in comments. But I'm not sure if you're ready to dive so deep.

export datagridview to txt with vb6.0

I would like to ask how to export datagridview from vb6.0 to .txt format? I write this code to view the content of table to datagridview
Call Buka
koneksi.CursorLocation = adUseClient
rsDTS.Open "select * from TBL_DTSHEET where KDKRY = '" & txtKdKry.Text & "' and (TGLWORK between '" & Format(dtAwal.Value, "mm/dd/yyyy") & "' and '" & Format(dtAkhir.Value, "mm/dd/yyyy") & "')", koneksi
With rsDTS
If Not (.BOF And .EOF) Then
mvBookmark = .Bookmark
End If
End With
Set DataGrid1.DataSource = rsDTS.DataSource
And now I wonder how can I export this datagridview into a file with format .txt?
anyone can help?
thanks
I think I can solved my own problem by adding some code like this
Open "D:\textfile.txt" For Output As #1
Do While rsDTS.EOF = False
Print #1, rsDTS.Fields("KDDTS").Value & ", " & rsDTS.Fields("KDHDTS").Value & ", " & rsDTS.Fields("TGLWORK").Value
rsDTS.MoveNext
Loop
Close #1
Hope this can help others

Retain message formatting from Google Spreadsheet email script

We are using a Google Spreadsheet script to send us reformatted email.
Problem: We are wondering if there is a way to retain minimal formatting such as line breaks for the "strEnquirerMessage" cell for the following script.
I have tried including htmlBody somehow but no luck so far. Any help is greatly appreciated. Thank you.
User emails this message in contact form:
Line 1
Line 2
Line 3
We currently receive this in the email from this script: Line 1 Line 2 Line 3
Goal is to receive this:
Line 1
Line 2
Line 3
var strEnquirerName = values[row][1];
var strEnquirerEmail = values[row][2];
var strEnquirerAddress = values[row][3];
var strTopic = values[row][4];
var strEnquirerProducts = values[row][5];
var strEnquirerMessage = values[row][6];
var strMessageBody = "<b>NAME:</b> " + strEnquirerName +
"<br/><br/><b>EMAIL:</b> " + strEnquirerEmail +
"<br/><br/><b>ADDRESS:</b> " + strEnquirerAddress +
"<br/><br/><b>TOPIC:</b> " + strTopic +
"<br/><br/><b>PRODUCTS:</b> " + strEnquirerProducts +
"<br/><br/><b>MESSAGE:</b> " + strEnquirerMessage;
MailApp.sendEmail("your#emailaddress.com", strEnquirerEmail, " Contact form from " + strEnquirerName + " - " + strEnquirerEmail + " Re: " + strTopic, strMessageBody);
Thanks to this post, I have found the answer. Below is the updated line from the above code:
var strEnquirerMessage = values[row][6].replace(/\n/g, '<br>');
Beside the cell value is code to replace Google Spreadsheet's new line character with a line break. Hope this helps others.

smaller & nicer select with bootstrap.css

Of course I know that SELECT form elements are hard to style and/or modify beyond the basics.
Just out of curiosity, does anyone know of a one-off bootstrap (the one from twitter) solution that would allow me to affect the size of the SELECT and perhaps even apply a gradient that looks more like a bootstrap button (than the scratchy surface they have now).
I don't mind noodling around with the CSS myself, but I thought I'd ask around before re-inventing the wheel.
Any pointers, links or suggestions would be greatly appreciated.
You can use the jQuery plugin bootstrap-select:
https://developer.snapappointments.com/bootstrap-select/
It will turn your select into a bootstrap button dropdown
A bit late but maybe this can help http://blog.iamjamoy.com/docs/select.html
or this http://ivaynberg.github.com/select2/
The first one doesn´t work on IE, if you can fix it please provide.
jQuery(function($){
$('select').each(function(i, e){
if (!($(e).data('convert') == 'no')) {
//$(e).hide().wrap('<div class="btn-group" id="select-group-' + i + '" />');
$(e).after('<div class="btn-group" id="select-group-' + i + '" />');
var select = $('#select-group-' + i);
var current = ($(e).val()) ? $(e).val(): ' ';
select.html('<input type="hidden" value="' + $(e).val() + '" name="' + $(e).attr('name') + '" id="' + $(e).attr('id') + '" class="' + $(e).attr('class') + '" /><a class="btn" href="javascript:;">' + current + '</a><a class="btn dropdown-toggle" data-toggle="dropdown" href="javascript:;"><span class="caret"></span></a><ul class="dropdown-menu"></ul>');
$(e).find('option').each(function(o,q) {
select.find('.dropdown-menu').append('<li>' + $(q).text() + '</li>');
if ($(q).attr('selected')) select.find('.dropdown-menu li:eq(' + o + ')').click();
});
select.find('.dropdown-menu a').click(function() {
select.find('input[type=hidden]').val($(this).data('value')).change();
select.find('.btn:eq(0)').text($(this).text());
});
$(e).remove();
}
});
});

JQUERY call to Controller Action: String Parameter truncated if containing 'space' character

I have a view that accepts 2 string parameters and 2 date values. User hits search button and they get filtered output to the screen. This all works perfectly well until a user inputs a string with a space. i.e. they can search for 'waste' but not 'waste oil'.
Interestingly, in the latter, the parameter is ok from Javascript before the call is made. But on entering the controller code it goes form being 'waste oil' on client to 'waste'. When this happens the other parameters get set to NULL crashing the system.
I've tried replacing the spaces if present with '#' character then stripping out and putting back in ' ' on the controller side. This is a messy fudge and only appears to work with one parameter.
There must be a simple explanation for this parameter data loss, any comments much appreciated
Not sure a code example is needed but here it is anyway if it help:
My controller header :
public ActionResult IndexSearch(int? page, string searchText,string searchTextSite,string StartDate,string EndDate)
{
My HTML Javascript :
function Search(sSearchText,sSite) {
sSearchText = sSearchText.toString().replace(" ", "#");
sSite = sSite.toString().replace(" ", "#");
debugger;
alert($("#AbsolutePath").val() + "Waste.mvc/IndexSearch?searchText=" + sSearchText + "&searchTextSite=" + sSite + "&StartDate=" + $('#StartDate').val() + "&EndDate=" + $('#EndDate').val());
$("#ResultsList").load($("#AbsolutePath").val() + "Waste.mvc/IndexSearch?searchText=" + sSearchText + "&searchTextSite=" + sSite + "&StartDate=" + $('#StartDate').val() + "&EndDate=" + $('#EndDate').val(),
function() {
$('#LoadingGif').empty();
});
$('#LoadingGif').empty().html('<img src="' + $("#AbsolutePath").val() + 'Content/images/ajax-loader.gif" alt="Loading image" />');
}
You are not URL encoding your parameters when sending the AJAX request because you are using string concatenations when building the url. You could use the following technique in order to have properly encoded values:
var url = $('#AbsolutePath').val() + 'Waste.mvc/IndexSearch';
var data = {
searchText: sSearchText,
searchTextSite: sSite ,
StartDate: $('#StartDate').val(),
EndDate: $('#EndDate').val()
};
$('#ResultsList').load(url, data, function() {
$('#LoadingGif').empty();
});
Now you will get correct values on the server.

Resources