``` function createActualRevenueRecord(periodStar...
# suitescript
n
Copy code
function createActualRevenueRecord(periodStartDate) {
    var timebillSearchObj = search.create({
      type: "timebill",
      filters: [
        ["formulanumeric: CASE WHEN (TO_CHAR({date},'MM') || '/01/' || TO_CHAR({date},'YYYY')) = periodStartDate THEN 1 ELSE 0 END", "equalto", "1"]
trying to get periodStartDate to work in the formula.. any clues?
b
im not actually sure that this looks easier than actually using one of the date related filters
n
I have daily time entries and I am trying to get one period of time entries at a time
b
but basic idea should be to change periodStartDate into a string that matches what you are trying to match against
n
this works in the UI, where I take all of a single months time entries and brin ghtem back to first month
b
and use string concatenation to put it into your formula in the right place
n
ok
b
depending on how you build your string, you probably want to make sure that your periodStartDate has quotes in it
n
can I use the .toString(); method in ss?
b
ss is ambiguous, in this context, could means suitescript or saved search
n
suitescript
b
you have to work to find something not named null or undefined that doesnt have a toString
n
got it to work
Copy code
function createActualTimeRecord(periodStartDate) {
    var tempPeriodStartDate = periodStartDate.toString();
    log.debug('tempPeriodStartDate',tempPeriodStartDate);

    var timebillSearchObj = search.create({
      type: "timebill",
      filters: [
        ["formulanumeric: CASE WHEN (TO_CHAR({date},'MM') || '/01/' || TO_CHAR({date},'YYYY')) = "+"'"+periodStartDate+"'"+" THEN 1 ELSE 0 END", "equalto", "1"]
      ],
this works ^
thanks @battk
Copy code
[
   {
      values: {
         "GROUP(formulatext)": "12/01/2020",
         "SUM(durationdecimal)": "5436.25",
         "GROUP(formulatext)_1": "PTO"
      }
   },
   {
      values: {
         "GROUP(formulatext)": "12/01/2020",
         "SUM(durationdecimal)": "7011.75",
         "GROUP(formulatext)_1": "Billable"
      }
   },
   {
      values: {
         "GROUP(formulatext)": "12/01/2020",
         "SUM(durationdecimal)": "473.25",
         "GROUP(formulatext)_1": "Training"
      }
   },
   {
      values: {
         "GROUP(formulatext)": "12/01/2020",
         "SUM(durationdecimal)": "340.75",
         "GROUP(formulatext)_1": "Pitch"
      }
   },
   {
      values: {
         "GROUP(formulatext)": "12/01/2020",
         "SUM(durationdecimal)": "661.5",
         "GROUP(formulatext)_1": "Internal Work"
      }
   },
   {
      values: {
         "GROUP(formulatext)": "12/01/2020",
         "SUM(durationdecimal)": "1274.5",
         "GROUP(formulatext)_1": "Internal Other"
      }
   }
]
this is the result of my SS ^
Copy code
var tempHours = projecthourssearch[i].getValue({
          name: 'SUM(durationdecimal)'
        });
this doesn't seem to be getting the value ^... what am I missing there?
b
Parameters to getValue should match that used to make the column
I generally recommend actually using Result.getValue(column) for formula related columns
👍 1
n
got it to work
I'm trying to do the sum of all the duration decimals in the for loop but its just concatenating instead see code:
Copy code
var temptotaltime = 0;        
temptotaltime += parseFloat(tempHours).toFixed(2);
result: 05436.257011.75473.25340.75661.501274.50
b
extra attention to the return type
n
i had no idea
wow thank you