use record.type as script parameter from a script ...
# ask-stanley-ai
t
use record.type as script parameter from a script deployment
c
AI generated answer (using internal Slack threads):
In order to use
record.type
as a script parameter from a script deployment, you can access it from the context variable. This can be useful when you want the same script to run on multiple record types and vary slightly based on which record type triggered it. Here is an example of how you can access the `record.type`:
Copy code
javascript
function beforeLoad(context) {
    var recordType = context.newRecord.type;
    // your code here
}
In this example,
context.newRecord.type
will give you the type of the record that triggered the script. In addition, you can set a script parameter with code rather than the UI. However, this is undocumented and may break at any time. Here is an example of how you can do this:
Copy code
javascript
record.submitFields({
  id: deploymentInternalId,
  type: record.Type.SCRIPT_DEPLOYMENT,
  values: {
    "custscript_interco_je_last_run_date": format.format({type: format.Type.DATETIME, value: runDate.toDate()}),
  },
})
In this example,
custscript_interco_je_last_run_date
is the script parameter and
format.format({type: format.Type.DATETIME, value: runDate.toDate()})
is the value you want to set for the script parameter. ****** 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.856871903
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.832421184
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.831514716
Please provide your feedback on this answer.