Netsuite Expression for Formula (Date) Field - netsuite

I am new to the NetSuite expressions and I am using the following formula in a Opportunity Saved Search result but it is returning an Invalid Expression.
I am trying to display the Systems Note Date when an Opportunity Status was changed to 'Suspect'.
CASE WHEN {systemnotes.field} IN {entitystatus} END CASE WHEN {systemnotes.newvalue}=Suspect THEN {systemnotes.date} END

In a single expression, there should only be one CASE and one END and then you can have several WHEN/THEN statements.
Your formula should be more like this:
CASE WHEN {systemnotes.field} = 'Entity Status' AND {systemnotes.newvalue}='Suspect' THEN {systemnotes.date} END
This is assuming you have Suspect as a value for this, but this should be correct

Related

Power Automate - check if valid date

I have a Power Automate flow that calls on an Office Script to read a specific cell in an Excel workbook. That cell is supposed to have a properly formatted date. If it is properly formatted, in order for Power Automate to read that, I set a variable with this expression:
addDays('1899-12-30', int(outputs('Run_script_2')?['body/result/DeliveryDate']), 'MM/dd/yy')
However, if the output of that script isn't an expected value (i.e. 8.9.2022 instead of 8/9/2022), the flow breaks when trying to run that expression. How can I write an expression that doesn't fail if there isn't the expected Excel-type date? I'd like the expression to equate to null if it's not able to calculate an actual date value.
You can check the NumberFormatCategory, or the specific NumberFormat of the cell to check if it is formatted as a date.
if (selectedSheet.getRange("A1").getNumberFormatCategory() == ExcelScript.NumberFormatCategory.date)
...
or
if (selectedSheet.getRange("A1").getNumberFormatLocal() == "m/d/yyyy")
...
You can return this boolean to Power Automate as well and build your expression accordingly.
Here is how I solved this issue, because my users use the excel date field for more than a date, such as entering "NA", "Not Known", "TBD", etc.
Use the INT() function on the date value. Configure the next step using the "Configure run after" setting to be "Failed" only. Configure the step after that to be "is skipped".
In my case, in the failed case, I simply copy the excel value into a string I'll use for my output file. If the INT() succeeds, I run a condition statement because I want to blank out future dates but leave past dates
You can try using JavaScript's Date class to convert the date in the cell. When you create an instance of the date object, you provide it with the date value from the cell in its constructor. You can then call the toLocalDateString() method of the date object and return that. You can see an example of how to do that below:
function main(workbook: ExcelScript.Workbook) {
let selectedSheet: ExcelScript.Worksheet = workbook.getActiveWorksheet();
let rang: ExcelScript.Range = selectedSheet.getRange("A1") //cell contains the value 8.9.2022
rang.setNumberFormat("mm/dd/yyyy")
let date: Date = new Date(rang.getValue() as string);
return date.toLocaleDateString();
}

Excel customer data validation for chars and numbers

I am trying to validate a combination of char and numbers that looks like this XXXX0000000.
I have tried this formula; =OR((LEFT(B2,3)="XXXX",LEN(B2)=11),AND(LEFT(B2,3)="XXXX",LEN(B2)=11).
The error message I receive is as follows:
excel error message
Title: "Excel customer data validation for chars and numbers"
...I have the feeling it's not just about validating XXXX0000000 but it's about the pattern of characters and numbers. Therefor try:
Formula in B1:
=IF(ISERROR(FILTERXML("<t><s>"&A1&"</s></t>","//s[translate(substring(.,1,4), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ','')=''][string-length()=11][substring(.,5)*0=0]")),"Invalid","Valid")
Where:
//s[translate(substring(.,1,4), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ','')=''] - Check if when we translate the first 4 characters to nothing this also equals empty string;
[string-length()=11] - Check that node is 11 characters long;
[substring(.,5)*0=0] - Check that substring from 5th position onwards equals zero when multiplied by zero.
Note: FILTERXML() is case sensitive and is currently checking for uppercase alpha-chars.
EDIT:
To use this in data-validation; Ditch the IF() since you don't need that in validation and nest the remainder in NOT():
=NOT(ISERROR(FILTERXML("<t><s>"&A1&"</s></t>","//s[translate(substring(.,1,4), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ','')=''][string-length()=11][substring(.,5)*0=0]")))
When you select your range, make sure the validation rule has the topleft cell in the reference.
You have two formulas but no joining of them
IE you have an OR formula
=OR((LEFT(B2,3)="XXXX",LEN(B2)=11)
Which will return a true/false answer
You also have an AND formula
=AND(LEFT(B2,3)="XXXX",LEN(B2)=11)
Which will return a true/false answer
when you work through it you are being given a return of:
=True(or false), true (or false)
That isn't a formula and is causing the error output
I think you want to use an IF statement to join them and get an output as desired:
E.g.
=If(OR(LEFT(B2,3)="XXXX",LEN(B2)=11),AND(LEFT(B2,3)="XXXX",LEN(B2)=11), DO SOEMTHING IF TRUE, DO SOMETHING IF FALSE)
I suggest this:
OR(LEFT(B2,3)="XXX",LEN(B2)=11,AND(LEFT(B2,3)="XXX",LEN(B2)=11))
It corrects the number of characters error and sorts the logic.

spotfire calculated column using over function

I want to create a calculated column "indicateur" that traces the boolean values
when I have a True, I increment the indicator by 1, however i want the false rows to have the value of the last true indicator.
and when i pass to a new ID, the incrementation starts from zero.
I already tried some spotfire expression using the over function but not getting the right results
case
when [boolean] then sum(If([boolean],1,0)) over (Intersect([ID],AllPrevious([ID])))
else 0
end
You have a couple of issues here. Your case statement is sub setting the data... it will only calculate sums where boolean is true.
The main issue is the over statement though. Something like this should give the correct answer
sum(If([boolean],1,0)) over (Intersect([ID],AllPrevious([Timestamp])))

saved search to pull date invoice was paid in full

I've a transaction saved search in which I've various formula columns displaying invoice date, any related credits, and then actual payments after any term discounts taken. Now I need to add another column to display the date invoice was marked "Paid in Full" I'm using the formula which is not working: case when {systemnotes.newvalue} = 'paid in full' then {systemnotes.date} end
I can't use 'date closed' because that's just displays the most recent payment date against an invoice and not the date it was fully applied for example an old credit memo.
Any input is appreciated.
Oracle string comparisons are case sensitive. {systemnotes.newvalue} returns 'Paid In Full' - not 'paid in full' (note the Title Case). You can correct the comparison to use Title Case like this:
case when {systemnotes.newvalue} = 'Paid In Full' then {systemnotes.date} end
or you can coerce both sides to upper or lower case for a slightly more robust comparison:
case when UPPER({systemnotes.newvalue}) = UPPER('paid in full') then {systemnotes.date} end
I've tested both of these and they work for me.
Why not just use the Date Closed? (closedate)

Excel Macro Best Practice for Multiple options in If Statement or Case

I have multiple "Call Types" (from "Roaming" to "International") and I need a vlookup to apply the correct rate depending on the type in an excel macro.
What's the best practice to do this?
If CategoryType = "Roaming" AND Country coainted in List A
Then
If List B
Then
Do I use arrays? How do you check if a string is in an array in an IF statement?
Solved: I used Case and then included sub-cases to assign a new Category:
Select Case otype
Case "International"
Select Case country
Case "Australia", "China", "Singapore"
ActiveCell.Offset(0, 68).Value = "R01"
Case Else
ActiveCell.Offset(0, 68).Value = "R02"
End Select
End Select
You could use something like the following formula (array formula, so use Ctrl+Shift+Enter to apply)
=MAX((B4:B7=B10)*(IF(ISERROR(SEARCH(B11,C4:C7)),0,1))*D4:D7)
The one issue is that you may get a false result if the country you're searching for happens to be a substring of another country. The only fix for that would be to put all your country names like |France|Canada|UK| and then add the pipes around the search country input.
There could also be another option. When I handle such calculations, I try to avoid putting multiple values into a single field. Instead, I try to treat it like a database:

Resources