This is the documentation for ConfiForms Server/Data Center app
However, this might also work for ConfiForms cloud and in most cases it does. But please see this page to understand the differences between server and cloud versions of the ConfiForms app.
With ConfiForms IFTTT macros it is important to note that: Macro body is evaluated as Velocity Template! This allows you to use #if #end constructions around JSON mapping parts. Field values are stored in Velocity templates under field names! For multi-value holding fields and for the single choice fields, like dropdowns, radio group fields, etc the field is always present in the context and has the value, so you cannot check it with as it will always be evaluated to true, but you can check if it has any values Single choice field Checking if multi-value field has certain label or id Also, there is standard set of objects inside the context Q: I want to check for null, something like this: A: There are several approaches. Select the one most suitable depending on what you really want to do. (Thanks, everybody, for all the feedback on the user list.) See also: Bugzilla #20999, Bugzilla #27741, VelocityNullSupport. Approach 1: Use the fact that null is evaluated as a false conditional. (cf. http://velocity.apache.org/engine/devel/user-guide.html#Conditionals) Note: The conditional will also pass if the result of $car.fuel is the boolean false. What this approach is actually checking is whether the reference is null or false. Approach 2: Use the fact that null is evaluated as an empty string in quiet references. (cf. http://velocity.apache.org/engine/devel/user-guide.html#quietreferencenotation) Note: The conditional will also pass if the result of $car.fuel is an empty String. What this approach is actually checking is whether the reference is null or empty. BTW, just checking for empty can be achieved by: Approach 3: Combine Approach 1 and 2. This will check for null and null only. Note: The logic underlying here is that: "(null or false) and (null or > empty-string)" => if true, must be null. This is true because "false and empty-string and not null" is never true. IMHO, this makes the template too complicated to read. Approach 4: Use a Tool that can check for null (NullTool,ViewNullTool). Note: Of course, NullTool must be in the Context as $null in this case (in ConfiForms it is included into the context under "null" variable name). In ConfiForms version 2.15.3+ we have extended NullTool to have 2 more convenient methods (isNullOrEmpty and isNotNullOrEmpty) to check if the value is null or empty Approach 5: Don't check for null directly, use a self-explaining method. Note: This is my (Shinobu Kawai's) recommended solution. You have to implement the method, but it makes the template so easy-to-read. Approach 6: Use a custom directive. cf. IfNullDirective, IfNotNullDirective Note: You will have to register the directive in your velocity.properties.#if(${somefield})
#end
--- check if field has no values
#if(${somefield.isEmpty()})
#end
--- check if the field is NOT empty and has values
#if(!${somefield.isEmpty()})
#end
--- get id
#if(${somefield.id})
#end
--- get label
#if(${somefield.label})
#end
--- check if field has label (stored in values)
#if(${somefield.hasLabel("some_label")})
#end
--- check if field has id (stored in values)
#if(${somefield.hasId("some_id")})
#end
context.put("entry", entry); <- ConfiForms Entry (raw)
context.put("user", user); <- Confluence user object
context.put("page", contentObject); <- AbstractPage objectSince ConfiForms version 1.49.3 there are additional objects in the context:
context.put("generalUtil", new com.atlassian.confluence.util.GeneralUtil());
context.put("res", ServletActionContext.getResponse());
context.put("req", ServletActionContext.getRequest());
context.put("action", com.atlassian.confluence.renderer.radeox.macros.MacroUtils.getConfluenceActionSupport());
Since ConfiForms version 2.27.3context.put("null", new NullTool()); // helper tool to check for nulls https://cwiki.apache.org/confluence/display/velocity/NullTool
context.put("esc", new EscapeTool()); // helper tool to escape values https://velocity.apache.org/tools/2.0/apidocs/org/apache/velocity/tools/generic/EscapeTool.html
context.put("list", new ListTool()); // helper tool to work on lists https://velocity.apache.org/tools/2.0/apidocs/org/apache/velocity/tools/generic/ListTool.html
context.put("iter", new IteratorTool()); // helper tool to work on lists https://velocity.apache.org/tools/2.0/apidocs/org/apache/velocity/tools/generic/IteratorTool.html
See Apache velocity tools for detailed documentation on these helper classesVery similar to what is available in the context when you develop Confluence user macros:
https://confluence.atlassian.com/doc/writing-user-macros-4485.html
https://developer.atlassian.com/server/confluence/confluence-objects-accessible-from-velocity/
which you can reference as any other variable in Velocity using velocity syntax, for example: ${page.id} to reference page id of current page
Also, a helpful link from apache
---- copied from Apache https://wiki.apache.org/velocity/CheckingForNull
#if ($car.fuel == null)
#if( ! $car.fuel )
#if( "$!car.fuel" == "" )
#if( "$car.fuel" == "" )
#if ((! $car.fuel) && ("$!car.fuel" == ""))
#if( $null.isNull($car.fuel) )
isNull
isNullOrEmpty
isNotNull
isNotNullOrEmpty#if( $car.fuelEmpty )
public boolean isFuelEmpty()
{
// return true if fuel is empty.
}
#ifnull( $car.fuel )
#ifnotnull( $car.fuel )
userdirective = org.apache.velocity.tools.generic.directive.Ifnull
userdirective = org.apache.velocity.tools.generic.directive.Ifnotnull