RunBatchUserScriptForSegmentsAndCompletionScript
Runs a script against the users in the specified segments, and then a completion script at the end.
| Service | Operation |
|---|---|
| script | RUN_BATCH_USER_SCRIPT |
Method Parameters
| Parameter | Description |
|---|---|
| scriptName | The name of the script with its path to be run against each user |
| scriptData | Data to be sent to the script in JSON format. |
| segmentCodeList | Array of segment codes that identify the users to run the user script against |
| segmentIdList | Deprecated: array of segment ids. Use segmentCodeList instead. |
| completionScript | The name of the script with its path to be run once, after all users have been processed. |
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 = {
"queryStat": "xp"
};
var segments = [
"high_spenders",
"lapsed_30d"
];
var completionScript = "path/to/script2";
var scriptProxy = bridge.getScriptServiceProxy();
var postResult = scriptProxy.runBatchUserScriptForSegmentsAndCompletionScript(scriptName, scriptData, segments, completionScript);
if (postResult.status == 200) {
// Success!
}
{
"service": "script",
"operation": "RUN_BATCH_USER_SCRIPT",
"data": {
"scriptName": "calcUser",
"scriptData": {
"queryStat": "xp"
},
"segmentCodeList": [
"high_spenders",
"lapsed_30d"
],
"completionScriptName": "processResults"
}
}
JSON Response
{
"packetId": 1,
"messageResponses": [
{
"data": {},
"status": 200
}
]
}
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 |