Skip to content

Instantly share code, notes, and snippets.

@chechedotmx
Last active November 17, 2019 02:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chechedotmx/cde9c2ce20c2097b7e0ffa34391e98e9 to your computer and use it in GitHub Desktop.
Save chechedotmx/cde9c2ce20c2097b7e0ffa34391e98e9 to your computer and use it in GitHub Desktop.
let uri = "https://api.smartsheet.com/2.0/search/sheets/";
let sheetId = inputData.sheetId;
let productCode = inputData.productCode;
let options = {
method: 'GET',
headers: {'Authorization': 'Bearer '+inputData.token}
};
productCode = parseInt(productCode,10);
fetch(uri+sheetId+'?query="ID'+productCode+'"', options)
.then(function(res) {
return res.json();
}).then(function(json) {
if(json.totalCount == 0){
callback(null, {"rowId":0});
}else{
let array = json.results;
let rowId = 0;
for (let index = 0; index < array.length; index++) {
if(array[index].objectType = "row"){
rowId = array[index].objectId
break;
}
}
callback(null, {"rowId":rowId});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment