CASE WHEN {previouslinks.previousdoc} != '' THEN ...
# ask-stanley-ai
n
CASE WHEN {previouslinks.previousdoc} != '' THEN TO_CHAR({transactionlines.accountingimpact.credit#currency_consolidated}) ELSE TO_CHAR({transactionlines.accountingimpact.debit#currency_consolidated}) END
c
AI generated answer (using internal Slack threads):
Based on the conversations, it seems like you are trying to create a conditional statement in NetSuite. The general structure of such a statement is
CASE WHEN condition THEN result ELSE alternative_result END
. In the first conversation, the user is trying to create a statement that checks if the currency is CAD. If it is, it returns the customer balance. If it's not, it divides the customer balance by the exchange rate. The correct syntax for this would be:
Copy code
CASE
  WHEN {currency} = 'CAD'
  THEN {customer.balance}
  ELSE {customer.balance}/NULLIF({exchangerate}, 0)
END
In the second conversation, the user is trying to create a statement that checks the number of days overdue and returns the foreign currency amount remaining. The correct syntax for this would be:
Copy code
CASE 
  WHEN ({recordtype} <> 'invoice' AND {recordtype} <> 'customerpayment' AND {recordtype} <> 'creditmemo' AND TRUNC({today})-{trandate} BETWEEN 1 AND 30) 
  THEN {amount} 
  WHEN ({recordtype} = 'creditmemo' AND {duedate} IS NULL AND TRUNC({today})-{trandate} BETWEEN 1 AND 30) 
  THEN -({amountremaining}) 
  WHEN ({recordtype} = 'invoice' AND {duedate} IS NOT NULL AND TRUNC({today})-{duedate} BETWEEN 1 AND 30) 
  THEN {amountremaining} 
  WHEN ({recordtype} = 'invoice' AND {duedate} IS NULL AND TRUNC({today})-{trandate} BETWEEN 1 AND 30) 
  THEN {amountremaining} 
  WHEN ({recordtype} = 'customerpayment' AND {duedate} IS NULL AND TRUNC({today})-{trandate} BETWEEN 1 AND 30) 
  THEN -({amountremaining}) 
END
In the third conversation, the user is trying to create a statement that checks if the transaction date is in March and if the account ID matches the income account ID. If both conditions are met, it returns the transaction quantity. If not, it returns 0. The correct syntax for this would be:
Copy code
CASE 
  WHEN TO_CHAR({transaction.trandate}, 'MON') = 'MAR' and ({transaction.account.id} = {incomeaccount.id} OR  {transaction.account.id} IN ('221','222','245','331')) AND {transaction.posting}= 'T' 
  THEN {transaction.quantity}  
  ELSE 0 
END
****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.816691875
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.815182
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.810064256
Please provide your feedback on this answer.