The Now Platform® Washington DC release is live. Watch now!
‎10-19-2017 05:56 AM
Hi all,
I'm after some assistance with a background script that i'm trying to get to work. I have a list of knowledge categories and i'm trying to bulk replace the word Dashboards with Analytics.
The field is a string field and i get the following list when running my background script query.
*** Script: KB: Dashboards / Dashboards / Connectivity
*** Script: KB: Dashboards / Dashboards / Other / General questions
*** Script: KB: Dashboards / Dashboards / Security / Remove Access
*** Script: KB: Dashboards / Dashboards / Connectivity / Access Issues
*** Script: KB: Dashboards / Dashboards / Other
*** Script: KB: Dashboards / Dashboards / Security / Access Issues
*** Script: KB: Dashboards / Dashboards / Security / New Access Request
*** Script: KB: Dashboards / Dashboards / Security
*** Script: KB: Dashboards / Dashboards
I have the following script. I have amended line 6 a few times to try different things, but cannot get it to update.
grCI = new GlideRecord('kb_category');
grCI.addQuery('full_category','STARTSWITH','Dashboards / D');
grCI.query();
while (grCI.next()){
gs.print('KB: '+grCI.full_category);
grCI.full_category = grCI.full_category.replace(/Dashboard/g , "Analytics");
grCI.update;
}
Solved! Go to Solution.
‎10-19-2017 06:21 AM
Got it to work, was missing () after the word update on line 7
grCI = new GlideRecord('kb_category');
grCI.addQuery('full_category','STARTSWITH','Dashboards / D');
grCI.query();
while (grCI.next()){
gs.print('KB 1: '+grCI.full_category);
grCI.full_category = grCI.full_category.replace(/Dashboards/g , "Analytics");
gs.print('KB 2: '+grCI.full_category);
grCI.update();
}
‎10-19-2017 06:04 AM
Hi Alex,
I think in line 6 you have missed "s" in Dashboards and n you are searching Dashboard which is why it's not executing . Correct it and let me know the output .
Please Hit/Like and Mark Helpful if it solved your purpose
‎10-19-2017 06:06 AM
Thanks for that, but it made no difference.
grCI = new GlideRecord('kb_category');
grCI.addQuery('full_category','STARTSWITH','Dashboards / D');
grCI.query();
while (grCI.next()){
gs.print('KB: '+grCI.full_category);
grCI.full_category = grCI.full_category.replace(/Dashboards/g , "Analytics");
grCI.update;
}
I get no error, just the same list re-printed back out.
‎10-19-2017 06:21 AM
Got it to work, was missing () after the word update on line 7
grCI = new GlideRecord('kb_category');
grCI.addQuery('full_category','STARTSWITH','Dashboards / D');
grCI.query();
while (grCI.next()){
gs.print('KB 1: '+grCI.full_category);
grCI.full_category = grCI.full_category.replace(/Dashboards/g , "Analytics");
gs.print('KB 2: '+grCI.full_category);
grCI.update();
}
‎08-02-2018 05:19 AM
Thanks for sharing this! We also have a need to perform bulk updates like this, for various reasons - very much appreciated!