- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-15-2016 02:13 PM
Hello,
I have a UI action that I want to convert to a UI Macro so that I can add it as a button at the end of a field.
Here's my UI action:
var onCall = new MHSOnCall("SMS",current.u_other_on_call_group_1);
var user = onCall.getPrimaryUserByGroup();
if (user) {
var wf = new Workflow();
var wfId = wf.getWorkflowFromName("MHS On-Call Voice");
// add as many variables as your workflow is expecting, then pass the object
gs.log ("Workflow ID "+wfId);
var vars = {};
vars.assignment_group = current.u_other_on_call_group_1;
gs.log ("assignment_group in vars "+vars.assignment_group);
gs.log ("vars [Object] "+vars);
wf.startFlow(wfId, current, current.operation(),vars);
action.setRedirectURL(current);
}
else {
gs.addInfoMessage("Assignment Group doesn't have either on-call schedule or Primary On-Call ");
action.setRedirectURL(current);
}
Here's what I've tried on the UI macro, but it's not working:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate var="jvar_guid" expression="gs.generateGUID(this);" />
<j:set var="jvar_n" value="callOnCallGroup1_${ref}"/>
<a id="${jvar_n}" onclick="callOnCallGroup1('${ref}')" title="${gs.getMessage('Call On-Call Group 1')}" tabindex="0" class="icon ref-button icon-phone btn btn-default btn-ref"></a>
<script>
function callOnCallGroup1(reference){
var onCallgroup = g_form.getValue(reference.split('.')[1]);
var onCall = new MHSOnCall("SMS", onCallgroup);
var user = onCall.getPrimaryUserByGroup();
if (user) {
var wf = new Workflow();
var wfId = wf.getWorkflowFromName("MHS On-Call Voice");
// add as many variables as your workflow is expecting, then pass the object
gs.log ("Workflow ID "+wfId);
var vars = {};
vars.assignment_group = onCallgroup;
gs.log ("assignment_group in vars "+vars.assignment_group);
gs.log ("vars [Object] "+vars);
wf.startFlow(wfId, current, current.operation(),vars);
action.setRedirectURL(current);
}
else {
gs.addInfoMessage("Assignment Group doesn't have either on-call schedule or Primary On-Call ");
action.setRedirectURL(current);
}
}
</script>
</j:jelly>
The button shows on the field, but when I click it, nothing happens. Please help.
Thanks,
Maria
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2016 08:49 AM
After seeking help from our ServiceNow Technical Consultant, the UI macro is now working!
Here's the updated script include:
Here's the updated UI macro:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2016 08:49 AM