service now helper scripts for automating some common tasks in the browser as bookmarklets
these are only tested and used with chrome currently
/* | |
bookmarklet to autopopulate the fields for a new scheduled task in chrome | |
you have to inspect to get the groupid you want to populate and you have to inspect for assigned to value as well | |
depending on what fields you want to enter, you may need a delay while the dropdown populates | |
i was able to get away with a half second await between the cat and subcat population | |
*/ | |
javascript: (async function() { | |
var ge = id => { return document.getElementById('gsft_main').contentWindow.document.getElementById(id) }; | |
var ss = (id, v) => { ge(id).value = v }; | |
ss('sc_task.priority', 4); | |
ss('sc_task.u_category', 'cat'); | |
ss('sc_task.assignment_group', 'havetoinspect'); | |
ss('sc_task.assigned_to', 'havetoinspect'); | |
ss('sc_task.short_description', 'InitialText'); | |
ge('sc_task.u_category').dispatchEvent(new Event('change')); | |
await new Promise(resolve => setTimeout(resolve, 500)); | |
ss('sc_task.u_subcategory', 'subcat'); | |
})(); |
/* bookmarklet to create servicenow URL to a scheduled task as long as it's on the screen */ | |
/* works in chrome, not tested in anything else */ | |
javascript:(function(){ | |
function tocb(str){ | |
const el = document.createElement('textarea'); | |
el.value = str; | |
document.body.appendChild(el); | |
el.select(); | |
document.execCommand('copy'); | |
document.body.removeChild(el); | |
}; | |
val = document.getElementById('gsft_main').contentWindow.document.getElementById('sys_readonly.sc_task.number').value; | |
url = 'https://your.service-now.url.here/task.do?sys_id=' + val; | |
tocb(url); | |
alert('copied - ' + url); | |
})(); |