ServiceNow Oauth example with Ansible:
ServiceNow system web service – RestMessage – set up POST data
HTTP request: create a variable ${myvar}
Click related links, auto-generate variables to create this
variable in DB, then click view sample script usage to use in script
For GET request this variable can also be used
https://community.servicenow.com/community?id=community_question&sys_id=7f3df786db7a3700414eeeb5ca961928
Workflow log set up:
https://hi.service-now.com/kb_view.do?sysparm_article=KB0538547
workflow run script -> rest message v2 token null problem is
due to permission
create a new role, add to all read related ACL in oauth_credential
table, and add the role to the group that user belongs
workflow get catalog_item: variables:
current.variables.the_name_of_the_variable
(Won’t work on assignment)
current.variables.the_name_of_the_variable
.getDisplayValue() will work on assignment
https://community.servicenow.com/community?id=community_question&sys_id=39cfbe6ddb58dbc01dcaf3231f9619e6
workflow universal global variable can be used during workflow:
workflow.scratchpad.variableName
workflow get mutli set varialbes:
https://community.servicenow.com/community?id=community_blog&sys_id=865b5aeddbc023c0feb1a851ca9619f9
function getMultiRowVariables() {
var idnum =
current.sys_id;
var multiRowData = [];
var gr = new
GlideRecord('sc_req_item');
if (gr.get(idnum)) {
var rowcount =
gr.variables.bill_of_materials.getRowCount();
}
for (var rc = 0; rc
< rowcount; rc++) {
var row =
gr.variables.bill_of_materials.getRow(rc);
//
workflow.info('quantity: ' + row.quantity + '\nModel: ' + row.model +
'\nserial_number: ' + row.serial_number + '\n----------------\n');
multiRowData.push(
{
quantity:
row.quantity,
model:
row.model,
serial_number: row.serial_number
}
);
}
return multiRowData;
}
workflow must ensure API call is not running multiple times, set
up branch and join, and wait condition, check workflow – all contexts- your
workflow-workflow transaction history:
branch && join
https://www.youtube.com/watch?v=xOc342NUzI8
workflow-wait condition script to ensure all catalog tasks are
done :
var rec = new GlideRecord('sc_task');
rec.addQuery('request_item', current.getValue('sys_id'));
rec.addQuery('state','NOT IN','3,4,7');
rec.query();
if(rec.hasNext()){
answer = false;
}
else{
//Continue
answer = true;
}
workflow use setvalue X= box to set description of approval:
https://community.servicenow.com/community?id=community_question&sys_id=3ad4cfe9dbd8dbc01dcaf3231f96199b
Servicenow new sn_ws.RESTMessageV2 is server side, to call API
in client script(client side), need to use glideAJax to call server side script
include :
Import one instance to another
Update_set (tracks changes)
Exported tables:
sys_user
sys_user_role(roles)
sys_user_group
sys_group_has_role(group role)
sys_user_grmember(user group link)
sys_security_ac
sys_workflow_version
sys_workflow
sc_layout
sc_cat_item
No comments:
Post a Comment