- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2018 12:58 AM
I am getting a "Missing semicolon" compile error on line 10 "If (gen.u_gen_cpu_name == ci.cpu_name){" of my script below:
//get CIs
var ci = new GlideRecord('cmdb_ci_computer');
ci.query();
while (ci.next()) {
//get the Generation record for this CI (only one record)
var gen = new GlideRecord("u_cpu_generation");
gen.addQuery("ci",ci.sys_id.toString());
gen.query();
while (gen.next()){
If (gen.u_gen_cpu_name == ci.cpu_name){
ci.u_cpu_generation = gen.u_gen_cpu_generation;
ci.u_processor_windows_10_capable = gen.u_processor_windows_10_capable;
}
ci.setWorkflow(false);
ci.update();
}
}
When I put it (even though I don't understand why would it need a semicolon on the 'if" statement) the error goes away but the script doesn't do what I expect it to do.
Could someone please assist. I just need to update the two fields, u_cpu_generation and u_processor_windows_10_capable on the Computer table, with data from the u_cpu_generation table. You are welcome to suggest changes on my script, that will enable me to achieve the desired result - still a learner in scripting!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2018 01:05 AM
Hi,
Please see below code:
var ci = new GlideRecord('cmdb_ci_computer');
ci.query();
while (ci.next()) {
var gen = new GlideRecord("u_cpu_generation");
gen.addQuery("u_gen_cpu_name",ci.cpu_name.toString()); // Hope these fields have same data type.
gen.query();
if(gen.next()){
gs.log('Entering','Check');//Check if this log is coming or not.
ci.u_cpu_generation = gen.u_gen_cpu_generation;
ci.u_processor_windows_10_capable = gen.u_processor_windows_10_capable;
ci.update();
}
}
Thanks,
Ashutosh Munot

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2018 01:51 AM
It looks like, you are referring a custom table in your query named "u_cpu_generation".
But in query, you are using CI field in your add query. Are you sure, is there any field available on that table?
var gen = new GlideRecord("u_cpu_generation");
gen.addQuery("ci",ci.sys_id.toString());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2018 02:25 AM
Hi Vinothkumar,
I realised that later and changed it to gen.addQuery("u_gen_cpu_name",ci.cpu_name); with the hope of getting a match on cpu_name as I know for sure that cpu_name on Computer table has a matching record on the custom table. But this didn't do it either...
Kind Regards
Arnold
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2018 02:43 AM
Hi Arnold,
The method setWorkflow(false) won't run in client script and will result in error whatever you try to do here if this script is present in client script.
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2018 03:10 AM
Hi Ankur,
I 'm running this as a Scheduled Job. I just tried running it without a setWorkflow(false) method and still no desired result.....
Kind Regards
Arnol
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2018 04:28 AM
Try with below script,
var ci = new GlideRecord('cmdb_ci_computer');
ci.query();
while (ci.next()) {
var gen = new GlideRecord("u_cpu_generation");
gen.addQuery("gen.u_gen_cpu_name",ci.cpu_name);
gen.query();
if(gen.next()){
ci.u_cpu_generation = gen.u_gen_cpu_generation;
ci.u_processor_windows_10_capable = gen.u_processor_windows_10_capable;
ci.update();
}
}