Can you reclassify a CI using a script?

Kit Sanders2
Kilo Contributor

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

1 ACCEPTED SOLUTION

Please use   the before business rule and let me know the output if you can find the ci with the new class.


View solution in original post

9 REPLIES 9

Raghu Manchikan
Kilo Expert

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


mikeblack
Tera Contributor

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


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.


Please use   the before business rule and let me know the output if you can find the ci with the new class.


The onBefore business rule works, thank you.