Skip to content
forked from ipavlic/apex-fp

Functional programming for Salesforce Apex

License

Notifications You must be signed in to change notification settings

jdkgabri/apex-fp

 
 

Repository files navigation

Apex FP provides functional constructs for SObject collections!

Examples

Transform SObjects with a simple declarative API.

List<Opportunity> largeOpportunities = SObjectCollection.of(opportunities).filter(Fn.Match.field(Opportunity.Amount).greaterThan(150000).also(Opportunity.AccountId).equals(accountId)).asList();
List<Task> prospectingTasks = SObjectCollection.of(Trigger.new)
	.filter(Fn.Match.recordFields(new Opportunity(Stage = 'Prospecting')))
	.mapAll(Fn.MapTo(Task.SObjectType).setField(Task.Subject, 'Follow up').mapField(Task.WhatId, Opportunity.Id));
Map<Id, List<Account>> accountsByParentId = SObjectCollection.of(accounts).groupByIds(Account.ParentId);
Decimal averageOpportunityValue = SObjectCollection.of(opportunities).mapToDecimal(Opportunity.Amount).average();

Find more examples in the documentation.

Deploy to Salesforce

Deploy to Salesforce

Read the documentation

Apex FP documentation

About

Functional programming for Salesforce Apex

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Apex 92.5%
  • JavaScript 6.5%
  • CSS 1.0%