Nav view search

Navigation

Search

The Exchange

The place to download pre-configured tickets, code snippets, and solutions

Back

Field Level Permissions

Examples of field level permissions and data validating.

Note: This solution is optimized for Virtual Ticket Developer.

If you are using Workgroups DaVinci and are planning to use a Toolbox snippet not marked as DaVinci-compatible, please check with Support for possible compatibility issues before using.

Example script to prevent a certain user group access to the edit mode of a form: The user is alerted that access is denied when the Edit button is clicked.

//@version "2.0"  
//@include "database:PS.js"  
 
Form.addEventListener("objectLoaded", function(){  
    if (Field( 'Status' ) == 'In Production' && PS.InArray(PS.GetUserGroups(LoggedInUser().ID), "Sales")) {  
       PS.Prevent("edit", "Sales staff do not have authority to change job specs after the job has begun production.");  
    } 

Example script to allow only members of a specific user group the ability to edit a certain field: Alerts the user, restores to the previous data.

//@version "2.0"  
//@include "database:PS.js"  
 
Form.addEventListener("elementChanged", function(e) {  
    var field = e.targetName;  
 
    if (field == 'Status' && !PS.InArray(PS.GetGroupUserIDs("Project Manager"), LoggedInUser().ID)) {    
        alert('Only a member of the Project Manager group can change this field.');  
        SetField(field, OldField(field));  
    }  
}); 

Example script to prevent data entry in a field base on the value in another field: If user enters invalid data, an alert to the user is issued and the field is set to null.

//@version "2.0"  
//@include "database:PS.js"  
 
Form.addEventListener("elementChanged", function(e) {  
    var field = e.targetName;  
 
    if ( field == 'Film_Type' && Field( 'Workflow_Type' )== 'Digital' ) {  
        alert("Film Type can not be specified on a Job with a Digital workflow.");  
        SetField(field, null);  
    }  
});

In Virtual Ticket package release 162.3 and greater, form controls editabiltiy can be set in MetaScript:

First label a form control in the Id property.

Then in the form's Global MetaScript, add an 'editingStarted' event listener.

In this function, set the readOnly property for that form control to true for uneditable and false for editable (see script below).

Form.addEventListener("editingStarted", function(){  
    if (Field( 'Customer Name' ) == 'Acme Manufacturing') {  
        Form.getControlById( 'fld_Estimate_Quantity' ).readOnly = true;   
    }  
    else {  
        Form.getControlById( 'fld_Estimate_Quantity' ).readOnly = false;   
    }  
});

Last Modified:

2011-09-30

by

Cliff Lewis