salesforce2apex

0.1.5 • Public • Published

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>&quot;BBB&quot;</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';
      }
    }
  }
}

Keywords

install

npm i salesforce2apex

Downloadsweekly downloads

6

version

0.1.5

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability