- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2016 04:30 AM
Is it possible to reclassify a CI by using a script?
I know it is possible to manually reclassify a CI by updating the Class (sys_class_name) on the form, but if I change the sys_class_name using a script, this results in a "record not found" error" on the CI.
From what I can gather, when the CI class is manually changed, a process runs in the background which deletes the CI from the old table and inserts it with the same sys_id into the new table. It seems that when the sys_class_name is changed by a script, this process in not invoked.
Any help gratefully received
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2016 05:59 AM
Please use the before business rule and let me know the output if you can find the ci with the new class.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2016 05:22 AM
Hi Kate,
Try Business rules instead of client script, so that background work will happen properly and use setWorkflow(true) in the BR.
Regards,
Raghu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2016 05:35 AM
The script works but you have to stick with some idea.
When you have the business rule triggered, it is getting updated with the new class , hence by selecting back button it shows the record is not found because it was checking for the record with the previous class.
But when you manually save, you are on the same record.
You can just refresh the list view of the particular class you have updated and you see there is an incremented out.
Try some method like action.setRedirect('current') to view the CI you have updated with the new class.
Does it make a sense?
Thanks,
Black
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2016 05:39 AM
Hi Black,
I can see the CI in the list view for the old class, but when I click on it I get "record not found". I cannot see the CI in the list view for the new class.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2016 05:59 AM
Please use the before business rule and let me know the output if you can find the ci with the new class.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2016 06:22 AM
The onBefore business rule works, thank you.