- 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 12:04 PM
Hi @sry ,
Is your Script Include marked as accessible from all application scopes?
G in Global should be small
var updateCI = new global.InsertXYZRecord().updateCI(current.getValue('u_configuration_item'),current.u_attribute_name,current.u_new_value);
after making these changes if still this doesn't work please share screenshot of your script include and code too
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 12:18 PM
Hi Chaitanya, thank you for your prompt response. i changed to small letters and it worked. yes the script include has accessible from all application scopes.
However the system called script include function and the function did not work as it supposed to update a record in cmdb_ci_hardware. Below is the script include and its function.
var InsertXYZRecord = Class.create();
InsertXYZRecord.prototype = {
initialize: function() {
},
updateCI: function(sysId, attributeName, newValue) {
var grCI = new GlideRecord("cmdb_ci_hardware");
grCI.addQuery('sys_id', sysId);
grCI.query();
if (grCI.next()) {
grCI.attributeName = newValue;
grCI.sys_updated_by='oreo';
grCI.setWorkflow(false);
grCI.update();
}
},
type: 'InsertXYZRecord'
};
Thanks,
Sry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2025 12:30 PM
Hi @sry ,
are u passing a field name as a second parameter(attributeName) to the method ?
if yes update your script as 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.update();
}
},
type: 'InsertXYZRecord'
};
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
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 12:48 PM - edited 06-03-2025 12:55 PM
Chaitanya, yes i am passing attributeName as second parameter. I changed function in script include but still the UI action is not able to call the script include and its function.
updateCI: function(sysId, attributeName, newValue) {
var grCI = new GlideRecord("cmdb_ci_hardware");
if (grCI.get(sysId)) {
grCI.setValue(attributeName, newValue);
grCI.sys_updated_by='oreo';
grCI.setWorkflow(false);
grCI.update();
}
},