- 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-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-12-2018 07:02 AM
Hi Ashutosh,
This is working perfectly!
Thank you very much for your help - much appreciated.
Kind Regards
Arnold