SuiteScript Best Practices Flashcards

1
Q

When searching for a small amount of fields what module & function should we use instead of loading the record?

A

nSearch.lookupFields, instead of nRecord.load

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Consider the time zone your scripts must use. Which time zone will server side scripts use by default?

A

Server side scripts will use the time zone specified in your NetSuite account.

If necessary, be sure to convert your time zones before using them.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

For client scripts, what happens when using the Advanced Employee Permissions feature?

A

The search columns available to the user is dependent on the permissions assigned to their role.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

If using the Advanced Employee Permissions feature on a client script, how should we check if the role has access to that field before setting/getting data?

A

We should use .getFields().includes([FIELD ID]) to check if the role has access.
Client Script Best Practices

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

For a map/reduce script what are the governance limits for each entry point?

A

getInputData: 10,000
map: 1,000
reduce: 5,000
summarize: 10,000
Map/Reduce Governance

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

For a map/reduce script, which 2 entry functions must be kept relatively lightweight?

A

The map and the reduce entry points, because their governance is limited more than the getInputData or summarize functions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

An object returned from the getInputData function of a Map/Reduce script must be capable of being transformed into what format?

A

Key/Value pairs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

If using a search in the getInputData function of a Map/Reduce, what should we return and why?

A

We should return the nSearch.search object or a reference to the search, instead of the results.

This is because running the search and returning the results has a higher chance of the search timing out.
Map/Reduce Script Best Practices

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

A map/reduce script can be interrupted at any point by an application server disruption. Afterwards the script is restarted. What could this lead to?

A

Duplicate data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What can we do to minimise the risk of duplicates being created if a map/reduce fails because of a server disruption?

A

Set the retryCount and exitOnError options in the script.

Check the context.isRestarted property in each entry point of the sccript then handle if true.
System Response After a Map/Reduce Interruption

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Give an example of logic that we can use to avoid duplicates if a map/reduce fails because of a server disruption & the context.isRestarted property returned true?

A

Create a flag checkbox on records that will be processed via a map/reduce, so we can check if this record is already processed or not.

Ensure this checkbox flag is checked once processed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Why should we not change the buffer size field on a map/reduce script?

A

Because although this can increase the available processing time, but it has a higher chance to cause data duplication or loss.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How long ideally should a map/reduce or scheduled script be designed to run?

A

No more than 5 minutes, if possible.
Optimizing SuiteScript Performance

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Why should we schedule Scheduled Scripts to run between 2AM and 6AM PST?

A

This is the period of time that database activity will be at its lowest. Therefore scripts scheduled between 2AM and 6AM PST will run quicker.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

We should create twice as many non-scheduled deployments as the total number of simultaneous calls you anticipate for a scheduled script.

A

I don’t know why.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

When building a custom UI for Suitelets outside of the NetSuite UI, which API’s should we use to help users manage their credentials within the custom UI?

A

The N/auth Module and N/crypto Module
Suitelets and UI Object Best Practices

17
Q

What setting option for suitelets should be used only when absolutely necessary?

A

Available without login

18
Q

How long should suitelets optimally take at most to run?

A
19
Q

Regarding sensitive field values, what should we make sure not to do when developing user event scripts?

A

We should make sure the UE does not read a sensitive field value
User Event Script Best Practices

20
Q

Rather than trying to execute a user event script from another user event script, what should we do?

A

Create a custom module containing common code between the two user events, and use the module across both scripts.

21
Q

What is the maximum amount of time it should ideally take a user event to complete?

A

5 seconds or less

22
Q

True or False

We should aim to minimise API calls that perform Load, Search, or Save record operations.

A

True.

We should avoid saving multiple records in an After Submit function, and avoid loading and submitting a record in a Before Submit function.

23
Q

We should avoid loading and submitting records in what entry point?

A

Any Before Record Submit entry point.

24
Q

We should avoid saving MULTIPLE records in what entry point?

A

Any After Record Submit entry point

25
Q

If we have multiple searches required in a script that are on the same record type, what should we do?

A

We should attempt combining those searches into a single larger search.

26
Q

What module should we use instead of N/search when searching for large data sets?

A

We should use N/task to search for larger data sets.