Add fields choices server-side

I've been looking for a clean way to add choices to the available options for ServiceNow Discovery Source on the cmdb_ci table. As you may have seen we've got a SCOM Solution that can import data via IRE into ServiceNow, and when using this additional discovery_source options increase the power of IRE.

The below function makes it easy to add a new option to a choice list, I've followed with the earlier mention of cmdb_ci and used an example of discovery_source.

function addChoiceToList(tableName, fieldName, value, label) {// The entries created will go in the Choice tablevar choiceTable = new GlideRecord('sys_choice');// Initialize a new blank record for our choice.choiceTable.initialize();// Set the values passed into the function for this choicechoiceTable.setValue('name',tableName);choiceTable.setValue('element',fieldName);choiceTable.setValue('value',value);choiceTable.setValue('label',label);// Commit the record to the tablechoiceTable.update();}addChoiceToList('cmdb_ci','discovery_source','scom_server_two','SCOM Servers 2')

Previous
Previous

Update Rollup 2 for System Center 2019 is out!

Next
Next

First look at the Azure SQL Managed Instance MP