diff --git a/Specialized Areas/Fix scripts/Cancel Struck Slack Conversations/README.md b/Specialized Areas/Fix scripts/Cancel Struck Slack Conversations/README.md new file mode 100644 index 0000000000..c3959e454b --- /dev/null +++ b/Specialized Areas/Fix scripts/Cancel Struck Slack Conversations/README.md @@ -0,0 +1,4 @@ +**Use Case** +1. Sometimes due to network or connecton issue, users are not able to end the conversations using **restart** or **end** command from slack. +2. This script will cancel the struck slack conversations, allowing the users to interaction with ServiceNow again through slack. +3. The encoded Query device type specify the source of conversation. diff --git a/Specialized Areas/Fix scripts/Cancel Struck Slack Conversations/script.js b/Specialized Areas/Fix scripts/Cancel Struck Slack Conversations/script.js new file mode 100644 index 0000000000..b3d4dc95f2 --- /dev/null +++ b/Specialized Areas/Fix scripts/Cancel Struck Slack Conversations/script.js @@ -0,0 +1,13 @@ +/* +This script will mark the struck slack conversation as canceled. +Use Case: Sometimes due to n/w or connecton issue, users are not able to end the conversations using restart or end command from slack. +Device Type in Encoded Query specify the source of conversation, slack in this case. +*/ +var struckConv = new GlideRecord('sys_cs_conversation'); // conversation table glide record +struckConv.addEncodedQuery('stateINopen,faulted,chatInProgress^device_type=slack'); // Query can be enhanced based on user (consumer) or date range. +struckConv.query(); +while(struckConv.next()){ + struckConv.setValue('state','canceled'); // set the state to cancel for struck conversation. + struckConv.setWorkflow(false); + struckConv.update(); +}