Skip to content
Release: Australia · Updated: 2026-03-12 · Official documentation · View source

UserCriteria- Scoped

The UserCriteria API provides methods to create, modify, and delete user criteria records using scripts.

To use this class in a scoped application, use the sn_uc namespace identifier. The User Criteria Scoped API plugin (ID: com.glideapp.user_criteria.scoped.api) must be enabled to access this API.

Parent Topic:Server API reference

UserCriteria - UserCriteria()

Creates an instance of the UserCriteria class.

var uc = new sn_uc.UserCriteria();

UserCriteria - UserCriteria(String sys_id)

Creates an instance of the UserCriteria class with the specified sys_id.

NameTypeDescription
sys_idStringsys_id of the user criteria.
var uc = new sn_uc.UserCriteria("31bea3d53790200044e0bfc8bcbe5dec");

UserCriteria - create(Object columnValues, Boolean standardUpdate)

Creates a user criteria with specified values in the user_criteria table. Values specified in columnValues override the values provided via setters.

NameTypeDescription
columnValuesObjectKey and value pairs for a column and its value.
standardUpdateBooleanSet to true to enable the running of engines and workflow.
TypeDescription
Stringsys_id of the created user criteria.
var uc = new sn_uc.UserCriteria(); 
uc.setCompanies("31bea3d53790200044e0bfc8bcbe5dec,0c441abbc6112275000025157c651c89");
uc.setActive(true); 
uc.setUsers("31bea3d53790200044e0bfc8bcbe5dec,0c441abbc6112275000025157c651c89");
var UserCriteriaId = uc.create();
gs.info(UserCriteriaId);

Output:

41bea3d53790200044e0bfc8bcbe5dec

UserCriteria - deleteRecord()

Deletes the current user criteria.

NameTypeDescription
None  
TypeDescription
BooleanIf true, the user criteria is deleted.If false, no user criteria is found to delete.
var uc = new sn_uc.UserCriteria("31bea3d53790200044e0bfc8bcbe5dec");
uc.deleteRecord();

Output:

true

UserCriteria - read(String columns)

Displays the mapping for the attribute and value pairs of the catalog item.

NameTypeDescription
columnsStringArray of catalog item attributes.
TypeDescription
ObjectMapping for the attribute and value pairs of the catalog item.
var uc = new sn_uc.UserCriteria("7b8a6927ef732100438236caa5c0fb89");
var obj = uc.read(["company","name"]);
gs.info(JSON.stringify(obj));

Output:

Script: {"name":"All ACME Corporation employees","company":"e7c1f3d53790200044e0bfc8bcbe5deb,227cdfb03710200044e0bfc8bcbe5d6b,86c1f3193790200044e0bfc8bcbe5d95,98c37b193790200044e0bfc8bcbe5dbe,81f95197ac1d55eb35432fd1e068385e,df7d53303710200044e0bfc8bcbe5dac,81fdf9ebac1d55eb4cb89f136a082555,4b7d13f03710200044e0bfc8bcbe5db6,81f87336ac1d55eb06002def816d139f,81fbfe03ac1d55eb286d832de58ae1fd,81fca4cbac1d55eb355b4b6db0e3c80f,187d13f03710200044e0bfc8bcbe5df2,81fd65ecac1d55eb42a426568fc87a63,31bea3d53790200044e0bfc8bcbe5dec,81f75fcaac1d55eb2b0781d6f2c3c260"}

UserCriteria - setActive(Boolean active)

Specifies if the user criteria is active.

NameTypeDescription
activeBooleanIf true, the user criteria is active. If false, the user criteria is inactive.
TypeDescription
void 
var uc = new sn_uc.UserCriteria();
uc.setActive(true); 

UserCriteria - setAdvanced(boolean advanced)

Specifies if the user criteria has an advanced script.

NameTypeDescription
advancedBooleanIf true, the user criteria has an advanced script.If false, the user criteria does not have an advanced script.
TypeDescription
void 
var uc = new sn_uc.UserCriteria();
uc.setAdvanced(true); 

UserCriteria - setCompanies(String companies)

Sets the company property for the user criteria.

NameTypeDescription
companiesStringComma-separated list of the company sys_ids to be set for the user criteria.
TypeDescription
void 
var uc = new sn_uc.UserCriteria();
uc.setCompanies("31bea3d53790200044e0bfc8bcbe5dec,0c441abbc6112275000025157c651c89"); 

UserCriteria - setDepartments(String departments)

Sets the department property for the user criteria.

NameTypeDescription
departmentsStringComma-separated list of the department sys_ids to be set for the user criteria.
TypeDescription
void 
var uc = new sn_uc.UserCriteria();
uc.setDepartments("31bea3d53790200044e0bfc8bcbe5dec,0c441abbc6112275000025157c651c89"); 

UserCriteria - setGroups(String groups)

Sets the group property for the user criteria.

NameTypeDescription
groupsStringComma-separated list of the group sys_ids to be set for the user criteria.
TypeDescription
void 
var uc = new sn_uc.UserCriteria();
uc.setGroups("31bea3d53790200044e0bfc8bcbe5dec,0c441abbc6112275000025157c651c89"); 

UserCriteria - setLocations(String locations)

Sets the location property for the user criteria.

NameTypeDescription
locationsStringComma-separated list of the location sys_ids to be set for the user criteria.
TypeDescription
void 
var uc = new sn_uc.UserCriteria();
uc.setLocations("31bea3d53790200044e0bfc8bcbe5dec,0c441abbc6112275000025157c651c89"); 

UserCriteria - setMatchAll(Boolean match_all)

Sets the match_all property for the user criteria.

NameTypeDescription
Nonematch\_allIf true, all conditions set as properties for the user criteria should be fulfilled. If false, at least one condition set as a property for the user criteria should be fulfilled.
TypeDescription
void 
var uc = new sn_uc.UserCriteria();
uc.setMatchAll(true); 

UserCriteria - setName(String name)

Sets the name property for the user criteria.

NameTypeDescription
nameStringName of the user criteria.
TypeDescription
void 
var uc = new sn_uc.UserCriteria();
uc.setName("Property1"); 

UserCriteria - setRoles(String roles)

Sets the role property for the user criteria.

NameTypeDescription
rolesStringComma-separated list of the role sys_ids to be set for the user criteria.
TypeDescription
void 
var uc = new sn_uc.UserCriteria();
uc.setRoles("31bea3d53790200044e0bfc8bcbe5dec,0c441abbc6112275000025157c651c89"); 

UserCriteria - setScript(String script)

Sets the script for the user criteria.

NameTypeDescription
scriptStringScript to be set for the advanced user criteria.
TypeDescription
void 
var uc = new sn_uc.UserCriteria();
uc.setScript("function scriptTest() {
  var retVal;
  if (gs.getUser().getRecord().getDisplayValue('department') == 'Product Management') {
      retVal = true;
  } else {
      retVal = false;
  }
  return retVal;
}"); 

UserCriteria - setUsers(String users)

Sets the user property for the user criteria.

NameTypeDescription
usersStringComma-separated list of the user sys_ids to be set for the user criteria.
TypeDescription
void 
var uc = new sn_uc.UserCriteria();
uc.setUsers("31bea3d53790200044e0bfc8bcbe5dec,0c441abbc6112275000025157c651c89"); 

UserCriteria - update(Object columnValues, String reason)

Updates the current catalog item with the specified values.

NameTypeDescription
columnValuesObjectMapping for the column name and the value pairs.
reasonStringReason for updating the catalog item.
TypeDescription
StringReturns the sys_id of the created user criteria.
var uc = new sn_uc.UserCriteria();
uc.update("name": "Updated name", "The existing name is not relevant. Setting a relevant name"); 

Output:

31bea3d53790200044e0bfc8bcbe5dec