- 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:11 AM
HI,
Can you try if instead of If.
Thanks,
Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2018 01:28 AM
Thank you very much Ashutosh; it indeed resolved the semicolon issue.
At least I will now tackle the next issue, which is the actual update that I want to achieve - it still doesn't update the two fields but I am suspecting my query line "gen.addQuery("ci",ci.sys_id.toString());". Does it make sense to you?
Kind Regards
Arnold

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2018 01:50 AM
Hi,
Use gen.addQuery("ci",ci.sys_id);
Thanks,
Ashutosh
Please Mark Answer as correct/Helpful if it helped.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2018 02:19 AM
Hi Ashutosh,
It didn't work. I even tried gen.addQuery("u_gen_cpu_name",ci.cpu_name); to no success. I tried this because cpu_name on Computer table is the same as u_gen_cpu_name from the other table. Don't know what to do anymore....
Kind Regards
Arnold