-
Save Record
Description:
Used to create a new record in the designated Table.
Returns:
Collection of record data created for the new record.
Example Syntax:
Map record = save("<TableName>", ["<FieldName>": "<FieldValue>"]);
-
Load Record
Description:
Used to load an existing record by matching the field name and field value, or a collection of matching field names and field values.
Returns:
Collection of record data for the loaded record
Example Syntax:
Map record = loadRecord("Table", "Field", "Value");
Map record = loadRecord("Table", ["Field": "Value", "Field": "Value"]);
-
Load Application User
Description:
Used to load an existing application user by matching field names and field values.
Returns:
Collection of record data for the loaded user
Example Syntax:
Map user = loadRecord("Account Users", "Email", "johnsmith@email.com");
currentValues["Assigned User"] = user;
-
Load Application User Group
Description:
Used to load an existing application user group by matching field names and field values.
Returns:
Collection of record data for the loaded user group
Example Syntax:
// Lookup existing application user group
Map group = loadRecord("XVIA_USER_GROUP", "group_name", "(group-name-value-here)");
// Set record's assigned group to found group
currentValues["Assigned Group"] = group
-
Update Record
Description:
Used to update an existing record by matching the record's Table, field name, and field value.
Returns:
Collection of record data for the updated record.
Example Syntax:
Map record = loadRecord("Table", "Field", "Value");
record["Field"] = "NewValue";
update(record);
-
Delete Record
Description:
Used to delete an existing record.
Returns:
Deletes a specified record.
Example Use Case:
When a Parent Record is deleted, find all Child Records on a specified table that are linked to that Parent Record and delete them as well.
Example Syntax:
def relatedRecords = getRelatedRecords('RelatedTableAPIName', currentValues.id)
for (record in relatedRecords) {
deleteRecord(record.id)
}
Example Use Case Syntax Explanation:
-
getRelatedRecords('RelatedTableAPIName', currentValues.id)
: Retrieves all records related to the current one via a relationship. -
deleteRecord(record.id)
: Deletes the related record using its ID.
Functions used with Child Records
-
Add Child
Description:
Used to create a new Child Record related to an existing Parent Record.
Returns:
Void response after successfully creating the new Child Record.
Example Syntax:
addChild("Child Table", "Relationship.Name", ["Record Field": "Value"]);
addChild("Child Table", "Link to Parent", ["Field": "Value"]);
-
Load Children
Description:
Used to fetch all Child Records associated with the specified existing Parent Record.
Returns:
A list of matching Child Records associated with the specified Parent Record.
Example Syntax:
// Lookup children
List<Map> children = getChildren("Child Table Name", "Link to Parent Field");
// Iterate children
children.each { child ->
// Perform action on each iteration
}
Related Articles:
App Script Variables
App Script Library
App Scripts Overview
Comments
0 comments
Please sign in to leave a comment.