Class OpenWFE::SetValueExpression
In: lib/openwfe/expressions/fe_set.rb
Parent: FlowExpression

The ‘set’ expression is used to set the value of a (process) variable or a (workitem) field.

    <set field="price" value="CHF 12.00" />
    <set variable="/stage" value="3" />
    <set variable="/stage" field-value="f_stage" />
    <set field="stamp" value="${r:Time.now.to_i}" />

(Notice the usage of the dollar notation in the last exemple).

‘set’ expressions may be placed outside of a process-definition body, they will be evaluated sequentially before the body gets applied (executed).

Shorter attributes are OK :

    <set f="price" val="CHF 12.00" />
    <set v="/stage" val="3" />
    <set v="/stage" field-val="f_stage" />
    <set f="stamp" val="${r:Time.now.to_i}" />

    set :f => "price", :val => "USD 12.50"
    set :v => "toto", :val => "elvis"

In case you need the value not to be evaluated if it contains dollar expressions, you can do

    set :v => "v0", :val => "my ${template} thing", :escape => true

to prevent evaluation (i.e. to escape).

Methods

reply  

Included Modules

ValueMixin

Public Instance methods

[Source]

     # File lib/openwfe/expressions/fe_set.rb, line 88
 88:         def reply (workitem)
 89: 
 90:             vkey = lookup_variable_attribute(workitem)
 91:             fkey = lookup_field_attribute(workitem)
 92: 
 93:             value = workitem.attributes[FIELD_RESULT]
 94: 
 95:             #puts "value is '#{value}'"
 96: 
 97:             if vkey
 98:                 set_variable vkey, value
 99:             elsif fkey
100:                 workitem.set_attribute fkey, value
101:             else
102:                 raise "'variable' or 'field' attribute missing from 'set' expression"
103:             end
104: 
105:             reply_to_parent(workitem)
106:         end

[Validate]