Download as pdf or txt
Download as pdf or txt
You are on page 1of 18

NetSuite Formulas

http://tiny.cc/NSformula

Please feel free to “give back” and share some. Send your formula examples to dhynek@business-
fitness.com.

Contributing Organizations:

MasterGraphics DIY Home Center


Apogee Forte Research
WiscNet Cielo

Table of Contents
Case When Formulas .................................................................................................................................... 4
Multiple Case When statements in a single formula ................................................................................ 4
Using Case When to locate text ................................................................................................................ 4
Using date in Case When .......................................................................................................................... 5
Case When with more than one select ..................................................................................................... 5
Multiple Case When statements with Wildcards ..................................................................................... 5
Case When statement to look up Multiple Zip Codes .............................................................................. 5
Using Case When to select all date for the last 7 days (Time for last week by employee) ...................... 5
Using Multiple “Not” in a Case When statement ..................................................................................... 5
Multiple Case When satements Grouped................................................................................................. 5
To display the milestone status with corresponding colors (red, yellow, green) ..................................... 5
Using Case When to determine when an item was sold for free ............................................................. 6
Mass Update for Last Sales Face to Face .................................................................................................. 6
Decode .......................................................................................................................................................... 6
Simple Case When with Decode ............................................................................................................... 6
Decode with Multiple Case When ............................................................................................................ 6
Look at date and determine the month ................................................................................................... 6
Dealing with Null Data .................................................................................................................................. 7
NVL ............................................................................................................................................................ 7
NVL2 .......................................................................................................................................................... 7
Use NVL2 to provide link when a field is not null ..................................................................................... 7
Nullif ......................................................................................................................................................... 7
Using SUM and Nullif to Divide 2 formulas… ............................................................................................ 7
Managing Text .............................................................................................................................................. 7
Remove characters from text ................................................................................................................... 7
Display only portion of text....................................................................................................................... 8
Concat ....................................................................................................................................................... 8
Concatenate two fields ............................................................................................................................. 8
Using CONCAT Statement ......................................................................................................................... 8
Using CONCAT Statement in a Mass Update Fields Formula.................................................................... 8
RPad/LPad ................................................................................................................................................ 8
SUBSTR...................................................................................................................................................... 8
Clean up Phone Numbers using “Replace” ............................................................................................... 9
Formatting .................................................................................................................................................... 9
Using check Box in a Formula and Inline HTML ........................................................................................ 9
Controlling Column and Row data in Searches ....................................................................................... 9
HTML Text Tags ......................................................................................................................................... 9
NetSuite Custom Label coding .................................................................................................................. 9
Formula Example: ............................................................................................................................... 10
Column Label Example: ....................................................................................................................... 10
Quick Links .................................................................................................................................................. 11
Using quick link pop-up for inline editing ............................................................................................... 11
Customer Quick View Link (Text Formula).............................................................................................. 11
Log a Call with loaded customer and contact information ..................................................................... 11
Log a Call with loaded customer, contact, and support contract information ....................................... 11
View Contracts ........................................................................................................................................ 12
Send Custom Email ................................................................................................................................. 12
Create a Deal ........................................................................................................................................... 12
View Activities ......................................................................................................................................... 12
Edit Customer ......................................................................................................................................... 12
Selecting an Email Template and assign Contact from a Link (Text formula)......................................... 12
Sending an Email from a transaction search (Text formula)................................................................... 12
Calculation Functions .................................................................................................................................. 13
Math ....................................................................................................................................................... 13
Show quantity within a range ................................................................................................................. 13
Calculate Gross Profit.............................................................................................................................. 13
Calculate Days to a Date ......................................................................................................................... 13
Calculate Days between Dates using System Notes ............................................................................... 13
Total sales ............................................................................................................................................... 13
Total Cost ................................................................................................................................................ 13
Gross Profit Dollars ................................................................................................................................. 14
Getting year to date (YTD) revenue in transaction search ..................................................................... 14
Calculate Subtotal ................................................................................................................................... 14
Date......................................................................................................................................................... 14
Used to calculate a date 60 days in the future ....................................................................................... 14
Show the day of the week ...................................................................................................................... 14
Using MAX with Date range to select Month range ............................................................................... 15
Using TO_CHAR to find last month in a date field .................................................................................. 15
Using the TO_CHAR to select data for a specific day of the week.......................................................... 15
Search to compare an Expiration date to today’s date .......................................................................... 15
Scripts ..................................................................................................................................................... 15
Sample Script (Work Flow Action Script) ................................................................................................ 15
Additional Script Example ....................................................................................................................... 16
Miscellaneous ............................................................................................................................................. 17
Using a MAX Command inside a formula (used in actual VRS Forecast) ................................................ 17
Who Last Modified .................................................................................................................................. 17
Search for a work for sequence in a field using REGEXP_INSTR ............................................................. 17
Not Equal To............................................................................................................................................ 17
Finding First not Null field from list of fields using Coalesce .................................................................. 17
Using an URL to Enter Data on an Online Form ...................................................................................... 17
Using a Saved Search to fill as a default value in field ............................................................................ 18
Using MAX and SUM in the same formula.............................................................................................. 18
Wildcards ................................................................................................................................................ 18
Case When Formulas
Multiple Case When statements in a single formula
CASE {custitemcommission_parent}when 'Autodesk Software Vertical' THEN 1 WHEN 'Autodesk
Software Vertical Subscription New' THEN 2 WHEN 'Autodesk Software Vertical Subscription Renewal'
THEN 3 WHEN 'Autodesk Software Horizontal' then 4 WHEN 'Autodesk Software Horizontal Subscription
New' then 5 WHEN 'Autodesk Software Horizontal Subscription Renewal' THEN 6 WHEN 'Hardware
Equipment ' THEN 7 WHEN 'Refurb Equipment' THEN 8 WHEN 'Hardware Maintenance Program' then 9
when 'Software -Non Autodesk' then 11 when 'Software - Kubotek' then 12 when 'Imaging Services - All
Formats' then 13 when 'InkJets' then 14 When 'Consulting' then 15 when 'Training' then 16 when
'Software Support' then 17 when 'Drafting Supplies' then 18 When 'S&R Parts & Labor' then 10 ELSE 0
END

case {item.custitemcommission_parent} when 'Autodesk Software Vertical' then


{salesrep.custentityplan_ad_sw_vert_pro_q1} when'Autodesk Software Vertical Subscription New' then
{salesrep.custentityplan_ad_sw_vert_sub_q1} when'Autodesk Software Vertical Subscription Renewal'
then {salesrep.custentityplan_ad_sw_vert_sub_rn_q1} when'Training' then
{salesrep.custentityplan_sw_training_q1} when'Consulting' then
{salesrep.custentityplan_sw_serv_con_q1} when'Software Support' then
{salesrep.custentityplan_sw_support_q1} when'Imaging Services - All Formats' then
{salesrep.custentityplan_img_srv_all_for_q1} when'Hardware Maintenance Program' then
{salesrep.custentityplan_hw_maint_q1} when'Hardware Equipment ' then
{salesrep.custentityplan_hw_equ_q1} when'Autodesk Software Horizontal' then
{salesrep.custentityplan_ad_sw_hor_pro_q1} when'Autodesk Software Horizontal Subscription
Renewal' then {salesrep.custentityplan_ad_sw_hor_sub_q1} when'Software -Non Autodesk' then
{salesrep.custentityplan_sw_

case {item.custitem_commission_code}when '1' then {salesrep.custentityplan_ad_sw_vert_pro_q1}


when'2' then {salesrep.custentityplan_ad_sw_vert_sub_q1} when'3' then
{salesrep.custentityplan_ad_sw_vert_sub_rn_q1} when'16' then
{salesrep.custentityplan_sw_training_q1} when'15' then {salesrep.custentityplan_sw_serv_con_q1}
when'17' then {salesrep.custentityplan_sw_support_q1} when'13' then
{salesrep.custentityplan_img_srv_all_for_q1} when'9' then {salesrep.custentityplan_hw_maint_q1}
when'7 ' then {salesrep.custentityplan_hw_equ_q1} when'4' then
{salesrep.custentityplan_ad_sw_hor_pro_q1} when'5' then
{salesrep.custentityplan_ad_sw_hor_sub_q1} when'11' then {salesrep.custentityplan_sw_non_ad_q1}
when '8' then {salesrep.custentityplan_hw_referb_q1} when '14' then
{salesrep.custentityplan_hw_inkjets_q1} end

Using Case When to locate text


It looks at the name of a records and Identifies when “Manfact” is in the text

case when {altname} like '%'||('Manufact')||'%' then 'Y' end


Using date in Case When
Case when (to_char({customermain.custentitydata_ad},'MM/DD/YYYY'))= '01/07/2010' then '<a
name="1/7/10 Data" id="1/7/10
Data"href="'||'https://system.netsuite.com/app/common/search/searchresults.nl?searchtype=Custom
er&Customer_SALESREP=@ALL@&Entity_INTERNALID='||{customermain.internalid}||'&sortcol=Entity_
ALTNAME_raw&sortdir=ASC&csv=HTML&OfficeXML=F&pdf=&style=NORMAL&report=&grid=&searchid
=3565"target="_blank">1/7/10 Data</a>' end

Case When with more than one select


case when{item.custitem_vertical}='AEC' and {item.custitem_product_type}IN('Software','Fee') then
{amount}end

Multiple Case When statements with Wildcards


case when {transaction.type}in ('Invoice','Cash Sale') and {transaction.item}like'%Software - Non%' then
{transaction.trandate} else (case when {transaction.type}in ('Invoice','Cash Sale') and{transaction.item}
like 'Autodesk%' then {transaction.trandate}end)end

Case When statement to look up Multiple Zip Codes


To use this formula, make sure you are in the Criteria section of the search, select "Formula (Numeric)"
then place the formula below in the "Formula*" section, select equal to, in the "Formula Numeric"
section and the number 1 in the "Value" section. Make sure there are no line breaks or weird spacing
after you copy the Numbers into NetSuite.
CASE WHEN TO_NUMBER({zipcode}) IN (55122,55425,55123) THEN 1 END

Using Case When to select all date for the last 7 days (Time for last week by employee)
CASE WHEN ({today} - {time.date}) BETWEEN 0 AND 7 THEN {time.durationdecimal} end

Using Multiple “Not” in a Case When statement


This is used when you want to eliminate more than one value from a Case statement lookup, in the
example below we want to display the income account only it is not UPS or Freight.
case when {item.incomeaccount} not in ('UPS', 'Freight') then {item.incomeaccount}end

Multiple Case When satements Grouped


Case When {type}in ('Invoice','Cash Sale') then ({netamount}*{contribution}) else (Case When
{type}='Sales Order' and {status}in ('Pending Approval', 'Pending Fulfillment', 'Partially Fulfilled', 'Pending
Billing/Partially Fulfilled', 'Pending Billing') then ({netamount}*{contribution}) else (Case when
{type}='Deal' then (case {custbody_forecast_stage} when 'Commit ' then
(({netamount}*{contribution})*.75) when 'Upside' then (({netamount}*{contribution})*.25)when
'Pipeline' then (({netamount}*{contribution})*.1) end)end) end) end

To display the milestone status with corresponding colors (red, yellow, green)
CASE WHEN ({status} = 'Completed' OR ROUND({percentworkcomplete}*100, 1) = 100.0) THEN '<span
style="color:#afc437;font-weight:bold;">Completed</span>' WHEN (TO_DATE(TO_CHAR({startdate},
'MM/DD/YYYY'), 'MM/DD/YYYY') - TO_DATE(TO_CHAR(SYSDATE, 'MM/DD/YYYY'), 'MM/DD/YYYY')) < -
1 THEN '<span style="color:#bf340f;font-weight:bold;">' || (TO_DATE(TO_CHAR(SYSDATE,
'MM/DD/YYYY'), 'MM/DD/YYYY') - TO_DATE(TO_CHAR({startdate}, 'MM/DD/YYYY'), 'MM/DD/YYYY')) || '
days overdue</span>' WHEN (TO_DATE(TO_CHAR({startdate}, 'MM/DD/YYYY'), 'MM/DD/YYYY') -
TO_DATE(TO_CHAR(SYSDATE, 'MM/DD/YYYY'), 'MM/DD/YYYY')) = -1 THEN '<span
style="color:#bf340f;font-weight:bold;">' || (TO_DATE(TO_CHAR(SYSDATE, 'MM/DD/YYYY'), 'MM/DD/YYYY')
- TO_DATE(TO_CHAR({startdate}, 'MM/DD/YYYY'), 'MM/DD/YYYY')) || ' day
overdue</span>' WHEN (TO_DATE(TO_CHAR({startdate}, 'MM/DD/YYYY'), 'MM/DD/YYYY') -
TO_DATE(TO_CHAR(SYSDATE, 'MM/DD/YYYY'), 'MM/DD/YYYY')) = 0 THEN '<span
style="color:#f89406;font-weight:bold;">Due today</span>' WHEN (TO_DATE(TO_CHAR({startdate},
'MM/DD/YYYY'), 'MM/DD/YYYY') - TO_DATE(TO_CHAR(SYSDATE, 'MM/DD/YYYY'), 'MM/DD/YYYY')) =
1 THEN '<span style="color:#428bca;font-weight:bold;">Due in ' || (TO_DATE(TO_CHAR({startdate},
'MM/DD/YYYY'), 'MM/DD/YYYY') - TO_DATE(TO_CHAR(SYSDATE, 'MM/DD/YYYY'), 'MM/DD/YYYY')) || '
day</span>' ELSE '<span style="color:#428bca;font-weight:bold;">Due in ' ||
(TO_DATE(TO_CHAR({startdate}, 'MM/DD/YYYY'), 'MM/DD/YYYY') - TO_DATE(TO_CHAR(SYSDATE,
'MM/DD/YYYY'), 'MM/DD/YYYY')) || ' days</span>' END

Using Case When to determine when an item was sold for free
case when {item.custitemcommission_parent}='Software Support' and {amount}<1 then
{item.custitem_purchase_price}end

Mass Update for Last Sales Face to Face


This is used on a Customer Mass update that is looking at event dates and a dropdown field (On the
event) for type of face-to-face activity, then updating the customer record with the activity date. This
Mass Update runs nightly.
Case when {activity.date}>{lastface2face.custentity} Then {activity.date} else (CASE WHEN {custentity55}
IS NULL THEN {activity.date} ELSE { lastface2face.custentity } END) end

Decode
Simple Case When with Decode
Case {custeventcall_outcome} when 'Connect' then (DECODE (to_char({createddate}, 'D'), '2' , 1))end

Decode with Multiple Case When


Compares expr to each search value one by one. If expr is equal to a search, the corresponding result is
returned. If no match is found, default is returned. (Account segmentation grading 2)
DECODE(((case {custentityacc_seg_comp_size}when'Low' then 1 when 'High' then 3 when 'Medium'
then 2 when 'None/Unknown' then 0 else 0 end)+(case {custentityacc_seg_upgradeables}when'Low'
then 1 when 'High' then 3 when 'Medium' then 2 when 'None/Unknown' then 0 else 0 end)+(case
{custentityacc_seg_relationship} when'Low' then 1 when 'High' then 3 when 'Medium' then 2 when
'None/Unknown' then 0 else 0 end)+(case {custentityacc_seg_service_pont}when'Low' then 1 when
'High' then 3 when 'Medium' then 2 when 'None/Unknown' then 0 else 0
end)),12,'A',11,'A',10,'A',9,'A',8,'B',7,'B',6,'B',5,'C',4,'C',3,'C',2,'C',1,'C')

Look at date and determine the month


Decode
((to_char({date},'MM')),'01','January','02','February','03','March','04','April','05','May','06','June','07','Jul
y','08','August','09','September','10','October','11','November','12','December')
Dealing with Null Data
NVL
NVL allows you to replace null with the second parameter
NVL({shipstate},{billstate})

(({billingtransaction.amount}-(NVL({billingtransaction.discountamount},0)))-(case
{item.custitemcommission_parent}when'Software Support' then ({billingtransaction.amount}*.5) when
'InkJets' then (case when {purchaseorder.amount}='0' then (NVL({item.lastpurchaseprice},0)*{quantity})
else {purchaseorder.amount} end) when'Training' then ({billingtransaction.amount}*.5)
when'Consulting' then ({billingtransaction.amount}*.5) when'Imaging Services - All Formats' then
({billingtransaction.amount}*.5) when'Hardware Maintenance Program' then
({billingtransaction.amount}*.7) Else {purchaseorder.amount} end))*{contribution}

NVL2
Use NVL2 to provide link when a field is not null
NVL2({custbody_ec_mg_contracts_billing},('<a name="Edit"
id="Edit"href="'||'https://system.netsuite.com/app/common/custom/custrecordentry.nl?rectype=215
&id='||{custbody_ec_mg_contracts_billing.internalid}||'&e=f"target="_blank">EContract</a>'),'1')

Nullif
Using NULLIF compares expr1 and expr2. If equal, the function returns null. If not equal, the function
returns expr1.
NULLIF(({billingtransaction.amount}-(NVL({billingtransaction.discountamount},0)))-(case
{item.custitemcommission_parent}when'Software Support' then ({billingtransaction.amount}*.5) when
'InkJets' then (case when {purchaseorder.amount}='0' then (NVL({item.lastpurchaseprice},0)*{quantity})
else {purchaseorder.amount} end) when'Training' then ({billingtransaction.amount}*.5)
when'Consulting' then ({billingtransaction.amount}*.5) when'Imaging Services - All Formats' then
({billingtransaction.amount}*.5) when'Hardware Maintenance Program' then
({billingtransaction.amount}*.7) Else {purchaseorder.amount}
end),0)/NULLIF(({billingtransaction.amount}-(NVL({billingtransaction.discountamount},0))),0)

Using SUM and Nullif to Divide 2 formulas…


(SUM(case when {item.type}in('Service', 'Non-inventory Item') then {amount} end))/(Sum(NULLIF((Case
when {item.type}='Inventory Item' then {amount} end),0)))

Managing Text
Remove characters from text
Provided By Danielle Tourdot from WiscNet: I recently needed to remove the first 3-5 characters from
our Transport Provider ID to only give the name of the Transport Provider. Here is the formula that I
used:
case when {custrecord_transport_provider_id} like '%' then
(SUBSTR({custrecord_transport_provider_id},INSTR({custrecord_transport_provider_id},' ')+1)) else
{custrecord_transport_provider_id} end

Display only portion of text


Provided by Michael Anderson from DIY Home Center: Only display child matrix portion of item ID,
Formula (Text). For example, ABC : 123 would return 123. “!=0” is “not equal”.
case when instr({itemid},' : ')!=0 then substr({itemid},instr({itemid},' : ')+3) else {itemid} end

Concat
Concatenate two fields
Provided by Lisa Lijewski from Cielo: When you have multiple lines on one record, concatenate the internal
ID and the Line no. for a unique identifier (to be able to upload/update each individual line on a record).
{internalid} || {line}

Using CONCAT Statement


{item.name}||' '||{item.description}
CONCAT('<a name="register"
id="register"href="https://forms.netsuite.com/app/site/crm/externalcasepage.nl?compid=652186&for
mid=157&h=84b4cbf55b608a034de9&location=',CONCAT({location},CONCAT('&start_date=',CONCAT({c
ustevent_start_date},CONCAT('&item_id=',CONCAT({custeventitemid},CONCAT('&item_title=',CONCAT({
title},'&ck=S4dJ-jw1ASsrCek-&vid=RYDWtmnwABhEExDK&cktime=79094 ">Register</a>' ))))))))

Using CONCAT Statement in a Mass Update Fields Formula


concat({custrecord_noteson},' *')

RPad/LPad
The RPAD and LPAD allows you to remove characters from a string at a specific point and direction for
Example LPAD(‘tom’, 2) will return ‘to’. RPAD removes from the Right and LPAD from the Left.
rpad({item.displayname},60) will display only the first 60 characters.

SUBSTR
The SUBSTR allows you to show characters after a point in the verbiage
Example:
Created From Field returns result: Purchase Order #PO12345, only want to see PO12345
The total characters from the beginning of the field info to where the PO starts is 16 characters
case when {type}='Purchase Order' then (substr({createdfrom},17)) end
***Had to add an additional character count to have the # remove from the verbiage

Provided by Lisa Lijewski from Cielo: Change the posting/accounting period into a three-digit month
format

SUBSTR({postingperiod},1,3)
Provided by Lisa Lijewski from Cielo: Extract a substring from a string using expression pattern
matching. This one gives us the customer name (entity field) from the beginning of the string up to the
colon (as we use customer: project hierarchy, but want parent customer for reporting). Good for when
the (no hierarchy) is not available on a search field.
RTRIM(REGEXP_SUBSTR({entity},'[^:]*'))

Clean up Phone Numbers using “Replace”


This formula is very useful for removing characters from a field this formula is using on a contact and is
cleaning up the Phone Number from (608) 785-1900 to 6087851900.
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE({phone},'('),')'),' '),'-'),'.')

Formatting
Using check Box in a Formula and Inline HTML
Case when {custrecord_hw_top_customer}=’T' then '<span style="font-family:Times;font-size:22px;font-
style:normal;font-weight:bold;text-decoration:none;text-transform:none;color:33cc33;background-
color:ffffff;">Imaging Top Customer </span>' else (Case when {custrecord_curr_custom_tier}='MG
TOP 200'then '<span style="font-family:Times;font-size:22px;font-style:normal;font-weight:bold;text-
decoration:none;text-transform:none;color:33cc33;background-color:ffffff;">MG TOP 200
</span>' end) end

Controlling Column and Row data in Searches


Using HTML code in your Saved Searches can provide better space utilization, and more visible data in
the Column Headers as well as in the Results (in the search rows).

HTML Text Tags


<hl></hl> Creates the largest headline
<h6></h6> Creates the smallest headline
<b></b> Creates bold text
<i></i> Creates italic text
<tt></tt> Creates teletype, or typewriter-style text
<em></em> Emphasizes a word (with italic or bold)
<strong></strong> Emphasizes a word (with italic or bold)
<font size="3"></font> Sets size of font, from 1 to 7
<font color="green"></font> Sets font color, using name or hex value
<br> Inserts a line break

NetSuite Custom Label coding


Aligns text center, adds space top/bottom
<p style="text-align:center; padding: 10px;">Next Steps</p>
Expands column width, text left justified: <table width="400"> Label Name</table>
Expands column width, text centered: <center><table width="400"> Next Steps</table></center>
Formula Example:
NVL2({custrecordlead_contact_ref},(NVL2({custrecord_tc_contract_id},('<a name="Send Email Custom"
id=" Send Email Custom

"href="https://system.netsuite.com/app/crm/common/crmmessage.nl?&contact='||{custrecordlead_c
ontact_ref.internalid}||'&entity='||{custrecordlead_customer_ref.internalid}||'&record='||{internalid}
||'&recordtype=272&xnew=T&l=T&templatetype=EMAIL&template=1162&cf=65"target="_blank">Sen
d Welcome Email</a>'),'Fix Contract Details<BR> <------- ')),'<b>Need</b> to Fix <BR> Contact
Ref')

Column Label Example:


Check to Mark <BR> Contact as Approved <BR> for Training
Quick Links
Using quick link pop-up for inline editing
'<a href="#"
onclick="window.open(''https://system.netsuite.com/app/site/hosting/scriptlet.nl?script=191&deploy=
1&recid=' || {internalid} ||
''',''selection'',''dependent=yes,height=400,width=300,scrollbars=no,statusbar=no,titlebar=no,menubar=
no,resizeable=yes,location=no'');">LINK TEXT</a>'

Customer Quick View Link (Text Formula)


'<a name="QuickView"
id="QuickView"href="'||'https://system.netsuite.com/app/common/entity/custjob.nl?id='||{customer.i
nternalid}||'&print=T&cf=111"target="_blank">QuickView</a>'

Log a Call with loaded customer and contact information


'<a name="Log Call" id="Log
Call"href="https://system.netsuite.com/app/crm/calendar/call.nl?l=T&refresh=activities&transaction='|
|{internalid}||'&invitee='||{customer.internalid}||'&company='||{customer.internalid}||'&contact='||
{custbody7.internalid}||'&status=COMPLETE"target="_blank">Log Call</a>'

Log a Call with loaded customer, contact, and support contract information
'<a name=" Log Call " id=" Log Call
"href="'||'https://system.netsuite.com/app/crm/calendar/call.nl?status=COMPLETE&l=T&refresh=activi
ties&invitee='||{internalid}||'&company='||{custrecord_customer.internalid}||'&contact='||{custrecor
d_contact.internalid}||'&pf=custevent_supp_cont&pi='||{internalid}||'&cf=309"target="_blank">Log
Call</a>'
View Contracts
'<a name="Contracts"
id="Contracts"href="https://system.netsuite.com/app/common/search/searchresults.nl?rectype=105&s
earchtype=Custom&ADW_Entity_INTERNALID='||{custrecord_customer2.internalid}||'&sortcol=CUSTR
ECORD_EXP_DATE_raw&sortdir=ASC&csv=HTML&OfficeXML=F&pdf=&style=NORMAL&report=&grid=&
searchid=2995&dle=T"Target="_blank">Contracts</a>'

Send Custom Email


'<a name="Send Email Custom" id=" Send Email Custom
"href="https://system.netsuite.com/app/crm/common/crmmessage.nl?&contact='||{custrecordec_ma
nager_contact.internalid}||'&entity='||{custrecord_ec_c_customer.internalid}||'&record='||{internalid
}||'&recordtype=215&xnew=T&l=T&templatetype=EMAIL&template=477&cf=65"target="_blank">Send
Email MP</a>'

Create a Deal
'<a name="Create Deal" id="Create
Deal"href="'||'https://system.netsuite.com/app/accounting/transactions/estimate.nl?entity='||{Custo
mermain.internalid}||'&cf=217"target="_blank">Create Deal</a>'

View Activities
'<a name="Activites"
id="Activities"href="'||'https://system.netsuite.com/app/crm/common/crmactivityhistory.nl?id='||{cus
tomer.internalid}||'&fkcol=kCompany"target="_blank">Activities</a>'

Edit Customer
'<a name="Edit"
id="Edit"href="'||'https://system.netsuite.com/app/common/entity/custjob.nl?id='||{custrecord_ec_c
_customer.internalid}||'&cf=63&e=T"target="_blank">Edit</a>'

Selecting an Email Template and assign Contact from a Link (Text formula)
'<a name="Send Email Custom" id=" Send Email Custom
"href="https://system.netsuite.com/app/crm/common/crmmessage.nl?&contact='||{custrecordec_ma
nager_contact.internalid}||'&entity='||{custrecord_ec_c_customer.internalid}||'&record='||{internalid
}||'&recordtype=215&xnew=T&l=T&templatetype=EMAIL&template=476&cf=65"target="_blank">Send
Email FSMA</a>'
Sending an Email from a transaction search (Text formula)
'<a name="Send Email" id=" Send Email
"href="https://system.netsuite.com/app/crm/common/crmmessage.nl?transaction='||{internalid}||'&e
ntity='||{customer.internalid}||'&l=T&templatetype=EMAIL"target="_blank">Send Email</a>'
Calculation Functions
Math
Show quantity within a range
Provided by Jenny Berg from Forte Research: To show the number of employees in each age range
group
CASE WHEN (ROUND(ROUND({today}-{birthdate},2)/365)) between '1' and '19' THEN 'Under 20' WHEN
(ROUND(ROUND({today}-{birthdate},2)/365)) between '20' and '24' THEN '20-24' WHEN
(ROUND(ROUND({today}-{birthdate},2)/365)) between '25' and '29' THEN '25-29' WHEN
(ROUND(ROUND({today}-{birthdate},2)/365)) between '30' and '34' THEN '30-34' WHEN
(ROUND(ROUND({today}-{birthdate},2)/365)) between '35' and '39' THEN '35-39' WHEN
(ROUND(ROUND({today}-{birthdate},2)/365)) between '40' and '44' THEN '40-44' WHEN
(ROUND(ROUND({today}-{birthdate},2)/365)) between '45' and '49' THEN '45-49' WHEN
(ROUND(ROUND({today}-{birthdate},2)/365)) between '50' and '54' THEN '50-54' WHEN
(ROUND(ROUND({today}-{birthdate},2)/365)) between '55' and '59' THEN '55-59' WHEN
(ROUND(ROUND({today}-{birthdate},2)/365)) between '60' and '64' THEN '60-64' WHEN
(ROUND(ROUND({today}-{birthdate},2)/365)) between '65' and '69' THEN '65-69' WHEN
(ROUND(ROUND({today}-{birthdate},2)/365)) between '70' and '74' THEN '70-74' WHEN
(ROUND(ROUND({today}-{birthdate},2)/365)) between '75' and '79' THEN '75-79' WHEN
(ROUND(ROUND({today}-{birthdate},2)/365)) between '80' and '84' THEN '80-84' WHEN
(ROUND(ROUND({today}-{birthdate},2)/365)) between '85' and '89' THEN '85-89' ELSE NULL END

Calculate Gross Profit


Provided by Lisa Lijewski from Cielo:
(case when {accounttype}=’income’ then {grossamount} else 0 end)-(case when{accounttype}=’Cost of Sales’
then {grossamount} else 0 end)

Calculate Days to a Date


Provided by Lisa Lijewski from Cielo:
{applying transaction.trandate}-{trandate}

Calculate Days between Dates using System Notes


Provided by Delilah Ruch from Apogee:

case when {entitystatus}='Closed Won' then ((case when {systemnotes.newvalue}='Closed Won' then
{systemnotes.date} end)-{datecreated})end

Total sales
nvl((case when {Type}='Credit Memo' then (({amount}-(NVL({discountamount},0)))*{contribution}) else
(({billingtransaction.amount}-(NVL({billingtransaction.discountamount},0)))*{contribution})end) ,(case
when {Type}='Credit Memo' then (({amount}-(NVL({discountamount},0)))*1) else
(({billingtransaction.amount}-(NVL({billingtransaction.discountamount},0)))*1)end))

Total Cost
(case {item.custitemcommission_parent}when'Software Support' then ({billingtransaction.amount}*.4)
when 'InkJets' then (case when {purchaseorder.amount}='0' then
(NVL({item.lastpurchaseprice},0)*{quantity}) else {purchaseorder.amount} end) when'Training' then
({billingtransaction.amount}*.4) when'Consulting' then ({billingtransaction.amount}*.4) when'Imaging
Services - All Formats' then ({billingtransaction.amount}*.5) when'Hardware Maintenance Program'
then ({billingtransaction.amount}*.7) when'Software - Kubotek' then ({billingtransaction.amount}*.8)
Else {purchaseorder.amount} end)*{contribution}

Gross Profit Dollars


(({billingtransaction.amount}-(NVL({billingtransaction.discountamount},0)))-(case
{item.custitemcommission_parent}when'Software Support' then ({billingtransaction.amount}*.4) when
'InkJets' then (case when {purchaseorder.amount}='0' then (NVL({item.lastpurchaseprice},0)*{quantity})
else {purchaseorder.amount} end) when'Training' then ({billingtransaction.amount}*.4)
when'Consulting' then ({billingtransaction.amount}*.4) when'Imaging Services - All Formats' then
({billingtransaction.amount}*.5) when'Hardware Maintenance Program' then
({billingtransaction.amount}*.7) when'Software - Kubotek' then ({billingtransaction.amount}*.8) Else
{purchaseorder.amount} end))*{contribution}

Getting year to date (YTD) revenue in transaction search


This Fiscal year to date:
case when {type}in('Cash Sale','Sales Order','Credit Memo','Invoice') and {trandate} >=
add_months(trunc({today},'YYYY'),decode(sign(to_char({today},'MM')-10),1,10,-2)) then
({Netamount}*(NVL({contribution},1))) end
Previous Fiscal year to date:
case when {type}in('Cash Sale','Sales Order','Credit Memo','Invoice') and {trandate} >=
add_months(trunc({today},'YYYY'),decode(sign(to_char({today},'MM')-10),1,-2,-14)) and {trandate} <=
add_months({today}, -12) then ({Netamount}*(NVL({contribution},1))) end
Previous Fiscal Year to date Margin
case when {type}in('Cash Sale','Sales Order','Credit Memo','Invoice') and {trandate} >=
add_months(trunc({today},'YYYY'),decode(sign(to_char({today},'MM')-10),1,-2,-14)) and {trandate} <=
add_months({today}, -12) then (NVL({custcolact_margin},({Amount} -
({item.lastpurchaseprice}*{quantity}))*(NVL({contribution},1))) ) end
Note: The -10 in each formula is setting the start of the Fiscal year as November.

Calculate Subtotal
nvl2({netamountnotax},{netamountnotax},{amount})

Date
Used to calculate a date 60 days in the future
{today}+60

Show the day of the week


Provided by Jenny Berg from Forte Research: To show the day of week (Friday) rather than the date
(4/20/2018)
TO_CHAR({date},'DAY')
Using MAX with Date range to select Month range
(Case (to_char({today},'MM')) when '01' then (MAX({salesrep.custentity_p_t_q1})) when '11' then
(MAX({salesrep.custentity_p_t_q1})) when '12' then (MAX({salesrep.custentity_p_t_q1})) when '02' then
(MAX({salesrep.custentity_p_t_q2})) when '03' then (MAX({salesrep.custentity_p_t_q2})) when '04' then
(MAX({salesrep.custentity_p_t_q2})) when '05' then (MAX({salesrep.custentity_p_t_q3})) when '06'
then (MAX({salesrep.custentity_p_t_q3}))when '07' then (MAX({sales`rep.custentity_p_t_q3}))else
(MAX({salesrep.custentity_p_t_q3}))end)/3

Using TO_CHAR to find last month in a date field


case when (to_char({time.datecreated},'mm'))=(to_char({today}, 'mm')-1) then {time.durationdecimal}
end

Using the TO_CHAR to select data for a specific day of the week
case when to_char({time.date},'D')='1' then {time.durationdecimal} end = Sunday
case when to_char({time.date},'D')='2' then {time.durationdecimal} end = Monday

Search to compare an Expiration date to today’s date


case when (to_char({custrecord_customer.custrecord_exp_date},'DD/MM/YYYY')) >
(to_char({today},'DD/MM/YYYY')) THEN 'T' ELSE 'F' END

Scripts
Sample Script (Work Flow Action Script)
This script sample is used to update a field on the customer from a Custom Record workflow. A
Workflow Action script allows you to run a script within a workflow. This function allows you to update
associated records from a workflow, this is very handy to “Carry Data Forward”
//**Formula to write data from a contracts workflow to the attached Customer record **
//***In order to create a WorkFlow Action, you need 3 netsuite objects, first the physical script (the
code), second is the SCRIPT Record in netsuite, this is where you connect the script to a function
(Contracts_Customer), and lastly you need a SCRIPT DEPLOYMENT record. Example of this in NS:
Physical script us "Preview masterGraphics.js", SCRIPT Record is "Master G - Test Tom" (This is also the
name of WorkFlow Action) and the SCRIPT DEPLOYMENT "Customdeploy1" This sample workflow is
designed to work from a CustomRecord (Contrats) to a Customer, thus the fields are noted from the
CustomRecord standpoint ***
function Evolve_Contracts_Customer(){
// Getting the data / values needed
var custRec = nlapiGetFieldValue('custrecord_customer');
var custName = nlapiGetFieldValue('name');
var expdate = nlapiGetFieldValue('custrecord_exp_date');
//Combining the data into a single Variable
var data = (custName + " EXP: " + expdate)
//Selecting the Record Type that will be updated
var recId = nlapiLoadRecord('customer',custRec);
//Writing the field value
recId.setFieldValue('custentity_training_sub_end',data);
//Submitting / Saving the Record
var rec = nlapiSubmitRecord(recId);
}
// Script End

Build workflow and set new action as the name of the script

Additional Script Example


//Script start
function Call_update_contract(){
//select contract to be changed: for this script the contract# loads to a phone call record so the script is
looking at the support contract# on the phone call.
var contractRec = nlapiGetFieldValue('custevent_supp_cont');
//get a date field to write to the last call date field
var currentdate = nlapiGetFieldValue('completeddate');
//open contract
var recId = nlapiLoadRecord('customrecord105',contractRec);
//write data to be updated
recId.setFieldValue('custrecord_last_mgd_serv_call',currentdate);
//save record
var rec = nlapiSubmitRecord(recId);
}
………………………

Miscellaneous
Using a MAX Command inside a formula (used in actual VRS Forecast)
MAX(case {item.custitem_commission_code}when '1' then {salesrep.custentity_p_1_q1} when'2' then
{salesrep.custentity_p_2_q1} when'3' then {salesrep.custentity_p_3_q1} when'16' then
{salesrep.custentity_p_16_q1} when'15' then {salesrep.custentity_p_15_q1} when'17' then
{salesrep.custentity_p_17_q1} when'13' then {salesrep.custentity_p_13_q1} when'9' then
{salesrep.custentity_p_9_q1} when'7' then {salesrep.custentity_p_7_q1} when'4' then
{salesrep.custentity_p_4_q1} when'5' then {salesrep.custentity_p_5_q1} when'11' then
{salesrep.custentity_p_11_q1} when '8' then {salesrep.custentity_p_8_q1} when '14' then
{salesrep.custentity_p_14_q1} end)

Who Last Modified


Provided by Lisa Lijewski from Cielo: To see who last modified something:
Min({systemnotes.name})keep(dense_rank last order by {systemnotes.date})

Search for a work for sequence in a field using REGEXP_INSTR


Using this formula you can search a field (displayname) for (STE) then return the position of the
characters that it is looking for. The (1,1,1,'i') are all a default and usually can stay the same. The
formula below is used to count the number of times the “STE” is found in the item display name; then, if
found, enter a 1, otherwise enter 0. This is very handy in the summary criteria of a search.
case when REGEXP_INSTR({item.displayname},'Ste',1,1,1,'i')>1 then 1 else 0 End

Not Equal To
case when ({type}='Deal' and ({status}<>'Processed') and {custbody20}='Lost Deal') then {internalid}end

Finding First not Null field from list of fields using Coalesce
You can use the function Called Coalesce to search a list of fields and then write the first not Null value.
Used this in a Workflow that was looking at 3 date fields, we need to find a field that was not null then
write the date.
COALESCE({custrecord_asset_expire},{custrecord_exp_date}, {custrecord6})

Using an URL to Enter Data on an Online Form


This is a very useful way to enter data on any online forms (online Case forms, Custom Records,
Marketing forms). To do this you need to first build a template with the fields hidden (this is not a
requirement but this way the customer doesn’t see the data) this is done with a bit of url code. Second
step is to click on the External URL (you have to click on it do not just copy and paste) and add
"$fieldname=what you want to enter" then run and test your new url.

https://forms.netsuite.com/app/site/crm/externalcustrecordpage.nl?compid=652186&formid=212&h=
e4257034c558ffb566a1&redirect_count=1&did_javascript_redirect=T&custrecordlead_source=SAMPLE
Note: If you are using a field that is list value you need to use the internal ID for the value you want
selected.

Using a Saved Search to fill as a default value in field


This is a very useful tool to sum up things like total time on a project or Case. The major limitation is
that you cannot use these field in searches, workflows or mass updates. The Trick to success with this is
to build a summing search (the results should have one number, these are often used for KPIs or
ScoreCards) making sure you have a filter (I use internal ID) that the system can use to isolate the data.
Then when you create the Field just enter the saved search on the Validation & Defaulting tab then
make sure the store value is unchecked. To learn more about this search help for: “Summary Searches”
or “Creating Custom Fields with Values Derived from Summary Search Results”.

Using MAX and SUM in the same formula


This formula was set up and used in a Formula (Numeric) set to Maximum. The Purpose of the this
formula is to calculate the how much time is left on a case. The ..so_time field is the total time available
on the case.
(Max({custevent_so_time}))-(SUM({time.durationdecimal}))

Wildcards
case when {transaction.item} like '%Imag%' then 'Yes' end

You might also like