Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Copy Selected Cell Values Without using SNUtils

Jose Manuel
Tera Contributor

Hi all,

 

if you don't have SNUtils and you want to use the command /copycells, here you have the code to do it from the browser's console.

 

//----------------- !Copy values of cells when it's not a link
var rowsSelected = document.querySelectorAll("td.list_edit_selected_cell");
var values = [];

rowsSelected.forEach(function (row) {
    values.push(row['firstChild']['data'])
});
console.log(values);
console.log(values.toString());

//----------------- ! Copy values of cells when it's a link
var rowsSelected = document.querySelectorAll("td.list_edit_selected_cell");
var values = [];

rowsSelected.forEach(function (row) {
    values.push(row['firstChild']['firstChild']['data'])
});
console.log(values);
console.log(values.toString());

 

Use the first part of the code when the column is not a reference field or first column and use the second part of the code when the column a reference field or the first column.

 

Steps:

Select the cells to copy

JoseManuel_0-1754681227463.png

this column contains hyperlink, so I will use the second code.

Copy and paste the code in the browser's console.

JoseManuel_0-1754681457339.png

 

 

Yokohama working!

 

#TricksAndTips

0 REPLIES 0