- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 12-04-2020 12:14 AM
we have 4 types of pre post processing script. Please details about all types of script.
- Pre sensor
- Post Sensor
- Pre execution
- On Failure
Order of execution pre post processing script :
Pre sensor: You can change payload before it will be proccesed by Identification Engine. Use IEJsonUtility in order to add relevant information to the payload Input parameters in Pre sensor mode: payload, patternId
var rtrn = {};
//parsing the json string to a json object
var payloadObj = JSON.parse(payload);
//put your business logic here
//you can return a message and a status, on top of the input variables that you MUST return.
//returning the payload as a Json String is mandatory in case of a pre sensor script, and optional in case of post sensor script.
//if you want to terminate the payload processing due to your business logic - you can set isSuccess to false.
rtrn = {'status':{
'message':'Enter your message here',
'isSuccess':true
},
'patternId':patternId,
'payload':JSON.stringify(payloadObj)
};
Post sensor: You can update/add missing info to the DB based on result (Json) from Identification Engine Output parameters in Post sensor mode: payload
var rtrn = {};
//parsing the json string to a json object
var payloadObj = JSON.parse(payload);
//put your business logic here
//you can return a message and a status, on top of the input variables that you MUST return.
//returning the payload as a Json String is mandatory in case of a pre sensor script, and optional in case of post sensor script.
//if you want to terminate the payload processing due to your business logic - you can set isSuccess to false.
rtrn = {'status':{
'message':'Enter your message here',
'isSuccess':true
},
'patternId':patternId,
'payload':JSON.stringify(payloadObj)
};
Pre execution: This script will run before the execution of the assigned pattern/s it allows the user to add data that can be accessed by the running the pattern this is done by adding variables to the scriptable PrePatternExecutionData object below is an example of the possible variables that can be added.
var data = new SNC.PrePatternExecutionData();
// add a string with variable name 'stringA'
data.addString('stringA','string_value');
// add a list with variable name 'listA', value given must be a list
var lst = ['list_first_value','list_second_value'];
data.addList('listA',lst);
// this will create a new table variable 'tableA'
// the value given must be a map, whose keys will be the tables fields and values the first row
data.addTableEntry('tableA',{
'first_field':'row 1 arg1',
'second_field':'row 1 arg2'});
// this will add a second row to the previous table 'tableA'
// note that the keys in map must match the previous tables fields
data.addTableEntry('tableA',{
'first_field':'row 2 arg3',
'second_field':'row 2 arg4'});
//use this method if you want the pattern not to be executed
//data.executePattern(false);
//must return the data at end
rtrn = data;
On Failure: You can do operations in case a pattern failed.
var rtrn = {};
//put your business logic here
//you can return a message and a status, on top of the input variables that you MUST return.
//returning the payload as a Json String is mandatory in case of a pre sensor script, and optional in case of post sensor script.
//if you want to terminate the payload processing due to your business logic - you can set isSuccess to false.
rtrn = {'status':{
'message':'Enter your message here',
'isSuccess':true
},
'patternId':patternId
};
- 4,549 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Have a read though this post
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Thanks for sharing. Very nice article.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
In a post-sensor script how can you determine if the IRE detected an 'insert' or an 'update'?