- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2025 11:49 AM
Hi, I am trying to call a Global script include from a scoped UI Action but its not working. Below is the how i am calling from UI action. But its not working. Can anyone help me how can i get the script include being called?
var updateCI = new Global.InsertXYZRecord().updateCI(current.getValue('u_configuration_item'),current.u_attribute_name,current.u_new_value);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2025 01:32 PM
Hi @sry
for that you have to use autoSysFields(false)
update your script include like this
var InsertXYZRecord = Class.create();
InsertXYZRecord.prototype = {
initialize: function() {
},
updateCI: function(sysId, attributeName, newValue) {
var grCI = new GlideRecord("cmdb_ci_hardware");
if (grCI.get(sysId)) {
grCI.setValue(attributeName, newValue); //updated this line
grCI.sys_updated_by = 'oreo';
grCI.setWorkflow(false);
grCI.autoSysFields(false);
grCI.update();
}
},
type: 'InsertXYZRecord'
};
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2025 01:02 PM
Hi @sry ,
put a gs.info() inside the updateCI method and check if the method is being called or not
please share the screenshots of UI action and the script include configurations
may the from the scope it doesn't have access to cmdb_ci_hardware table
put this script in the background script with test values and check
set sysid of CI and field name and value and select your scope if available for test
new global.InsertXYZRecord().updateCI(current.getValue('SYSID OF A CI'),'short_description'/*fieldName*/,'value');
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2025 01:26 PM
Hi Chaitanya, i am able to call the script include and the function. One small issue is as you can see in the function i am hardcoding that "SYS_UPDATED_BY" = 'oreo'. System is not setting the value 'oreo', it is populating the user who made the update. how can i circumvent this?
grCI.sys_updated_by='oreo';
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2025 01:32 PM
Hi @sry
for that you have to use autoSysFields(false)
update your script include like this
var InsertXYZRecord = Class.create();
InsertXYZRecord.prototype = {
initialize: function() {
},
updateCI: function(sysId, attributeName, newValue) {
var grCI = new GlideRecord("cmdb_ci_hardware");
if (grCI.get(sysId)) {
grCI.setValue(attributeName, newValue); //updated this line
grCI.sys_updated_by = 'oreo';
grCI.setWorkflow(false);
grCI.autoSysFields(false);
grCI.update();
}
},
type: 'InsertXYZRecord'
};
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2025 01:42 PM
Thank you so much Chaitanya. i am able to resolve the issues and everything is working as we expected.