How run One time script ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2013 11:52 PM
Hello,
I have a question please, how to run One time script to replace one value on the incident form with another value ?
What is the best way?
I have example script below. I need replace existing value with new value . Below is only example where i need to start learn my knowledge and test it...
Im not experienced yet, but here is my proposal how to manage it.
Create client script and schedule it to run it once ?
or
Just create script in schedule job and run it once ?
Please help me to learn hot to do it.
Thank you for your help.
Here is a script example:
var inc = new GlideRecord('incident');
// Change all Open(1) incidents to Active(2)
inc.addQuery('incident_state', 1);
inc.query();
var inc = new GlideRecord('incident');
// Change all Open(1) incidents to Active(2)
inc.addQuery('incident_state', 1);
inc.query();
while (inc.next()) {
inc.autoSysFields(false); // Do not update sys_updated_on, sys_updated_by, and sys_mod_count
inc.setWorkflow(false); // Do not run any other business rules
inc.setValue('incident_state', 2);
inc.update();
}
Petr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-02-2013 05:04 AM
I have found workaround how to do it by this script below.
If script find in database record where field X have value Y, then another type field X1 will get Value Y1 { Y and Y1 values are same on different tables }.
It work like that, but i have lot of data to be changed and it would be really great if some of you could help me please.
Question is how to move value from One field type{string , table A } to Another fielld type { reference, table B }
Any ideas please ?
I like to experiment and play with it, but need to help how to start please.
Thank you
Petr
var acc = new GlideRecord('u_accounting');
acc.addQuery('u_company_mill_code_fin','FI_01');
acc.addQuery('u_accounting_state', 7);
acc.query();
while (acc.next()) {
acc.autoSysFields(true); // Do not update sys_updated_on, sys_updated_by, and sys_mod_count
acc.setWorkflow(false); // Do not run any other business rules
acc.setValue('jaja_test','80f357e5b9de4100438058bb8299c062');
acc.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2020 10:17 AM
I'm surprised this doesn't have an answer, but you can go to "System Definition" > "Scripts - Background" to run a script ad hoc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2020 10:37 AM
Running a background script will run this code once. However, take caution when using this method as it could possibly negatively affect your instance.