- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2017 01:19 PM
Hi,
Thanks in advance for looking at this issue. I've reviewed quite a few community posts andrew.och asimpkin here that are similar in nature, but not quite covering my use case and a problem I can't seem to solve.
I'm using Helsinki On-Call scheduling and am attempting to use the Notify and Assign workflow to check the rota, see if there is a an on-call person, and assign to that group and the primary person. I simply want this workflow to look at the rule and assign the correct group and primary on-call person defined in that schedule.
I have a rotation setup, trigger rules setup (e.g. when a P1 or P2 is assigned, assign to this group and primary person), but when the workflow gets to "Should the task be assigned?" run script activity, only the group is being assigned and the Assigned To with the Primary on-call person is not being assigned. How can I make this workflow assign the Incident to the correct group AND the Primary on-call person?
The script logs an error as below. There isn't even a line 51 in the script to try and troubleshoot further and I've searched elsewhere without luck.
Should the task be assigned?(74b18948dbd83200835dfcdfbf9619de): org.mozilla.javascript.WrappedException: Wrapped org.mozilla.javascript.JavaScriptException: java.lang.IllegalArgumentException: Argument must be a String or NativeString instance (<refname>; line 51)
Thanks and appreciate your help.
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2017 09:28 AM
OK so I tested on my demo instance and there is definitely a bug in the out of the box workflow. I would suggest you raise an incident in Hi. Please feel free to reference this post in your incident. But to get you going the solution is a quick fix:
1. Open Workflow Editor and check out the On-Call: Assign and Notify workflow
2. Open the If "Should the task be assigned" activity
3. Edit lines 9 and 12 where there is a reference to the workflow.inputs.assignment_group variable. You just need to add toString() at the end of that. So your script should look like the following when done:
gs.include("OnCallRotation");
answer = ifScript();
function ifScript() {
//Get the assignment group from the input variable
//Assign the incident to the right on-call resource
var rota = new OnCallRotation();
rota.who(workflow.inputs.assignment_group.toString());
var currentOnCall = rota.getPrimaryUser();
workflow.scratchpad.assignment_group_id = workflow.inputs.assignment_group.toString();
workflow.scratchpad.current_on_call_id = currentOnCall;
//Only assign if there is someone is on_call & assigned_to is empty
if(currentOnCall && current.assigned_to.nil()) {
workflow.scratchpad.comments = gs.getMessage("Incident assigned based on current on-call resource");
return 'yes';
} else
return 'no';
}
4. Click Update.
5. Publish your workflow and test.
Please mark any post as helpful or the correct answer so others can benefit.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2017 10:09 AM
By default the code leverages a notification device of type SMS as the primary and if one isn't found it uses the mobile phone. I suggest you get your user's used to using notification devices as primary because down the road with Notify text to voice you can also use a Voice notification device for that and conference calls too. This number can be independent of their mobile.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2017 02:10 PM
Conor, does this all make sense? Any other questions? Please mark any of the posts helpful or the correct answer to your question so others can benefit.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2017 05:51 AM
Hi Michael,
Appreciate your help on this request sorting out updating the OOB workflow. In followup to your point about getting users used to using notification devices as primary, and that this number can be independent of the mobile_phone field - should I be pointing this script/workflow to pull the number from somewhere different then? I don't necessarily see any logic in the scripts in these workflows or trying a variety of contact numbers for sending an SMS. My use case works correctly pulling from the user mobile_phone field.
This is a bit of an aside, so if you'd prefer a message elsewhere or a separate thread, please let me know.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2017 07:04 AM
No worries! All the out of the box code is written to look at the user's notification devices first and then one isn't found resort to the user's mobile number. An example is the Send SMS workflow activity so if you look at its details, it leverages a script include called NotifyUtils. In there are several "helper" functions including one called getUniquePhoneNumbersForUsersAndGroups, this function calls a subfunction called _getNumbersForUser which you will see first searches for notification devices and if one isn't found, it will use the mobile phone.
So this said if you use the OOB workflow activities then things behave this way by default. If you are using the script based API, then you can utilize the mobile phone directly. You can also leverage the NotifyUtils script include functions too in your own scripts to keep things working like the out of the box functionality as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2017 08:43 AM
Again, that response is helpful as I try and navigate the utilities that are associated with the Notify plugin and API. In your text you mention if you're accessing the script based API - I assume you are referring to using a REST script to post a message?
My real usecase is to have a simple table where and end user can input a phone number and text, and send a one-time SMS. I've been attempting to use the basic get Notify number and send content from the OOB Notify workflows without much luck and have tried two approaches, one via REST and one using the built in Notify scripts.
With REST, I have the message setup but can't pass variables successfully to the StringParameter so that the script will look at the value that a user has put into a form. For example, I have a table called 'onetimesms' with a phone number field, and want the user to be able to submit a record that has a number in it, and the corresponding workflow to fire the below script to retrieve the number and body.
Here is the basic REST example where I have the REST Message defined in SN (e.g. the 'To', 'From', 'Body') but wasn't able to successfully pass any variables e.g. getValue("number") where "number" would be the number a person put into the table to the StringParameter
var sm = new sn_ws.RESTMessageV2("Twilio", "post");
sm.setAuthenticationProfile("basic", "################");
sm.setStringParameter('To', '+1234567890'); // the number to get the SMS
sm.setStringParameter('From', '+123455677'); // my sending SMS number from Twilio
sm.setStringParameter('Body', 'Hello world!');
var response = sm.execute();
I've also tried to set an example instead of using REST, using the native Notify Send SMS activity. I'm trying to have the numbers array grab the value the user puts into a field called "number", instead of looking up a user and their corresponding mobile_phone or other notification device value, but without luck.
result = getRecipientsAndNumberToSendFrom();
/**
* Generate the object that will configure what number to send
* the SMS from and to what additional phone numbers or users
* the SMS should be sent.
*
* @returns {{notify_number: *, users: Array, groups: Array, numbers: Array}}
*/
function getRecipientsAndNumberToSendFrom() {
return {
notify_number : getNotifyNumber(), // the sys_id of the notify number
users : [], // array of user ids
groups : [], // array of group ids
numbers : [current.getValue("number").toString()] // array of E164 compliant phone numbers
};
}
/**
* Function to determine the Notify Number to call from
*
* Note, THIS LOGIC SHOULD PROBABLY CHANGE as it will
* return the first notify number which may not even
* be a SMS capable number.
*
* @returns {*}
*/
function getNotifyNumber() {
// if this workflow is running in the context
// of the call table, use the notify number
// associated
if (current.getTableName() == 'notify_call')
return current.notify_number;
// get the first notify number - THIS SHOULD PROBABLY CHANGE!
var number = new GlideRecord('notify_number');
number.query();
if (number.next())
return number.getUniqueValue();
return null;
}
Really appreciate your time and thoughtful response. Thanks.