Script to change package of my widget?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2017 03:28 PM
I am trying to change the package under the widget section. It does not allow me to do it because it says "Security prevents writing to this field".
How do I change that?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2017 03:42 PM
You can not change package after widget is created.
Please go to your application and update set and then clone your widget.
Regards,
Sachin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2017 03:46 PM
I did that but the default package is global. How do I switch to Service Portal - Service Catalog. The reason I want to do that it is because I created a widget that uses this API but for some reason it doesn't work with the global one.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2017 04:13 PM
Hi,
Please run below background script to change package for your widget
var wd = new GlideRecord("sp_widget");
wd.addQuery('name',"Cool Clock");// update your current widget name
wd.query();
while(wd.next()){
wd.sys_package = "4907294cdbf203008d73771c8c96198d";// this is sys_id of Service Portal - Service Catalog package
wd.setWorkflow(false);
wd.update();
}
Regards,
Sachin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-06-2017 02:25 PM
Where do I insert this script? I don't know where to place it!