Update Record With Button When Viewing In Browser: User Event & Client Scripts

How do you add an actionable button on the client-side view of a record in Netsuite that would allow the user, once the button is clicked, to insert something into the current record and have the changes saved to the record? I had a recent requirement where a button was needed on the client side when viewing a record. The intent was that if the user needed to update the record the button would invoke the process for refreshing the content on the record and update any necessary fields. ...

March 11, 2023 · 7 min · 1444 words · Ryan Sheehy

Sort List By Second (or Nth) Element In Python: 1 Line Of Code

How do you sort a list of lists by the second element using Python? To sort a list of lists by the second element in each list use the key parameter to either the .sort() list function (if modifying the original list) or the sorted() function (if returning a new list). Here’s an example demonstrating how you can do this with code: 1 2 3 4 >>> list_2d = [['2nd', 2], ['3rd', 3], ['1st', 1]] >>> list_2d.sort(key=lambda x: x[1]) >>> print(list_2d) [['1st', 1], ['2nd', 2], ['3rd', 3]] As you can see from the above code the key parameter in the .sort() list function uses a lambda expression which takes each list and extracts the second element. This is used as the key to determine how each list will be sorted. ...

November 5, 2022 · 2 min · 320 words · Ryan Sheehy

Google Sheets Named Functions In 5 Minutes

What is a named function in Google Sheets and when is it best to use this new feature in your spreadsheet? Google Sheets new Named Functions feature enables you to refactor long formulas into what appears as a native function in your Google Sheets spreadsheet. Use this feature in Google Sheets if you find you are using a complex formula more than once within your Google Sheets. A recent need I found was with a finance spreadsheet which helped to calculate the right amount of tax to withhold. The original formula referenced a tax table that provided the variables to complete a linear function. ...

October 26, 2022 · 7 min · 1402 words · Ryan Sheehy

Google Sheets SWITCH Formula Example: Refactor IF Functions By 20%

How do you use the Google Sheets SWITCH() formula? The SWITCH() formula in Google Sheets enables you to compress a series of IF statements, even nested IF statements, into one succinct function. Take a recent example where I refactored the following formula which helped to add the appropriate years, months or days to an existing date. Here was the original formula which would calculate the next date according to an increment type: ...

October 22, 2022 · 7 min · 1377 words · Ryan Sheehy

How To Set A Default Value For VLOOKUP

How can you set a default value when using the VLOOKUP function? As VLOOKUP throws an #N/A error when the searched item cannot be found in the first column range, wrap the VLOOKUP function in an IFERROR formula and set the value to the default sought. For example like this: = I F E R R O R ( V L O O K U P ( s e a r c h , r a n g e , c o l u m n _ i d x , m a t c h _ t y p e ) , d e f a u l t _ v a l u e ) Where default_value is the placeholder where you would the data inserted into your spreadsheet if the item is not found in the first column of the range. ...

October 8, 2022 · 4 min · 701 words · Ryan Sheehy

SuiteScript Change On Credit Hold Field On Customer Record

How do you change the Hold field found on the customer record using SuiteScript? The Hold field in a Customer record prevents users or the customer from having any new Sales Orders being placed and has three settings On, Off and Auto. The code name of the field is creditholdoverride. To set the value for this field using SuiteScript, enter the value in all capital letters according to the value you want. ...

October 5, 2022 · 2 min · 259 words · Ryan Sheehy

How To Create A Radio Button In Suitelet Form

How do you create a radio button in a Suitelet form? To create a series of radio button elements in a Suitelet form you need to add each element of the radio series as distinct fields using the .addField function. The id property needs to be the same for each radio field and the source property needs to be unique for each element. Here’s an example demonstrating what this would look like where the user is required to select the option of “Direct Debit” or “Credit Card”: ...

September 28, 2022 · 4 min · 785 words · Ryan Sheehy

How To Remove From String In Python

How do you remove a newline character \n from a string in Python? The easiest way to remove a new line from a string in Python is by using the string method .replace(). Another way is to use the string method .strip() if the new line is at the start or end of the string. Here are some examples demonstrating how to remove the new line characters: 1 2 3 4 5 6 7 8 9 10 11 >>> s = """ ... This string has new lines ... everywhere! ... """ >>> print(s) This string has new lines everywhere! >>> s.replace('\n', '') 'This string has new lineseverywhere!' As you can see from the above output the string .replace() method takes two parameters: the first being the string to find and the second being the string to replace once found. ...

September 21, 2022 · 6 min · 1236 words · Ryan Sheehy

Close Python In Terminal: Command & Shortcut

How do you quit out of Python when you’re in an interactive shell environment? The easiest way to close the Python shell in Terminal is to issue the quit() command. Here’s an example demonstrating how to exit from a terminal window using the a-Shell app on the iPhone: As you can see from the example above I was able to access the Python interactive shell by entering python3 on the command line. This simple instruction invokes the Python REPL and enables the user to enter Python commands. ...

September 20, 2022 · 2 min · 250 words · Ryan Sheehy

Python: Move Files From One Directory To Another

How do you move files from one directory to another using Python? If you want to move specific files from one directory to another with Python, use the glob library to fetch the correct files, then use the os library’s rename method to change the current file to the new directory. Here is an example of how this might look using a Python script. 1 2 3 4 5 import os import glob current_dir = os.getcwd() old_files = os.path.join(current_dir, 'old_loc', '*.py') With the current code I have imported the 2 essential libraries needed to help co-ordinate the change, these being the os and glob libraries. ...

September 20, 2022 · 4 min · 799 words · Ryan Sheehy