Making Script Quicker/more efficient - google-apps-script

I am attempting to have a script check sheet1 for first and last names (2 cells), use the first and last name of each person in sheet1, then in sheet2 check each person for a value in 4-5 rows greater than 0.
The issue is that certain names are in different columns and I need to check one column and have those names in that one column checked against a large (180 cells) list of names. This is the part where it times out.
I have the code fully functioning and working, but it uses some parts too heavily and ends up timing out. The getvalue function is used heavily and I am unsure of a better way to use it. I am looking for how to make it more efficient and or run better.
I may just have to input the names in the code to make it faster, but I was hoping for a more user-friendly approach so that names could change in sheet1 and format automatically in the script.
Thank you!
function getvalue(CellName) {
return SpreadsheetApp.getActiveSpreadsheet().getSheetByName('sheet2').getRange(CellName).getValues();
}
function getAdvisee(CellName) {
return SpreadsheetApp.getActiveSpreadsheet().getSheetByName('sheet1').getRange(CellName).getValues();
}
function teacher1() {
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('sheet1');
var LastRow = ss.getLastRow();
var columns = 3;
var columnassignments = 3;
var columnEnrichment = 3;
var columnAmount = 3;
var advisoryStudent = getvalue('a' + columnEnrichment);
var studentEnrichment = getvalue('g'+ columnEnrichment);
var hours = Utilities.formatDate(studentEnrichment, 'EST', 'mm');
var minutes = Utilities.formatDate(studentEnrichment, 'EST', 'ss');
var teacherEmail = getAdvisee('b2');
var student1 = getAdvisee('b3');
var student1F = getAdvisee('b3');
var student2 = getAdvisee('b4');
var student2F = getAdvisee('b4');
var student3 = getAdvisee('b5');
var student3F = getAdvisee('b5');
var student4 = getAdvisee('b6');
var student4F = getAdvisee('b6');
var student5 = getAdvisee('b7');
var student5F = getAdvisee('b7');
var student6 = getAdvisee('b8');
var student6F = getAdvisee('b8');
var student7 = getAdvisee('b9');
var student7F = getAdvisee('c9');
var student8 = getAdvisee('b10');
var student8F = getAdvisee('c10');
var student9 = getAdvisee('b11');
var student9F = getAdvisee('c11');
var student10 = getAdvisee('b12');
var student10F = getAdvisee('c12');
var student11 = getAdvisee('b13');
var student11F = getAdvisee('c13');
for (columns; columns <= LastRow && columns <= 160; columns++) {
var advisoryStudent = getvalue('a' + columns);
var advisoryStudentSp = getvalue('b' + columns);
var reminderCount = getvalue('e' + columns);
var reminderLink = getvalue('m'+columns);
if (advisoryStudentSp == student1F || advisoryStudent == student2 && advisoryStudentSp == student2F || advisoryStudentSp == student3F || advisoryStudentSp == student4F || advisoryStudentSp == student5F || advisoryStudentSp == student6F || advisoryStudentSp == student7F && advisoryStudent == student7 || advisoryStudentSp == student8F || advisoryStudent == student9 && advisoryStudentSp == student9F|| advisoryStudent == student10 && advisoryStudentSp == student10F || advisoryStudent == student11 && advisoryStudentSp == student11F) {
if ( getvalue('e' + columns) > 0 ) {
reminders = reminders + getvalue('b' + columns) + ' ' + getvalue('a' + columns) + ': ' + reminderCount + '<br>Reminder Link: ' + reminderLink + '<br>';
}
}
}
for (columnassignments; columnassignments <= LastRow && columnassignments <= 160; columnassignments++) {
var advisoryStudent = getvalue('a' + columnassignments);
var advisoryStudentSp = getvalue('b'+columnassignments);
var assignmentCount = getvalue ('f' + columnassignments);
var assignmentLink = getvalue('n' + columnassignments);
if (advisoryStudentSp == student1F || advisoryStudent == student2 && advisoryStudentSp == student2F || advisoryStudentSp == student3F || advisoryStudentSp == student4F || advisoryStudentSp == student5F || advisoryStudentSp == student6F || advisoryStudentSp == student7F && advisoryStudent == student7 || advisoryStudentSp == student8F || advisoryStudent == student9 && advisoryStudentSp == student9F|| advisoryStudent == student10 && advisoryStudentSp == student10F || advisoryStudent == student11 && advisoryStudentSp == student11F) {
if (getvalue('f' + columnassignments) > 0) {
assignments = assignments + getvalue('b' + columnassignments) + ' ' + getvalue('a' + columnassignments) + ': ' + assignmentCount + '<br>Assignment Link: ' + assignmentLink + '<br>';
}
}
}
for (columnAmount; columnAmount <= LastRow && columnAmount <= 160; columnAmount++) {
var advisoryStudent = getvalue('a' + columnAmount);
var advisoryStudentSp = getvalue('b' + columnAmount);
var amountowed = getvalue ('i' + columnAmount);
if (advisoryStudentSp == student1F || advisoryStudent == student2 && advisoryStudentSp == student2F || advisoryStudentSp == student3F || advisoryStudentSp == student4F || advisoryStudentSp == student5F || advisoryStudentSp == student6F || advisoryStudentSp == student7F && advisoryStudent == student7 || advisoryStudentSp == student8F || advisoryStudent == student9|| advisoryStudent == student10 && advisoryStudentSp == student10F || advisoryStudent == student11 && advisoryStudentSp == student11F) {
if (getvalue('i' + columnAmount) > 0) {
amount = amount + getvalue('b' + columnAmount) + ' ' + getvalue('a' + columnAmount) + ': ' + '$' + amountowed + '<br>';
}
}
}
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Status Calculator');
var LastRow = ss.getLastRow();
var columns = 3;
var columnassignments = 3;
var columnEnrichment = 3;
for (columnEnrichment; columnEnrichment <= LastRow && columnEnrichment <= 160; columnEnrichment++) {
var advisoryStudent = getvalue('a'+columnEnrichment);
var advisoryStudentSp = getvalue('b' + columnEnrichment);
if (advisoryStudentSp == student1F || advisoryStudent == student2 && advisoryStudentSp == student2F || advisoryStudentSp == student3F || advisoryStudentSp == student4F || advisoryStudentSp == student5F || advisoryStudentSp == student6F || advisoryStudentSp == student7F && advisoryStudent == student7 || advisoryStudentSp == student8F || advisoryStudent == student9 && advisoryStudentSp == student9F|| advisoryStudent == student10 && advisoryStudentSp == student10F || advisoryStudent == student11 && advisoryStudentSp == student11F) {
if (Utilities.formatDate(getvalue('g' + columnEnrichment), 'EST', 'HH') > 0 || Utilities.formatDate(getvalue('g' + columnEnrichment), 'EST', 'mm') > 0){
enrichment = enrichment + getvalue('b' + columnEnrichment) + ' ' + getvalue('a' + columnEnrichment) + ': ' + Utilities.formatDate(getvalue('g' + columnEnrichment), 'EST', 'HH') + ' hours ' + Utilities.formatDate(getvalue('g' + columnEnrichment), 'EST', 'mm') + ' minutes <br>'
}
}
}
}
EDIT:
This portion just has a list of names in one column and searches for one word in the entire 200 row column and returns the rows with that word, then returns it again if it is greater than 5.
If I had it just looking for numbers greater than or equal to 5 and using a getvalue function, would that be the most efficient way to return names with values of 5 or more?
function getValues(CellName) {
return SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet2').getRange(CellName).getValues();
}
function setvalue(CellName, value) {
return SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet2').getRange(CellName).setValue(value);
}
function test(i) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sh2 = ss.getSheetByName('Sheet2');
var data = sh2.getRange('A1:C200').getValues();
var amount = sh2.getRange('c1:c200').getValues()
var findthis = sh2.getRange('e1').getValues();
var acol = sh2.getRange(1,sh2.getLastRow(),1,1).getValues();
var bcol = sh2.getRange(1,sh2.getLastRow(), 2, 1).getValues();
var test = acol.join().split(',');
var test2 = bcol.join().split(',');
for (i = 0; i<data.length; i++) { //search all rows
if ('wet' == data[i][0]) { //finds wet in the data column and returns row
Logger.log('testing' + ' row ' + (i+1))
if (amount[i][0] >= 5) { //search if c >= 5
Logger.log('Larger ' + ' row ' + (i+1))
}
}
}
}

I would suggest grouping your data into arrays by its natural grid ranges and then accessing the values by array index.
Something along the lines of:
function teacher1() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sh_1 = ss.getSheetByName('sheet1');
var sh_2 = ss.getSheetByName('sheet2');
...
// Get all related values into array & retrieve each row record by index
var student = sh_1.getRange("B3:C13").getValues(); // student[row][col] :ex: student11 => student[12][0]::student11F => student[12][1]
...
// remove the for loop & get all values in a col with one call per col
//(this could be optimized further)
var a_col = sh_2.getRange(1, sh_2.getLastRow(), 1, 1).getValues(); // col a rows 1-lastrow()
var b_col = sh_2.getRange(1, sh_2.getLastRow(), 2, 1).getValues(); // col b rows 1-lastrow()
// Flatten the array to make searching that column easier
var advisoryStudent = a_col.join().split(",")
var advisoryStudentSp = b_col.join().split(",")
// etc ...
// To check if student11 is in advisoryStudentSp: (can loop through students here)
// -1 means not found
// any other number is the index position of `advisoryStudentSp[i]`
// if 5 is returned then student11 matched the value in sheet2 colB row6
Logger.log("student11 is in position: %s", advisoryStudentSp.indexOf(student[12][0]))
}
edit: added the somewhat important .getValues()

Rather than retrieve the cell values one by one using your getValue() / getAdvisee() formulas you need to read the entire sheets or the relevant ranges all at once using Range.getValues(), then work with the data in the arrays.
The key issue here is that each individual call to Range.getValues() consumes a lot of time, whether you read in 100 cells at once or a single cell value. Thus your current approach of reading in one cell at a time is extremely slow (as you are seeing).
Refactoring in this way is too large to undertake as part of my answer, but once completed this script will run in just a couple seconds.

Related

How can I fix require Value In Range

I have this script that works perfectly in some of my spreadsheets but fails on others.
I have code that is too long, or crashes. Please help me shorten the code
Can someone help and explain me this?
Here is the code:
function setDataValid_(range, sourceRange) {
var rule = SpreadsheetApp.newDataValidation().requireValueInRange(sourceRange, true).build();
range.setDataValidation(rule);
}
function onEdit() {
var aSheet = SpreadsheetApp.getActiveSheet();
var aCell = aSheet.getActiveCell();
var aColumn = aCell.getColumn();
if (aColumn == 4 && aSheet.getName() == 'Tháng 6') {
var range = aSheet.getRange(aCell.getRow(), aColumn + 1);
var sourceRange = SpreadsheetApp.getActiveSpreadsheet().getRangeByName(aCell.getValue());
setDataValid_(range, sourceRange)
}
else if (aColumn == 5 && aSheet.getName() == 'Tháng 6') {
var range = aSheet.getRange(aCell.getRow(), aColumn + 1);
var sourceRange = SpreadsheetApp.getActiveSpreadsheet().getRangeByName(aCell.getValue());
setDataValid_(range, sourceRange)
}
if (aColumn == 4 && aSheet.getName() == 'Tháng 7') {
var range = aSheet.getRange(aCell.getRow(), aColumn + 1);
var sourceRange = SpreadsheetApp.getActiveSpreadsheet().getRangeByName(aCell.getValue());
setDataValid_(range, sourceRange)
}
else if (aColumn == 5 && aSheet.getName() == 'Tháng 7') {
var range = aSheet.getRange(aCell.getRow(), aColumn + 1);
var sourceRange = SpreadsheetApp.getActiveSpreadsheet().getRangeByName(aCell.getValue());
setDataValid_(range, sourceRange)
}
if (aColumn == 4 && aSheet.getName() == 'Tháng 8') {
var range = aSheet.getRange(aCell.getRow(), aColumn + 1);
var sourceRange = SpreadsheetApp.getActiveSpreadsheet().getRangeByName(aCell.getValue());
setDataValid_(range, sourceRange)
}
else if (aColumn == 5 && aSheet.getName() == 'Tháng 8') {
var range = aSheet.getRange(aCell.getRow(), aColumn + 1);
var sourceRange = SpreadsheetApp.getActiveSpreadsheet().getRangeByName(aCell.getValue());
setDataValid_(range, sourceRange)
}
if (aColumn == 4 && aSheet.getName() == 'Tháng 9') {
var range = aSheet.getRange(aCell.getRow(), aColumn + 1);
var sourceRange = SpreadsheetApp.getActiveSpreadsheet().getRangeByName(aCell.getValue());
setDataValid_(range, sourceRange)
}
else if (aColumn == 5 && aSheet.getName() == 'Tháng 9') {
var range = aSheet.getRange(aCell.getRow(), aColumn + 1);
var sourceRange = SpreadsheetApp.getActiveSpreadsheet().getRangeByName(aCell.getValue());
setDataValid_(range, sourceRange)
}
}
Here is an prototype of how I would do it. I can't guarantee it because your date set if pretty complex.
I use the event object e to identify the active sheet, range and value.
Notice I use Range.offset() because you want to set the value in the column next to the one edited.
function onEdit(e) {
let sheets = ['Tháng 6','Tháng 7','Tháng 8','Tháng 9'];
let sheet = e.range.getSheet();
if( sheets.indexOf(sheet.getName()) < 0 ) return;
let column = e.range.getColumn();
if( ( column === 4 ) || ( column === 5 ) ) {
let range = e.range.offset(0,1);
let sourceRange = e.source.getRangeByName(e.value);
setDataValid_(range, sourceRange);
}
}

Set cell value using if statement

I'm trying to use an if statement in scripts to set cell values once conditions are met, however its not working and i can't figure out why.
I need to do it using scripts rather than formulas in the sheet itself
var mainWSname = "Exposure"
function onEdit(e){
var activeCell = e.range();
var r = activeCell.getRow()
var c = activeCell.getColumn()
var val = activeCell.getValue();
var wsName = activeCell.getSheet().getName()
if(wsName === mainWSname && c === 2 && val === "Match"){
wsName.getRange(r, 3).setValue("18")
wsName.getRange(r, 4).setValue("80")
}
}
Try this modification:-
var mainWSname = "Exposure"
function onEdit(e){
var activeCell = e.range;
var r = activeCell.getRow()
var c = activeCell.getColumn()
var val = e.value;
var wsName = activeCell.getSheet()
if(wsName.getName() === mainWSname && c === 2 && val === "Match"){
wsName.getRange(r, 3).setValue("18")
wsName.getRange(r, 4).setValue("80")
}
}
Reference:
Event Object

Google Script to hide rows by 2 conditions, One word and one date

This is the first question I have posted on Stack Overflow so I apologize if I am doing this wrong. I have a tracker for work where I am trying to hide rows with a script that meets 2 conditions. 1. If a row contains "rejected" or "withdrew" 2. Date older than the previous quarter (in this case 1/1/2022). I can get the script to hide rows with just the words no problem but I have no clue how to do the date because I think it is a different syntax.
The dates are in column K, M, O, Q, S, U, W.
Here is the code I am currently using:
function Hide() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheets = ss.getSheets();
for (var sheetI = 1; sheetI <= 3; sheetI++) {
var sheet = sheets[sheetI];
sheet.showRows(1, sheet.getMaxRows());
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = ss.getSheetByName("Data Validation");
var v = s.getRange("A2").getValues();
var kk = SpreadsheetApp.getActiveSpreadsheet();
var k = kk.getSheetByName("SM");
var a = k.getRange("K:K").getValue();
var b = k.getRange("M:M").getValue();
var c = k.getRange("O:O").getValue();
var d = k.getRange("Q:Q").getValue();
var e = k.getRange("S:S").getValue();
var f = k.getRange("U:U").getValue();
var g = k.getRange("W:W").getValue();
var colJ = sheet.getRange("J:J").getValues().map(function(row) {return row[0];});
var colL = sheet.getRange("L:L").getValues().map(function(row) {return row[0];});
var colN = sheet.getRange("N:N").getValues().map(function(row) {return row[0];});
var colP = sheet.getRange("P:P").getValues().map(function(row) {return row[0];});
var colR = sheet.getRange("R:R").getValues().map(function(row) {return row[0];});
var colT = sheet.getRange("T:T").getValues().map(function(row) {return row[0];});
var colV = sheet.getRange("V:V").getValues().map(function(row) {return row[0];});
colJ.forEach(function(value, rowI) {
if (value === "rejected" && a < v) {
sheet.hideRows(rowI + 1, 1);
}
else if (value === "withdrew" && a < v) {
sheet.hideRows(rowI + 1, 1);
}
});
colL.forEach(function(value, rowI) {
if (value === "rejected" && b < v) {
sheet.hideRows(rowI + 1, 1);
}
else if (value === "withdrew" && b < v) {
sheet.hideRows(rowI + 1, 1);
}
});
colN.forEach(function(value, rowI)
{
if (value === "rejected" && c < v) {
sheet.hideRows(rowI + 1, 1);
}
else if (value === "withdrew" && c < v) {
sheet.hideRows(rowI + 1, 1);
}
});
colP.forEach(function(value, rowI) {
if (value === "rejected" && d < v) {
sheet.hideRows(rowI + 1, 1);
}
else if (value === "withdrew" && d < v) {
sheet.hideRows(rowI + 1, 1);
}
});
colR.forEach(function(value, rowI) {
if (value === "rejected" && e < v) {
sheet.hideRows(rowI + 1, 1);
}
else if (value === "withdrew" && e < v) {
sheet.hideRows(rowI + 1, 1);
}
});
colT.forEach(function(value, rowI) {
if (value === "rejected" && f < v) {
sheet.hideRows(rowI + 1, 1);
}
else if (value === "withdrew" && f < v) {
sheet.hideRows(rowI + 1, 1);
}
});
colV.forEach(function(value, rowI) {
if (value === "accepted" && g < v) {
sheet.hideRows(rowI + 1, 1);
}
else if (value === "declined" && g < v) {
sheet.hideRows(rowI + 1, 1);
}
else if (value === "didn't extend" && g < v) {
sheet.hideRows(rowI + 1, 1);
}
});
}
}
Original look of sheet
Intended Look of sheet
Since nobody dares to dive deep into this problem (me included) for now, here is the partial solution.
This function returns true if a given date doesn't belong to current quarter:
function is_the_date_old_enough(checked_date) {
// which quarter the date belongs
const get_quarter_of = date => Math.ceil((date.getMonth()+1)/3);
// number of quarters in current date
var cur_date = new Date();
var cur_date_years = cur_date.getFullYear();
var cur_date_quarts = cur_date_years * 4 + get_quarter_of(cur_date);
// number of quarters in checked date
var checked_date_years = checked_date.getFullYear();
var checked_date_quarts = checked_date_years * 4 + get_quarter_of(checked_date);
// if the difference bigger than zero
return (cur_date_quarts - checked_date_quarts) > 0;
}
// tests (current date: 2022-01-14)
console.log(is_the_date_old_enough(new Date())); // false always
console.log(is_the_date_old_enough(new Date('2021-12-20'))); // true
console.log(is_the_date_old_enough(new Date('2021-09-05'))); // true
console.log(is_the_date_old_enough(new Date('2022-01-05'))); // false
console.log(is_the_date_old_enough(new Date('2000-01-05'))); // true
console.log(is_the_date_old_enough(new Date('2030-01-05'))); // false
Beware, the timezones can get you a headache for dates around first and last days of month. If you need to handle timezones it may require a more complicated solution. I suspect the variable cur_date should be defined with '00:00:00.00' time or something like that.

I want to get a timestamp on edit in my datetime row, but I need it to also timestamp when I copy/paste multiple rows in google script

I'm trying to add timestamps to my datetime row on edit. What I'm getting right now is if one row is edited at a time it works. However, what I need is to timestamp every row when I copy/paste values in over multiple rows.
function getDatetimeCol(){
var SHEET_NAME = 'Queue';
var DATETIME_HEADER = 'datetime (+48h for archive)';
var headers = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(SHEET_NAME).getDataRange().getValues().shift();
var colindex = headers.indexOf(DATETIME_HEADER);
return colindex+1;}
function onEdit(e) {
var SHEET_NAME = 'Queue';
var ss = SpreadsheetApp.getActiveSheet();
var cell = ss.getActiveCell();
var datecell = ss.getRange(cell.getRowIndex(), getDatetimeCol());
if (ss.getName() == SHEET_NAME && cell.getColumn() == 1 && !cell.isBlank() && datecell.isBlank()) {
datecell.setValue(new Date()).setNumberFormat("yyyy-MM-dd hh:mm");
}
};
function onEdit(e) {
//e.source.toast('entry');
const sh = e.range.getSheet();
if (sh.getName() == 'Queue' && e.range.columnStart == 1) {
//e.source.toast('cond');
let col = {};
sh.getRange(1, 1, 1, sh.getLastColumn()).getValues()[0].forEach((h, i) => { col[h] = i + 1 });
for (var i = 0; i < e.range.rowEnd - e.range.rowStart + 1; i++) {
let rg = sh.getRange(e.range.rowStart + i, col['datetime (+48h for archive)']);
if (rg.isBlank() && sh.getRange(e.range.rowStart,1).getValue() != '') {
//e.source.toast('if');
rg.setValue(new Date()).setNumberFormat("yyyy-MM-dd hh:mm");
}
}
}
}

Google script getting error while putting multiple conditions

I have pasted example below
code:
function ck() {
//assigning variables
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var lastrow = ss.getLastRow();
var valsr7 = sheet.getRange(lastrow, 3).getValue();
var valsr30 = sheet.getRange(lastrow, 4).getValue();
var valsrn = sheet.getRange(lastrow, 5).getValue();
var valINC7 = sheet.getRange(lastrow, 6).getValue();
var valINC30 = sheet.getRange(lastrow, 7).getValue();
var valINCn = sheet.getRange(lastrow, 8).getValue();
var service = sheet.getRange(lastrow, 2).getValue();
var now = new Date();
var wk = now.getWeek();
//now assigning values to variable
var A = valsr7;
var B = valsr30;
var C = valsrn;
var D = valINC7;
var E = valINC30;
var F = valINCn;
var AB = AB;
if (service == 'Global-Servicenow-Support-T2' && A ==0 && B == 0 ){
MailApp.sendEmail({
to: "prathamesh.padosakar.ext#lafargeholcim.com",
subject : "Open Tickets Global-C&k-T2 - Week-"+wk+"",
htmlBody: "Dear ABC, "+
"<p>Not assigned to any one = "+C+""+
"<P>   "+" "+
"<p>Not updated more than 7 Days = "+D+" "+
"<p>Not Updated more than 30 Days = "+E+""+
"<p>Not assigned to any one = "+F+""+
"<p>   "+" "+
"<p>Best Regards,"+
"<br>Global Service Desk "+,
cc: "techno.pratham94#gmail.com"})
}
if(service == 'Global-Servicenow-Support-T2' && A == 0){
MailApp.sendEmail({
to: "prathamesh.padosakar.ext#lafargeholcim.com",
subject : "Open Tickets Global-C&k-T2 - Week-"+wk+"",
htmlBody: "Dear ABC, "+
"<p>Not Updated more than 30 Days = "+B+""+
"<p>Not assigned to any one = "+C+""+
"<P>   "+" "+
"<p>Not updated more than 7 Days = "+D+" "+
"<p>Not Updated more than 30 Days = "+E+""+
"<p>Not assigned to any one = "+F+""+
"<p>   "+" "+
"<p>Best Regards,"+
"<br>Global Service Desk "+,
cc: "techno.pratham94#gmail.com"
});
}
else {
}
if(service == 'Global-Servicenow-Support-T2' && B == 0){
MailApp.sendEmail({
to: "prathamesh.padosakar.ext#lafargeholcim.com",
subject : "Open Tickets Global-C&k-T2 - Week-"+wk+"",
htmlBody: "Dear ABC, "+
"<p>Not updated more than 7 Days = "+A+" "+
"<p>Not assigned to any one = "+C+""+
"<P>   "+" "+
"<p>Not updated more than 7 Days = "+D+" "+
"<p>Not Updated more than 30 Days = "+E+""+
"<p>Not assigned to any one = "+F+""+
"<p>   "+" "+
"<p>Best Regards,"+
"<br>Global Service Desk "+,
cc: "techno.pratham94#gmail.com"
});
}
else {
}
when i pass condition through if(service == 'Global-Servicenow-Support-T2' && A == 0) and if(service == 'Global-Servicenow-Support-T2' && B == 0) it gives me single output output or correct output . when i pass condition if (service == 'Global-Servicenow-Support-T2' && A ==0 && B == 0 ) it give me output of all 3 conditions which are mention below.
if(service == 'Global-Servicenow-Support-T2' && A == 0) and if(service == 'Global-Servicenow-Support-T2' && B == 0) and if (service == 'Global-Servicenow-Support-T2' && A ==0 && B == 0 )
Please help i want single output when i pass condition if (service == 'Global-Servicenow-Support-T2' && A ==0 && B == 0 ).
Change condition
if(service == 'Global-Servicenow-Support-T2' && A == 0){
to
if(service == 'Global-Servicenow-Support-T2' && A == 0 && B != 0){
and change condition
if(service == 'Global-Servicenow-Support-T2' && B == 0){
to
if(service == 'Global-Servicenow-Support-T2' && B == 0 && A != 0){
Then you will have one output for if (service == 'Global-Servicenow-Support-T2' && A ==0 && B == 0 )