Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The variable send_warning only has meaning in an action context within a rule. Because user-defined actions are first-class values (i.e., they can be returned as the result of executing an expression), they can be passed into functions or other user-defined actions and returned as the result from a function. You can thus write recursive actions.

User defined actions may also return values. The returned value may be a string, map, array etc. Consider the following from the pico-engine version 0.43.0:

Code Block
languagejs
themeConfluence
    deleteChild = defaction(pico_name){
      ent_children = children(){"children"}
      child_collection = ent_children.collect(function(child){
                                              (child{"name"} ==  pico_name) => "to_delete" | "dont_delete"
                                            })
      child_to_delete = child_collection{"to_delete"}.head()

      every {
        engine:removePico(child_to_delete{"id"})
      }
      returns
      {
        "updated_children": child_collection{"dont_delete"},
        "child": child_to_delete
      }
    }

To retrieve the returned value (in this case a map), bind it to a new name using "setting":

Code Block
deleteChild(<give pico name>) setting(returnValue)