salesforce2apex
v0.1.5
Published
Salesforce Apex Code Generator from Salesforce Workflow
Downloads
2
Readme
Salesforce2Apex
Salesforce Apex Code Generator from Workflow Rules
Usage
$ npm install -g salesforce2apex
$ salesforce2apex -o object-name -f /path/to/workflow-metadata.workflow > hoge.trigger
// salesforce2apex -o Foo__c -f /path/to/Foo__c.workflow
input file
<?xml version="1.0" encoding="UTF-8"?>
<Workflow xmlns="http://soap.sforce.com/2006/04/metadata">
<fieldUpdates>
<fullName>barbarbar</fullName>
<field>Bar__c</field>
<formula>"BBB"</formula>
<name>barbarbar</name>
<notifyAssignee>false</notifyAssignee>
<operation>Formula</operation>
<protected>false</protected>
<reevaluateOnChange>true</reevaluateOnChange>
</fieldUpdates>
<rules>
<fullName>TestWorkflow</fullName>
<actions>
<name>test</name>
<type>FieldUpdate</type>
</actions>
<active>true</active>
<criteriaItems>
<field>Foo__c.Bar__c</field>
<operation>equals</operation>
<value>AAA</value>
</criteriaItems>
<triggerType>onAllChanges</triggerType>
</rules>
</Workflow>
output
trigger FooTrigger on Foo__c (before update) {
if (Trigger.isBefore && Trigger.isUpdate) {
for (Foo__c record : Trigger.New) {
if (record.Bar__c == 'AAA') {
record.Bar__c = 'BBB';
}
}
}
}