use record.type as script parameter from deploymen...
# ask-stanley-ai
t
use record.type as script parameter from deployment in mass reduce script
c
AI generated answer (using internal Slack threads):
In order to use the same script for different record types and have it vary slightly based on the record type that triggered it, you can indeed create multiple deployments. To determine which deployment triggered the script, you can use the
Record.type
from the record. This is available in the context variable. Here is an example of how you can use it:
Copy code
javascript
var recordType = context.newRecord.type;
if (recordType === record.Type.SALES_ORDER) {
    // Do something for sales orders
} else if (recordType === record.Type.PURCHASE_ORDER) {
    // Do something for purchase orders
}
In this example,
context.newRecord.type
will give you the type of the record that triggered the script. You can then use this information to conditionally execute different parts of your script based on the record type. For your deployments, you can set a script parameter that loads a different configuration record that's specific to the subsidiary. This way, you can avoid having lots of conditionals checking if various features are enabled or not in the configuration record. ****** 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.829009295
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.813157856
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.812255442
Please provide your feedback on this answer.