
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2019 02:55 PM
I have set up Okta on my instance and currently use it to provision users. What I would like to do next is have Okta create records on cmn_department. When a new department is created in AD I would like it to be added to ServiceNow.
I think I need to use REST API but I'm not really sure where to get started. Any help is really appreciated.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2019 12:59 PM
After working with Okta support a confirm at this time this is not possible.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2023 04:41 PM - edited 03-02-2023 04:42 PM
Definitely got me on the right track here. I ended up doing an insert / update before BR
for this that covered new company, department, cost center, and location on the user record since all 4 of those are reference fields.
(function executeRule(current, previous /*null when async*/ ) {
var dept, comp, loc, getCompany, getDept, getLoc, compDisp, deptDisp, locDisp, getCost, cost, costDisp;
comp = current.company;
compDisp = current.company.getDisplayValue();
dept = current.department;
deptDisp = current.department.getDisplayValue();
loc = current.location;
locDisp = current.location.getDisplayValue();
cost = current.cost_center;
costDisp = current.cost_center.getDisplayValue();
if (current.company.changes() && !compDisp && comp) {
getCompany = new GlideRecord('core_company');
getCompany.addEncodedQuery('name=' + comp + '^ORsys_id=' + comp);
getCompany.query();
if (getCompany.next()) {
//don't do anything. Just a safety check against creating a duplicate company
} else {
getCompany.newRecord();
getCompany.name = comp;
getCompany.notes = 'DO NOT DELETE: Company';
getCompany.insert();
current.company = getCompany.sys_id;
}
}
if (current.department.changes() && !deptDisp && dept) {
getDept = new GlideRecord('cmn_department');
getDept.addEncodedQuery('name=' + dept + '^ORsys_id=' + dept);
getDept.query();
if (getDept.next()) {
//don't do anything. Just a safety check against creating a duplicate department
} else {
getDept.newRecord();
getDept.name = dept;
getDept.description = 'Department created by Okta';
getDept.insert();
current.department = getDept.sys_id;
}
}
if (current.location.changes() && !locDisp && loc) {
getLoc = new GlideRecord('cmn_location');
getLoc.addEncodedQuery('name=' + loc + '^ORsys_id=' + loc);
getLoc.query();
if (getLoc.next()) {
//don't do anything. Just a safety check against creating a duplicate location
} else {
getLoc.newRecord();
getLoc.name = loc;
getLoc.insert();
current.location = getLoc.sys_id;
}
}
if (current.cost_center.changes() && !costDisp && cost) {
getCost = new GlideRecord('cmn_cost_center');
getCost.addEncodedQuery('name=' + cost + '^ORsys_id=' + cost);
getCost.query();
if (getCost.next()) {
//don't do anything. Just a safety check against creating a duplicate cost center
} else {
getCost.newRecord();
getCost.name = cost;
getCost.insert();
current.cost_center = getCost.sys_id;
}
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2023 05:01 PM
Hi @ctsmith, if you can mark my answer as Helpful i will be grateful 🙂