Add Buttons into Saved Searches

07/28/2023 02:17 PM - By MavenCloud

Saved searches are one of the most powerful and versatile features of NetSuite, and sometimes the most under-utilized.  Saved searches are most commonly used to quickly find data or inadvertently created when someone is trying to perform a quick "one-off" search of some records.  However, a saved search can be so much more than that.  Saved searches can be used to extract data from NetSuite on an efficient and consistent format.  They can be used to provide reminders and email notifications to both internal users and/or external relationships.  They are the basis of KPI's, charts, graphs and other dashboard elements.  Furthermore, they can be used as almost a "workspace" to help organize tasks and consolidate data into one efficient workspace for a particular user or department.  One of the key ways to elevate your saved searches is the use of Formulas.  NetSuite offers many types of formulas that can be used in many different ways:

  • Formula (currency) - the output produced by this formula is a numerical value with 2 decimal places
  • Formula (date) - the output produced by this formula is in date format
  • Formula (numeric) - the output produced by this formula is a numeric value and can contain many decimal places
  • Formula (HTML) - the output produced by this formula is denoted by the HTML elements placed within the formula (usually links)
  • Formula (text) - the output produced by this formula is in text format.
In this article we will discuss the use of the Formula (HTML) to provide links within your saved search.

One thing to note on using URLs is that Netsuite documentation recommends you use a "non-specific" URL so you do not run into access issues between different environments.  What this means is you would only place the part of the URL after the domain in your href instead of including the domain and account number.  This would help if you are trying to use this links between Production and Sandbox accounts because a Sandbox account has a different account number.  (ie. Production = 1234567 and Sandbox = 1234567-sb1).  This is why we use the non-specific "system.netsuite.com" domain within our Formula (HTML).  Alternatively you can just use the URL path after the domain and usually NetSuite will automatically append the path onto the current domain you are logged in under.  With this in mind you would update the Formula (HTML) example below to be the following:


'<a href=''/app/accounting/transactions/transaction.nl?id='|| {internalid} ||'&whence=''>'|| {number} ||'</a>'


This way NetSuite will reference the current account domain the user is logged in under, into the URL while redirecting the user to the linked URL.  We have experienced mixed results with this so we don't always recommend it initially trying to leverage either the non-specific system.netsuite.com domain OR the domain path.  Then if you experience errors you can add in an account specific domain where necessary.

Adding links within your saved search can not only help users navigate through NetSuite quickly and easily, but also provide quick access to records and information directly related to the content searched and displayed within your saved search.  One of the most common ways to utilize links within saved searches is to provide a link to a joined record.  For example, if you have created a Item Search then the native Edit/View link provided by the system will only navigate to the Item record.  


However, you may be joining to related transactions within this search and may want to give the user an easy way to open the transaction record.  This is easily done through a Formula (HTML) and an "href" element.  Add a Formula (HTML) into the results of your saved search and then use the following formula:


'<a href=''https://system.netsuite.com/app/accounting/transactions/transaction.nl?id='|| {internalid} ||'&whence=''>View</a>'


A few things to note with this formula:

  1. You can also replace "system" in the URL with youraccountnumber.app where youraccountnumber is the account number of your NetSuite environment. (ie https//1234567.app.netsuite.com/app/accounting, etc)  This will restrict your link to ONLY work within the environment you have entered.
  2. The text entered between the <a> and </a> elements is what is displayed to the user to click on.  You can change this to whatever you like.  You can also use double pipes to concatenate a field value here as well.  So instead of the link saying "View" you can have it list the Document Number of the transaction by instead changing the formula to:

'<a href=''https://system.netsuite.com/app/accounting/transactions/transaction.nl?id='|| {internalid} ||'&whence=''>'|| {number} ||'</a>'

Now the Transaction Number will be displayed AND it will be clickable to the user, redirecting them to the transaction listed in the results row of the saved search.

To help manage the user experience you can also update the <a> element with a notation so a new window is opened.  This way the user does not have to go back and reload the saved search after viewing or updating the transaction.  To do so we need to add a target attribute.  The resulting formula HTML would look like this:

'<a href=''https://system.netsuite.com/app/accounting/transactions/transaction.nl?id='|| {internalid} ||'&whence='' target="_blank">'|| {number} ||'</a>'

Another nice trick to help the user experience is to open the record in Edit mode to save the user from more clicks to make changes to the record.  To do so we can add a parameter of "e=T" into the URL.  The resulting URL would be:

'<a href=''https://system.netsuite.com/app/accounting/transactions/transaction.nl?id='|| {internalid} ||'&e=T&whence='' target="_blank">'|| {number} ||'</a>'

Now that we have a good grasp on how links will work we can work on turning this into a button instead of just hyperlinked text.  To do this we need to add a <button> wrapper around the Link Text so it is displayed as a button instead of hyperlinked text.  The resulting URL would be:

'<a href=''https://system.netsuite.com/app/accounting/transactions/transaction.nl?id='|| {internalid} ||'&e=T&whence='' target="_blank"><button type="button">'|| {number} ||'</button></a>'

Now we have a button displayed instead of hyperlinked text showing in our saved search.   Also, when clicked a new window will open AND the record will be opened in edit mode so the user can quickly and easily update the information.



You can also change some of the formatting of the button by using the "style" attribute inside the <button> element.  Some applicable attributes would be:
  • font-size
  • font-weight
  • font-style
  • color
  • background-color
So you could give your button a color with a style attribute and the resulting URL would be:

'<a href=''https://system.netsuite.com/app/accounting/transactions/transaction.nl?id='|| {internalid} ||'&e=T&whence='' target="_blank"><button type="button" style="background-color:red">'|| {number} ||'</button></a>'

And the user would see a formatted button in the saved search

One more feature you could add into this would be to open a pop-up window for the record instead of a new window or in the same window.  To do this you would add a "onclick" attribute into the overall <a> element.  The syntax can be quite tricky but the resulting formula would be:


'<a href="#" onclick="window.open(''https://system.netsuite.com/app/accounting/transactions/transaction.nl?id='|| {internalid} ||'&e=T&whence='',''selection'',''dependent=yes,height=600,width=800,scrollbars=no,statusbar=no,titlebar=no,menubar=no,resizeable=yes,location=no'');"><button type="button" >'|| {number} ||'</button></a>'


The the user can open/edit the record right within a pop up window, make their changes, then quickly close the window and return to the saved search quickly to keep working through the rest of the result.



You can also use the parameters within the "onclick" attribute to help control the size and functionality of the pop-up window by changing the "height", "width", "location" or other parameters.

If you would like more information on how to leverage saved searches within your NetSuite environment or need help with any customization or enhancement feel free to reach out to us at any time.  Also be sure to subscribe and follow our blog for more great tips and tricks.

MavenCloud