commentsToContext
Takes the comments of a given entry ID and stores them in the incident context, under a provided context key. For accessing the last executed task's comments, provide ${lastCompletedTaskEntries.[0]} as the value for the entryId input parameter.
javascript · Common Scripts
Details
| ID | commentsToContext |
|---|---|
| Language | javascript |
| From Version | 5.0.0 |
| Tags | Utility |
README
Use this script to take the comments of a given entry ID and stores them in the incident context, under a provided context key.
In order to access the last executed task’s comments, provide ${lastCompletedTaskEntries.[0]} as the value for the entryId input parameter.
Script Data
| Name | Description |
|---|---|
| Script Type | javascript |
| Tags | Utility |
Inputs
| Argument Name | Description |
|---|---|
| entryId | The entry ID to get the comments from. |
| contextKey | The context key to store comments into. |
| listSeperator | If value is a list - provide a list seperator. |
Outputs
There are no outputs for this script.
var entry = executeCommand("getEntry", {"id":args.entryId}); var key=args.contextKey; var comments=entry[0].Contents; var md = 'Comments set to context - '+key+':' + comments + '\n'; var ec={}; if (args.listSeperator) { ec[key]=[]; var list = comments.split(args.listSeperator); for (var i=0;i<list.length;i++) { ec[key].push(list[i].trim()); } } else { ec[key]=comments; } return {Type: entryTypes.note, Contents: entry, ContentsFormat: formats.json, HumanReadable: md, EntryContext: ec};