Configure custom scripts

To configure your custom script:

1. Access the library administration and select Custom scripts.

2. Click the name your script to open it.

3. Under Security mode, choose the permissions with which your script will run:

  • Run with current user’s privileges: the script is executed with the privileges of the user who triggers its execution. If the script tries to access a document on which the current user has no permission, the script fails with a permission denied error.
  • Run with administrator’s privileges: the script has administrator access, so it can access all documents.

Important: Use this option with caution. Administrator scripts can lead to a security breach. For example, an administrator script could be used by users to gain access to documents on which they have no permissions.

4. Select your execution mode:

  • Sync execution: The script is executed immediately. It can run up to 1 minute.
  • Async execution: The script is triggered a few seconds after you execute the script. Use this option for scripts that perform long or a large number of actions. Scripts that run in asynchronous mode can run for up to 10 minutes. This option is available only for Workflow Transition Action scripts and Update Action scripts.

Important: Asynchronous scripts can't lock a document. For example, you can't modify the properties of documents with asynchronous scripts.

5. Under Parameters, you can configure parameters for your script and define the default value for each parameter.

When configuring actions using your script in workflows, document classes or relations, you can set specific values for these parameters for each action.
For example, your script could be configured in two different workflow states, and each workflow state could use different values for your script’s parameters.

6. In the Imports section, configure the list of classes that you want your script to import.

7. In the code editor, configure the source code of your script. Depending on the type of script, you can edit the source code of different methods. Use the Method drop-down list to select the method you want to edit:

  • _execute: to execute Workflow Transition Action and Viewer Action scripts
  • _isApplicable: to configure who can execute a Viewer Action script
  • _getDisplayName: to return the name of a Viewer Action script defined in the document class
  • _executeAsync: to execute a Viewer Action script when the execution is set as asynchronous
  • _filter: to execute Relation Filter scripts
  • _update: to execute Update Action scripts
  • _createRelationVO: to execute Relation Render Action scripts

image01.png

Was this article helpful? 2 out of 14 found this helpful
If you didn’t find what you were looking for, don’t hesitate to leave a comment!
Have more questions? Submit a request

Comments

9 comments
  • In the method field I only have the _update option. I do not see the other options listed in the example.

    0
    Comment actions Permalink
  • Hi Reginald,
    Thanks for your query. The options available in the Method field vary according to the type of script. We changed the screenshot to make it clearer. Hope that helps!
    Have a great day,
    Catherine

    0
    Comment actions Permalink
  • Can I add additional web page that integrated with AoDocs using this custom script ?

    0
    Comment actions Permalink
  • We'll need a bit more context on what you are trying to achieve. What web pages and how are you looking to integrate them with AODocs?

    0
    Comment actions Permalink
  • I used a Workflow Action Transition script with Sync execution, but was prompted that I cannot modify a related document. Any workaround?

    0
    Comment actions Permalink
  • When you use Workflow Action transition and you enable it on the workflow state you have 4 options (documented here https://support.aodocs.com/hc/en-us/articles/205973916-Trigger-custom-scripts-on-workflow-states):
    Event: Choose when to trigger the custom script:
    - run when document enters this state before inbound transition is completed
    - run when document enters this state after inbound transition is completed
    - run when document leaves this state before outbound transition is completed
    - run when document leaves this state after outbound transition is completed

    On these options you can only perform updates on the current document it runs on if it runs AFTER the transition is completed.

    0
    Comment actions Permalink
  • What if the user has write permission on the starting state and only read permission on the target state? Does the script run all the same and update properties, or do I have to run that script with administrator privileges?

    0
    Comment actions Permalink
  • I updated my custom script, changing parameters value and seems that value changed, graphically. I mean, if I open the script again, I can see the variable changed. But if I PRINT the variable on logs, I have the old value! I also compiled the script and nothing changed

    -1
    Comment actions Permalink
  • Hi Giacomo,
    Thanks for your comment. We'd need to take a look at your custom script. You can open a ticket with our Support team. They'll be able to help you. https://support.aodocs.com/hc/en-us/requests/new
    Hope that helps!

    0
    Comment actions Permalink

Please sign in to leave a comment.