marth141
11/04/2022, 5:14 PMbattk
11/04/2022, 5:24 PMmarth141
11/04/2022, 6:01 PMfunction GetSearchResult() {
// get saved search results
var column = new nlobjSearchColumn("System Size", "job", "sum")
var results = nlapiSearchRecord(null, "customsearch1076", null, column);
// return the array of search objects
return results[0];
}
This doesn't work because it's not sure what these columns are. Image attached, on the "new nlobjsearchcoumn" I'm trying to get the "System Size" column (imaged)
However, when the script is working like this...
function GetSearchResult() {
var results = nlapiSearchRecord(null, "customsearch1076", null, null);
// return the array of search objects
return results[0];
}
I don't get the stuff that are formulas such as "System Size"
I get this as response
%{
"columns" => %{
"custentity_bb_fin_prelim_purch_price_amt" => 40695,
"custentity_bb_project_location" => %{
"internalid" => "3",
"name" => "Norco"
},
"custentity_bb_system_size_decimal" => 7028,
"internalid" => %{"internalid" => "13", "name" => nil}
},
"id" => nil,
"recordtype" => nil
}
When compared with the image attached, I'm not getting the same numbers like 91,370...
Any ideas?battk
11/04/2022, 6:11 PMbattk
11/04/2022, 6:11 PMmarth141
11/04/2022, 6:11 PMbattk
11/04/2022, 6:12 PMbattk
11/04/2022, 6:12 PM"System Size"
marth141
11/04/2022, 6:13 PMbattk
11/04/2022, 6:15 PMmarth141
11/04/2022, 6:17 PMcustrecord_bb_project.custentity_bb_system_size_decimal
... would that be right?battk
11/04/2022, 6:17 PMmarth141
11/04/2022, 6:18 PMcustrecord_bb_project
is the field on the "Project Action" that references the "Job" record type.battk
11/04/2022, 6:25 PMcustrecord_bb_project
would be the id of the joinbattk
11/04/2022, 6:25 PMcustentity_bb_system_size_decimal
would be the id of the field/columnmarth141
11/04/2022, 6:25 PMbattk
11/04/2022, 6:29 PMmarth141
11/04/2022, 6:30 PMfunction GetSearchResult() {
var column = new nlobjSearchColumn("custentity_bb_system_size_decimal", "custrecord_bb_project", "sum")
var results = nlapiSearchRecord(null, "customsearch1076", null, column);
// return the array of search objects
return results[0];
}
with a response like...marth141
11/04/2022, 6:30 PM%{
"columns" => %{
"custentity_bb_fin_prelim_purch_price_amt" => 40695,
"custentity_bb_project_location" => %{
"internalid" => "3",
"name" => "Norco"
},
"custentity_bb_system_size_decimal" => 7028,
"internalid" => %{"internalid" => "13", "name" => nil}
},
"id" => nil,
"recordtype" => nil
}
battk
11/04/2022, 6:34 PMbattk
11/04/2022, 6:35 PMbattk
11/04/2022, 6:37 PMbattk
11/04/2022, 6:37 PMmarth141
11/04/2022, 6:37 PMmarth141
11/04/2022, 6:38 PMfunction GetSearchResult() {
// Gets the saved search by internal id
var results = nlapiSearchRecord(null, "customsearch1076", null, null);
// Formats the results as an object
results = formatToObject(results)
// return the array of search objects
return results;
}
// Used to format a saved search into an object and include all of the columns of the saved search
// If this isn't used, your response will be missing summary columns
function formatToObject(results) {
// instantiates array container for search results
var output = new Array();
// get all columns of saved search
var columns = results[0].getAllColumns();
// loop through the search results
for (var i in results) {
// create placeholder object place holder
var obj = new searchRow(
// set the values of the object with the values of the appropriate columns
// using getText to get "Norco" instead of "3"
results[i].getText(columns[0]),
// using get value to get values of things
results[i].getValue(columns[1]),
results[i].getValue(columns[2]),
results[i].getValue(columns[3]),
results[i].getValue(columns[4]),
results[i].getValue(columns[5])
);
// add the object to the array of results
output.push(obj);
}
return output;
}
// Object to serve a place holder for each search row
function searchRow(
location,
jobs,
amount,
average_amount,
system_size,
average_system_size
) {
this.location = location;
<http://this.jobs|this.jobs> = jobs;
this.amount = amount;
this.average_amount = average_amount;
this.system_size = system_size;
this.average_system_size = average_system_size;
}
This responses with...
%{
"amount" => "529038.00",
"average_amount" => "40695.00",
"average_system_size" => "7028",
"jobs" => "13",
"location" => "3",
"system_size" => "91370"
}
Which I'm not thrilled about the "location" field having a 3 instead of norco...marth141
11/04/2022, 6:39 PMmarth141
11/04/2022, 6:42 PMmarth141
11/04/2022, 6:42 PMgetText
marth141
11/04/2022, 6:42 PM