use record.type as dynamic script parameter
# ask-stanley-ai
t
use record.type as dynamic script parameter
c
AI generated answer (using internal Slack threads):
In SuiteScript, you can use the
record.type
or
currentRecord.type
to get the type of the record you are working with. This can be used as a dynamic script parameter to determine the type of record that triggered the script. In a User Event script, you can access the record type using
Context.newRecord.type
. In a Client Script, you can get the record type using
currentRecord.type
. Both will return the record type enum. If you need the name of the record type instead of the id, you can perform a query on the ScriptRecordType table. For example, if you need to include a condition to check for the record type of "assemblyitem" in a User Event script, you can do so as follows:
Copy code
javascript
if (scriptContext.newRecord.type === 'assemblyitem') {
    // Your code here
}
In a Client Script, you can use
scriptContext.currentRecord.type
to get the record type. If
.type
is not returning anything, you may need to include the
N/currentrecord
module, depending on what you're doing in your script. ****** 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.818279326
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.814479649
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.813551903
Please provide your feedback on this answer.