ScheduleBatchUserScript
Schedules a script to run on the server at a later date.
| Service | Operation |
|---|---|
| script | SCHEDULE_BATCH_USER_SCRIPT |
Method Parameters
| Parameter | Description |
|---|---|
| scriptName | The name of the script with its path to be run. |
| scriptData | Data to be sent to the script in JSON format. |
| segmentCodeList | List of target segment codes. Omit, or pass an empty list, to send to all users. |
| segmentIdList | Deprecated: list of target segment ids. Use segmentCodeList instead. |
| startDateUTC | If scheduling at a set time. The start date in UTC in Unix millis timestamp format. |
| minutesFromNow | If scheduling in minutes from the current time. Number of minutes from now to run the script. |
warning
segmentIdList is deprecated. Use segmentCodeList instead. Segment ids are assigned separately in each environment, so the same id can refer to a different segment after an app is copied or promoted, and new apps reject segment ids in cloud code.
Usage
http://localhost:3000
- C#
- C++
- Obj-C
- Java
- JavaScript
- Dart
- Roblox
- GDScript
- Lua
- Cloud Code
- Raw
// S2S call: to view example, switch to the Cloud Code or Raw tab.
// S2S call: to view example, switch to the Cloud Code or Raw tab.
// S2S call: to view example, switch to the Cloud Code or Raw tab.
// S2S call: to view example, switch to the Cloud Code or Raw tab.
// S2S call: to view example, switch to the Cloud Code or Raw tab.
// S2S call: to view example, switch to the Cloud Code or Raw tab.
-- N/A
N/A
-- S2S call: to view example, switch to the Cloud Code or Raw tab.
var scriptName = "path/to/script1";
var scriptData = {
"parm": "value"
};
var segments = [
"high_spenders",
"lapsed_30d"
];
var startDateUTC = 1512750683157;
var minutesFromNow = 1;
var scriptProxy = bridge.getScriptServiceProxy();
var postResult = scriptProxy.scheduleBatchUserScript(scriptName, scriptData, segments, startDateUTC, minutesFromNow);
if (postResult.status == 200) {
// Success!
}
{
"service": "script",
"operation": "SCHEDULE_BATCH_USER_SCRIPT",
"data": {
"scriptName": "path/to/script1",
"scriptData": {
"parm": "value"
},
"segmentCodeList": [
"high_spenders",
"lapsed_30d"
],
"startDateUTC": "[[#ts+60000]]",
"minutesFromNow": 1
}
}
Common Error Code
Status Codes
| Code | Name | Description |
|---|---|---|
| 40793 | INVALID_SEGMENT_ID_LIST | None of the segment ids match a segment in the app |
| 41056 | INVALID_SEGMENT_CODE_LIST | None of the segment codes match a segment in the app |