Cloning widget-form in scoped app errors
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2018 02:32 PM
Hi Everyone, I'm trying to clone the global widget-form in a scoped application but am running into several issues. Firstly, there's the following error: Function hasRightsTo is not allowed in scope. Additionally, in my console I see TypeError: Cannot read property '_related_lists' of undefined and TypeError: Cannot read property '_attachmentGUID' of undefined. Any suggestions on how to get rid of all of these different errors?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2018 02:47 PM
The server script section needs to be modified. Couple of things you will have to think about... There are several global libraries used in the server script section of the widget, that may or not be accessible in scoped apps. So be prepared for the possibility this may not work at all.
You have to see if scoped apps allow you to access APIs like gs.hasRightsTo (looks like it doesn't allow it), GlideTableDescriptor, and GlideDBObjectManager to start with (there may be more, but saw those at a glance).
I don't think you will be able to get access to those APIs in scope, but try. Your system logs may have some server side errors/warnings indicating issues on the server script that you can troubleshoot.
BTW, I have had to clone the form widget before, and it worked fine, but I did it in Global scope. If you aren't planning to put this app on the store, you can also just clone the widget in global scope, but use it in your scoped app on a page. I have done that before successfully.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2018 03:04 PM
Thanks Jonathan, this is very helpful...will have to think over a couple things about this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2018 08:14 AM
Hey Jonathan, I ended up cloning the Form widget in Global, but am running into another error: TypeError: Cannot read property 'filter' of undefined. Have you encountered this before?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2018 09:00 AM
Did all of the angular providers and dependencies copy over? Also templates? You may have to copy the ng-templates that are related to the form widget. but that shouldn't cause the issue you are seeing. I would recommend inspecting the element on the browser after the page loaded. find the widget that represents your form widget. it should have a class of "v[sys_id of your widget]". if you inspect an element near the top of where your form widget is rendered, you should be pretty close to it.
Then in your javascript console type angular.element($0).scope(). If you got the right element, it will show you the angular scope for your widget, from there you can look at data.f to see if the form was initialized properly.