Learn Workday-scripting - 10 Code Examples & CST Typing Practice Test
Workday Scripting refers to the customization and automation of business processes, integrations, and workflows within the Workday platform using Workday Studio, Workday Calculated Fields, and Workday Report Writer capabilities.
View all 10 Workday-scripting code examples →
Learn WORKDAY-SCRIPTING with Real Code Examples
Updated Nov 27, 2025
Code Sample Descriptions
Simple Apex Trigger on Account
trigger AccountTrigger on Account (before insert) {
for(Account acc : Trigger.new) {
acc.Custom_Field__c = 'New Account';
}
}
A trigger that updates a custom field when an Account is inserted.
Apex Class to Calculate Discount
public class DiscountCalculator {
public static Decimal ApplyDiscount(Decimal price, Decimal percent) {
return price - (price * percent / 100);
}
}
A simple Apex class method that calculates discounted price.
Batch Apex to Update Opportunities
global class OpportunityBatch implements Database.Batchable<sObject> {
global Database.QueryLocator start(Database.BatchableContext BC) {
return Database.getQueryLocator('SELECT Id FROM Opportunity WHERE StageName = 'Prospecting'');
}
global void execute(Database.BatchableContext BC, List<Opportunity> scope) {
for(Opportunity opp : scope) {
opp.StageName = 'Closed Won';
}
update scope;
}
global void finish(Database.BatchableContext BC) {}
}
Batch Apex class to update Opportunity Stage to 'Closed Won'.
Trigger to Send Email on Contact Creation
trigger ContactEmailTrigger on Contact (after insert) {
List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();
for(Contact c : Trigger.new) {
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setToAddresses(new String[] {c.Email});
mail.setSubject('Welcome!');
mail.setPlainTextBody('Hello ' + c.FirstName + ', welcome to our platform.');
emails.add(mail);
}
Messaging.sendEmail(emails);
}
Send a welcome email when a new Contact is created.
Apex Trigger to Prevent Deletion
trigger PreventAccountDelete on Account (before delete) {
for(Account acc : Trigger.old) {
Integer contactCount = [SELECT COUNT() FROM Contact WHERE AccountId = :acc.Id];
if(contactCount > 100) {
acc.addError('Cannot delete account with more than 100 contacts');
}
}
}
Prevent deletion of Account records with more than 100 related Contacts.
Scheduled Apex to Update Leads
global class LeadStatusScheduler implements Schedulable {
global void execute(SchedulableContext sc) {
List<Lead> leads = [SELECT Id FROM Lead WHERE Status != 'Contacted'];
for(Lead l : leads) {
l.Status = 'Contacted';
}
update leads;
}
}
Scheduled Apex to update all Leads' Status to 'Contacted' every night.
Apex Trigger to Auto-Assign Owner
trigger CaseOwnerTrigger on Case (before insert) {
Id queueId = [SELECT Id FROM Group WHERE Name = 'Support Queue' AND Type='Queue' LIMIT 1].Id;
for(Case c : Trigger.new) {
c.OwnerId = queueId;
}
}
Automatically assign new Cases to a default queue.
Dynamic SOQL in Apex
String objectName = 'Account';
String fieldName = 'Name';
String filterValue = 'Acme';
String query = 'SELECT Id, ' + fieldName + ' FROM ' + objectName + ' WHERE ' + fieldName + ' LIKE '%' + filterValue + '%'';
List<SObject> results = Database.query(query);
Build and execute a dynamic SOQL query based on user input.
Apex Trigger to Log Changes
trigger AccountChangeLog on Account (after update) {
List<Account_Log__c> logs = new List<Account_Log__c>();
for(Account acc : Trigger.new) {
Account oldAcc = Trigger.oldMap.get(acc.Id);
if(acc.Name != oldAcc.Name) {
logs.add(new Account_Log__c(Account__c=acc.Id, Old_Name__c=oldAcc.Name, New_Name__c=acc.Name));
}
}
insert logs;
}
Log Account name changes into a custom object.
Use Custom Metadata in Apex
List<MySettings__mdt> settings = [SELECT MasterLabel, Threshold__c FROM MySettings__mdt];
for(MySettings__mdt s : settings) {
System.debug('Threshold for ' + s.MasterLabel + ': ' + s.Threshold__c);
}
Read a custom metadata type to control logic in Apex.
Frequently Asked Questions about Workday-scripting
What is Workday-scripting?
Workday Scripting refers to the customization and automation of business processes, integrations, and workflows within the Workday platform using Workday Studio, Workday Calculated Fields, and Workday Report Writer capabilities.
What are the primary use cases for Workday-scripting?
Automating HR business processes like onboarding, offboarding, and promotions. Creating calculated fields for payroll, benefits, and compensation. Generating custom reports for compliance and management decision-making. Integrating Workday with external systems using Workday Studio. Implementing conditional validations for data entry and workflow approvals
What are the strengths of Workday-scripting?
Highly configurable without modifying core Workday code. Supports complex business rules across HR, payroll, and finance. Cloud-native with real-time updates. Integrates seamlessly with Workday ecosystem. Reduces manual errors via automated calculations and validations
What are the limitations of Workday-scripting?
Proprietary platform; limited portability outside Workday. Learning curve for Workday Studio and calculated fields. Debugging complex integrations can be challenging. Performance impacted if calculated fields or reports are inefficient. Dependent on Workday release cycles for feature enhancements
How can I practice Workday-scripting typing speed?
CodeSpeedTest offers 10+ real Workday-scripting code examples for typing practice. You can measure your WPM, track accuracy, and improve your coding speed with guided exercises.