How to use 'setWorkflow' in scoped app scripting

sheikhassan
Tera Expert

I am getting an error Access to api 'setWorkflow' has been refused due to the api's cross-scope access policy.

How to fix this error?

Any help wold be appreciated.

5 REPLIES 5

syedfarhan
Kilo Sage

Go to your scoped app table and the use of scoped applications is they can allow or deny access from other tables. This allows them to keep 'private tables' for their application data or allow sharing of the information.   If you go to the tables you are trying to write, you'll see an Application Access tab that defines the cross application access.



tab.png



-Syed


Rajesh Mushke
Mega Sage
Mega Sage

Hi Sheik,



create Cross scope privilege



Cross-scope privilege record



Runtime access tracking uses cross-scope privilege records to determine which script operations and targets the system allows to run.


The system creates cross-scope privilege records when:
  • Runtime access tracking is set to Tracking or Enforcing.
  • A script attempts to access another application.

Each cross-scope privilege record contains the following information.


FieldDescription
Source ScopeThe application requesting runtime access to another application's resources.
Target ScopeThe application whose resources are being requested.
Target NameThe name of the table, script include, or script object being requested.
Target TypeThe type of request: table, script include, or script object.
OperationThe operation the script performs on the target. The target type determines the available operations. Tables support the read, write, create, and delete operations. Script includes and script objects only support the execute API operation.
StatusThe authorization for this record: requested, allowed, or denied


Administrators can manually create cross-scope privilege records for application developers in advance to communicate which cross-scope resources they expect developers to access. For example, administrators could create these cross-scope privilege records to permit application developers access to resources from Incident Management.



Source ScopeTarget ScopeTarget NameOperationStatus
My AppGlobalincidentReadAllowed
My AppGlobalincidentWriteAllowed
My AppGlobalScopedGlideRecordExecute APIAllowed


During testing, application developers should run all of their application scripting logic to ensure the system creates any necessary cross-scope privilege records. After application publication, the system only allows runtime requests to run that have a valid cross-scope privilege record.





Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke

Peter de Bock1
Mega Guru

hi Sheik,

Today I faced exactly the same issue "Access to api 'setWorkflow' has been refused due to the api's cross-scope access policy."

After analyzing I found the root cause and a solution for it. The root cause is that this function 'setWorkflow' is not supported in a scoped application. I doubt that it is feasible to allow this by configuring a cross scoped privilege as it is not an object (table, script include, ...).

To resolve it, you can create a new script Include in the global scope with a function which has the query and the setWorkflow in it. Then return your response. The setWorkflow can be used to disable Business Rules for Updates, Deletes and Inserts, though also so to circumvent Business Rule Before queries.

The setWorkflow is working 100% in a global scope script include 🙂

 

Example call:

var glSI = new global.your-global-script-include();
var responseObject = glSI.your-function();

 

Please mark helpfull or answered when when it does 🙂

 

regards, Peter

Hi Peter,

 

your idea sounds very good. Do you also have an example for the script include ?

 

Regards,

Mandy