
- 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
07-25-2019 06:04 PM
Do you have any advice on how to spot the transform map? Okta told me they are using REST.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2019 06:38 PM
in this case, if OKTA is using rest api, there are two cases.
1. Either Okta many be consuming a custom scripted REST API in ServiceNow. Whose endpoint maybe something like
https://*****.service-now.com/api/YourAPInamespace/****/...
2. Or Okta may be using a OOB table api to the sys user table to post the user records. the OOB table api pattern is as below
https://*****.service-now.com/api/now/table/sys_user
Ask Okta for the endpoint they are using to make the API call. If its case 1, then you need to find the Importset from the scripted rest API and then from the import set you can find the transform map.
If its case 2, (mostly), then there is no transform map involved. So you have to write an OnBefore Business Rule on the sys_user table and create the department if it's not found in the department's table. You can find the script to use in the BR below.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var departmentGr = new GlideRecord('cmn_department');
departmentGr.get('name',current.getValue('department'));
if(departmentGr){
gs.log("Department sent by Okta is a valid value "+current.getValue('department'));
}
else{
departmentGr.initialize();
departmentGr.setValue('name',current.getValue('department'));
var deptSysId = departmentGr.insert();
current.setValue('department',deptSysId);
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2019 09:55 AM
I am still working with Okta on this, The support person is not able to tell me much. They did say it is a scripted REST API. After I do an Okta sync and it creates a user in sys_user. Is there a way to look and see what created the user and what transform map was used?
Thanks again for the help!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2019 01:19 PM
I was directed to use "dynamic creation" to create the field.
https://docs.servicenow.com/administer/field_administration/task/t_EnableDynCreationForRefFields.html
This is all the info I can find on it. I created the following script include but I am unclear on what to enter for the dynamic creation script.
var NewDepartment = Class.create();
NewDepartment.prototype = {
initialize: function() {
},
create: function(current, value) {
current.name=value;
return current.insert();
},
type: 'NewDepartment'
};
Any advice is always welcome!

- 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.