nowAttachmentHandler in Scoped App

arthurcheung
Kilo Expert

We have a solution within the sn_customerservice scoped app for which I am building a portal for. We have a requirement for a page that shows a case's comments, and allow the user to add comments - pretty much what the out of the box "ticket" page did. This page and its widgets are in Global scope though, and didn't work when I tried from Customer Service.

So what I did was clone the "ticket_conversations" widget into Customer Service, and placed the clone on a page that was also in the Customer Service scope.

When I ran the page, I had a few errors, mostly due to service side APIs that are no longer available in scoped apps (handy doco here). These included:

  • GlideTableDescriptor is not allowed in scoped applications
  • Function setDisplayValue is not allowed in scope sn_customerservice

I "fixed" (I mean "fixed" as opposed to fix as this was just a means to get it working for experimental sake) these by either removing the references, are updating them to correct usage intead.

After this, I can add comments fine.

The problem occurs with attachments. When I attempt to attach, it comes back with the error:

Write operation against 'sn_customerservice_dap_case' from scope 'rhino.global' has been refused due to the table's cross-scope access policy

Despite the error, the attachment actually works.

Inspection of the code showed the attachments go through the angular factory "nowAttachmentHandler" (where I found the source code, thanks to this post). When attachments are made, a call is made to "onFileSelect", which in turn does what looks like a REST update to "angular.do?sysparm_type=ngk_attachments&sys_id=<sys_id>&table=<table_id>&action=add".

Does anyone know anything more about this? It's obviously doing an update in global scope when my table is in sn_customerservice. Is there anyway for me to set the scope when using nowAttachmentHandler.onFileSelect?

Or does anyone know of an alternate method to upload attachments via a scoped application from portal?

Thanks in advance,

Arthur

1 ACCEPTED SOLUTION

arthurcheung
Kilo Expert

It turned out there was a custom business rule on the sys_attachment table that update a field on the parent table. As this was done from global scope, it complained when we try to do it from Customer Service scope.



I currently get around this by setting the application access for the scoped table to allow updates from global.


View solution in original post

3 REPLIES 3

arthurcheung
Kilo Expert

It turned out there was a custom business rule on the sys_attachment table that update a field on the parent table. As this was done from global scope, it complained when we try to do it from Customer Service scope.



I currently get around this by setting the application access for the scoped table to allow updates from global.


Here instead of Setting Application Access for attachment table we can write one script include in global scope and add code for attachment update there in a method, we can call this method from scoped application.

 

This work for me without impacting application access because modifying application access will be global change. 

 

Thanks.

Hi, its been years since this was posted. But can I get a the script on how you got this done?