Workflow Object Example

The following example shows three SDF custom objects that can be used together in a SuiteCloud project for SuiteCloud Development Framework (SDF). The project consists of a custom list object, a transaction body custom field object, and a workflow object. When deployed to a target NetSuite account, the workflow allows supervisors to approve or reject estimates entered by their sales representatives. This example is based on a similar workflow sample in the SuiteFlow Help. For more information about this workflow and how to implement it using SuiteFlow instead of SDF, see Estimate Approval Routing Workflow.

The following workflow object concepts are shown in the example code:

The following file, when saved under /Objects/customlist_approvalstatuses.xml in a SuiteCloud project, specifies a custom list that stores all possible values of an Estimate record—approved, rejected, and pending approval.

          <customlist scriptid="customlist_approvalstatuses">
    <description></description>
    <isinactive>F</isinactive>
    <isordered>T</isordered>
    <name>Approval Statuses</name>
    <customvalues>
        <customvalue scriptid="val_51131_mstrwlf_705">
            <isinactive>F</isinactive>
            <value>Pending Approval</value>
        </customvalue>
        <customvalue scriptid="val_51132_mstrwlf_378">
            <isinactive>F</isinactive>
            <value>Approved</value>
        </customvalue>
        <customvalue scriptid="val_51133_mstrwlf_156">
            <isinactive>F</isinactive>
            <value>Rejected</value>
        </customvalue>
    </customvalues>
</customlist> 

        

The following file, when saved under /Objects/custbody_approvalstatus.xml in a SuiteCloud project, specifies an Approval Status transaction body custom field. The workflow sets this field to one of the possible values specified by the customlist_approvalstatuses custom list.

          <transactionbodycustomfield scriptid="custbody_approvalstatus">
    <accesslevel>2</accesslevel>
    <applyformatting>F</applyformatting>
    <bodyassemblybuild>F</bodyassemblybuild>
    <bodycustomerpayment>F</bodycustomerpayment>
    <bodydeposit>F</bodydeposit>
    <bodyexpensereport>F</bodyexpensereport>
    <bodyinventoryadjustment>F</bodyinventoryadjustment>
    <bodyitemfulfillment>F</bodyitemfulfillment>
    <bodyitemfulfillmentorder>F</bodyitemfulfillmentorder>
    <bodyitemreceipt>F</bodyitemreceipt>
    <bodyitemreceiptorder>F</bodyitemreceiptorder>
    <bodyjournal>F</bodyjournal>
    <bodyopportunity>F</bodyopportunity>
    <bodyothertransaction>F</bodyothertransaction>
    <bodypickingticket>F</bodypickingticket>
    <bodyprintflag>F</bodyprintflag>
    <bodyprintpackingslip>F</bodyprintpackingslip>
    <bodyprintstatement>F</bodyprintstatement>
    <bodypurchase>F</bodypurchase>
    <bodysale>T</bodysale>
    <bodystore>F</bodystore>
    <bodyvendorpayment>F</bodyvendorpayment>
    <checkspelling>F</checkspelling>
    <defaultchecked>F</defaultchecked>
    <displaytype>NORMAL</displaytype>
    <encryptatrest>F</encryptatrest>
    <fieldtype>SELECT</fieldtype>
    <globalsearch>F</globalsearch>
    <isformula>F</isformula>
    <ismandatory>F</ismandatory>
    <isparent>F</isparent>
    <label>Custom Approval Status</label>
    <onparentdelete>NO_ACTION</onparentdelete>
    <searchlevel>2</searchlevel>
    <selectrecordtype>[scriptid=customlist_approvalstatuses]</selectrecordtype>
    <showhierarchy>F</showhierarchy>
    <showinlist>F</showinlist>
    <storevalue>T</storevalue>
</transactionbodycustomfield> 

        

The following file, when saved under /Objects/customworkflow_approvals.xml in a SuiteCloud project, specifies the Estimate Approval Routing workflow. This workflow initiates when a sales representative saves a new estimate record. The workflow checks the estimate to determine whether the sales representative has a supervisor in their employee record. If they do not have a supervisor, the estimate status is approved and an email is sent to the sales representative. If the sales representative has a supervisor, the estimate status changes to Pending Approval, and two buttons become visible to their supervisor. When the supervisor clicks either of the buttons that appear on the estimate record, that status of the estimate changes to either Approved or Rejected, and an email is sent to the sales representative. For more information, see Estimate Approval Routing Workflow.

          <workflow scriptid="customworkflow_approvals">
  <description></description>
  <initcontexts></initcontexts>
  <initeventtypes></initeventtypes>
  <initoncreate>T</initoncreate>
  <initonvieworupdate>F</initonvieworupdate>
  <initsavedsearchcondition></initsavedsearchcondition>
  <inittriggertype>BEFORESUBMIT</inittriggertype>
  <isinactive>F</isinactive>
  <islogenabled>T</islogenabled>
  <keephistory>T</keephistory>
  <name>Estimate Approval Routing</name>
  <recordtypes>ESTIMATE</recordtypes>
  <releasestatus>TESTING</releasestatus>
  <runasadmin>F</runasadmin>
  <initcondition>
    <formula></formula>
    <type>VISUAL_BUILDER</type>
  </initcondition>
  <workflowstates>
    <workflowstate scriptid="workflowstate_entry">
      <description></description>
      <donotexitworkflow>F</donotexitworkflow>
      <name>State 1: Entry</name>
      <positionx>213</positionx>
      <positiony>33</positiony>
      <workflowactions triggertype="ONENTRY">
        <setfieldvalueaction scriptid="workflowaction_setpendingvalue">
          <clienttriggerfields></clienttriggerfields>
          <conditionsavedsearch></conditionsavedsearch>
          <contexttypes></contexttypes>
          <eventtypes></eventtypes>
          <field>[scriptid=custbody_approvalstatus]</field>
          <isinactive>F</isinactive>
          <scheduledelay></scheduledelay>
          <schedulemode>DELAY</schedulemode>
          <schedulerecurrence></schedulerecurrence>
          <scheduletimeofday></scheduletimeofday>
          <scheduletimeunit></scheduletimeunit>
          <valuechecked>F</valuechecked>
          <valuedate></valuedate>
          <valuefield></valuefield>
          <valueformula></valueformula>
          <valuejoinfield></valuejoinfield>
          <valueselect></valueselect>
          <valuetext></valuetext>
          <valuetype>STATIC</valuetype>
          <initcondition>
            <formula></formula>
            <type>VISUAL_BUILDER</type>
          </initcondition>
        </setfieldvalueaction>
      </workflowactions>
      <workflowtransitions>
        <workflowtransition scriptid="workflowtransition_hassupervisor">
          <buttonaction></buttonaction>
          <conditionsavedsearch></conditionsavedsearch>
          <contexttypes></contexttypes>
          <eventtypes></eventtypes>
          <scheduledelay></scheduledelay>
          <scheduletimeunit></scheduletimeunit>
          <tostate>[scriptid=customworkflow_approvals.workflowstate_approvalpending]</tostate>
          <triggertype>ONENTRY</triggertype>
          <waitforworkflow></waitforworkflow>
          <waitforworkflowstate></waitforworkflowstate>
          <initcondition>
            <formula><![CDATA[{supervisor} is not null]]></formula>
            <type>FORMULA</type>
          </initcondition>
        </workflowtransition>
        <workflowtransition scriptid="workflowtransition_isasupervisor">
          <buttonaction></buttonaction>
          <conditionsavedsearch></conditionsavedsearch>
          <contexttypes></contexttypes>
          <eventtypes></eventtypes>
          <scheduledelay></scheduledelay>
          <scheduletimeunit></scheduletimeunit>
          <tostate>[scriptid=customworkflow_approvals.workflowstate_approved]</tostate>
          <triggertype>ONENTRY</triggertype>
          <waitforworkflow></waitforworkflow>
          <waitforworkflowstate></waitforworkflowstate>
          <initcondition>
            <formula></formula>
            <type>VISUAL_BUILDER</type>
          </initcondition>
        </workflowtransition>
      </workflowtransitions>
    </workflowstate>
    <workflowstate scriptid="workflowstate_approvalpending">
      <description></description>
      <donotexitworkflow>F</donotexitworkflow>
      <name>State 2: Pending Approval</name>
      <positionx>213</positionx>
      <positiony>123</positiony>
      <workflowactions triggertype="BEFORELOAD">
        <addbuttonaction scriptid="workflowaction_approvebutton">
          <checkconditionbeforeexecution>T</checkconditionbeforeexecution>
          <conditionsavedsearch></conditionsavedsearch>
          <contexttypes></contexttypes>
          <eventtypes></eventtypes>
          <isinactive>F</isinactive>
          <label>Approve</label>
          <saverecordfirst>F</saverecordfirst>
          <initcondition>
            <formula><![CDATA[{salesrep.supervisor.id}={me}]]></formula>
            <type>FORMULA</type>
          </initcondition>
        </addbuttonaction>
        <addbuttonaction scriptid="workflowaction_rejectbutton">
          <checkconditionbeforeexecution>T</checkconditionbeforeexecution>
          <conditionsavedsearch></conditionsavedsearch>
          <contexttypes></contexttypes>
          <eventtypes></eventtypes>
          <isinactive>F</isinactive>
          <label>Reject</label>
          <saverecordfirst>F</saverecordfirst>
          <initcondition>
            <formula><![CDATA[{salesrep.supervisor.id}={me}]]></formula>
            <type>FORMULA</type>
          </initcondition>
        </addbuttonaction>
      </workflowactions>
      <workflowtransitions>
        <workflowtransition scriptid="workflowtransition_approveclick">
          <buttonaction>[scriptid=customworkflow_approvals.workflowstate_approvalpending.workflowaction_approvebutton]</buttonaction>
          <conditionsavedsearch></conditionsavedsearch>
          <contexttypes></contexttypes>
          <eventtypes></eventtypes>
          <scheduledelay></scheduledelay>
          <scheduletimeunit></scheduletimeunit>
          <tostate>[scriptid=customworkflow_approvals.workflowstate_approved]</tostate>
          <triggertype></triggertype>
          <waitforworkflow></waitforworkflow>
          <waitforworkflowstate></waitforworkflowstate>
          <initcondition>
            <formula></formula>
            <type>VISUAL_BUILDER</type>
          </initcondition>
        </workflowtransition>
        <workflowtransition scriptid="workflowtransition_rejectclick">
          <buttonaction>[scriptid=customworkflow_approvals.workflowstate_approvalpending.workflowaction_rejectbutton]</buttonaction>
          <conditionsavedsearch></conditionsavedsearch>
          <contexttypes></contexttypes>
          <eventtypes></eventtypes>
          <scheduledelay></scheduledelay>
          <scheduletimeunit></scheduletimeunit>
          <tostate>[scriptid=customworkflow_approvals.workflowstate_rejected]</tostate>
          <triggertype></triggertype>
          <waitforworkflow></waitforworkflow>
          <waitforworkflowstate></waitforworkflowstate>
          <initcondition>
            <formula></formula>
            <type>VISUAL_BUILDER</type>
          </initcondition>
        </workflowtransition>
      </workflowtransitions>
    </workflowstate>
    <workflowstate scriptid="workflowstate_approved">
      <description></description>
      <donotexitworkflow>F</donotexitworkflow>
      <name>State 3a: Approved</name>
      <positionx>213</positionx>
      <positiony>213</positiony>
      <workflowactions triggertype="ONENTRY">
        <setfieldvalueaction scriptid="workflowaction_setapprovevalue">
          <clienttriggerfields></clienttriggerfields>
          <conditionsavedsearch></conditionsavedsearch>
          <contexttypes></contexttypes>
          <eventtypes></eventtypes>
          <field>[scriptid=custbody_approvalstatus]</field>
          <isinactive>F</isinactive>
          <scheduledelay></scheduledelay>
          <schedulemode>DELAY</schedulemode>
          <schedulerecurrence></schedulerecurrence>
          <scheduletimeofday></scheduletimeofday>
          <scheduletimeunit></scheduletimeunit>
          <valuechecked>F</valuechecked>
          <valuedate></valuedate>
          <valuefield></valuefield>
          <valueformula></valueformula>
          <valuejoinfield></valuejoinfield>
          <valueselect></valueselect>
          <valuetext></valuetext>
          <valuetype>STATIC</valuetype>
          <initcondition>
            <formula></formula>
            <type>VISUAL_BUILDER</type>
          </initcondition>
        </setfieldvalueaction>
        <sendemailaction scriptid="workflowaction_sendapprovalemail">
          <attachmentfield></attachmentfield>
          <attachmentfile></attachmentfile>
          <attachmentjoinfield></attachmentjoinfield>
          <attachmenttype>SPECIFIC</attachmenttype>
          <body>Estimate {number} has been approved by your supervisor.</body>
          <conditionsavedsearch></conditionsavedsearch>
          <contexttypes></contexttypes>
          <eventtypes></eventtypes>
          <includeformat></includeformat>
          <includerecordlink>T</includerecordlink>
          <includetransaction>F</includetransaction>
          <isinactive>F</isinactive>
          <recipientbccemail></recipientbccemail>
          <recipientccemail></recipientccemail>
          <recipientemail></recipientemail>
          <recipientfield>STDBODYSALESREP</recipientfield>
          <recipientjoinfield></recipientjoinfield>
          <recipienttype>FIELD</recipienttype>
          <scheduledelay></scheduledelay>
          <schedulemode>DELAY</schedulemode>
          <schedulerecurrence></schedulerecurrence>
          <scheduletimeofday></scheduletimeofday>
          <scheduletimeunit></scheduletimeunit>
          <senderfield>STDBODYEMPLOYEE</senderfield>
          <senderjoinfield></senderjoinfield>
          <sendertype>FIELD</sendertype>
          <subject>Your Estimate Has Been Approved</subject>
          <template></template>
          <usetemplate>F</usetemplate>
          <initcondition>
            <formula></formula>
            <type>VISUAL_BUILDER</type>
          </initcondition>
        </sendemailaction>
      </workflowactions>
    </workflowstate>
    <workflowstate scriptid="workflowstate_rejected">
      <description></description>
      <donotexitworkflow>F</donotexitworkflow>
      <name>State 3b: Rejected</name>
      <positionx>213</positionx>
      <positiony>303</positiony>
      <workflowactions triggertype="ONENTRY">
        <setfieldvalueaction scriptid="workflowaction_setrejectvalue">
          <clienttriggerfields></clienttriggerfields>
          <conditionsavedsearch></conditionsavedsearch>
          <contexttypes></contexttypes>
          <eventtypes></eventtypes>
          <field>[scriptid=custbody_approvalstatus]</field>
          <isinactive>F</isinactive>
          <scheduledelay></scheduledelay>
          <schedulemode>DELAY</schedulemode>
          <schedulerecurrence></schedulerecurrence>
          <scheduletimeofday></scheduletimeofday>
          <scheduletimeunit></scheduletimeunit>
          <valuechecked>F</valuechecked>
          <valuedate></valuedate>
          <valuefield></valuefield>
          <valueformula></valueformula>
          <valuejoinfield></valuejoinfield>
          <valueselect></valueselect>
          <valuetext></valuetext>
          <valuetype>STATIC</valuetype>
          <initcondition>
            <formula></formula>
            <type>VISUAL_BUILDER</type>
          </initcondition>
        </setfieldvalueaction>
        <sendemailaction scriptid="workflowaction_sendrejectionemail">
          <attachmentfield></attachmentfield>
          <attachmentfile></attachmentfile>
          <attachmentjoinfield></attachmentjoinfield>
          <attachmenttype>SPECIFIC</attachmenttype>
          <body>Estimate {number} has been rejected by your supervisor.</body>
          <conditionsavedsearch></conditionsavedsearch>
          <contexttypes></contexttypes>
          <eventtypes></eventtypes>
          <includeformat></includeformat>
          <includerecordlink>T</includerecordlink>
          <includetransaction>F</includetransaction>
          <isinactive>F</isinactive>
          <recipientbccemail></recipientbccemail>
          <recipientccemail></recipientccemail>
          <recipientemail></recipientemail>
          <recipientfield>STDBODYSALESREP</recipientfield>
          <recipientjoinfield></recipientjoinfield>
          <recipienttype>FIELD</recipienttype>
          <scheduledelay></scheduledelay>
          <schedulemode>DELAY</schedulemode>
          <schedulerecurrence></schedulerecurrence>
          <scheduletimeofday></scheduletimeofday>
          <scheduletimeunit></scheduletimeunit>
          <senderfield>STDBODYEMPLOYEE</senderfield>
          <senderjoinfield></senderjoinfield>
          <sendertype>FIELD</sendertype>
          <subject>Your Estimate Has Been Rejected</subject>
          <template></template>
          <usetemplate>F</usetemplate>
          <initcondition>
            <formula></formula>
            <type>VISUAL_BUILDER</type>
          </initcondition>
        </sendemailaction>
      </workflowactions>
    </workflowstate>
  </workflowstates>
</workflow> 

        

Related Topics

Workflows as XML Definitions
Workflow State Creation

General Notices