Resco Wiki

On Can Execute

App users can execute commands from their app, for example, run a mobile report or delete several records at once. Predefined commands usually function out of the box. However, you can use rules to define their availability and tweak their function. On Can Execute defines when a command is available in the app. This rule is executed when a command is about to be displayed. Use it to control in which situations users can see and use the command, so you can hide it in situations where its action is not suitable. On Can Execute controls the availability of both predefined commands and custom commands.

On Can Execute is available for the following user interface components:

In Woodford, you can edit the commands available for a form. In Questionnaire Designer, you can edit the commands available when filling out a questionnaire.

Commands

List of predefined form and questionnaire commands can be found here.

Examples of On Can Execute rule

Field clearing command availability

If the Entity.addres1_line1 field contains data, the delete button is enabled. Otherwise, it remains disabled.

Image / XML example
On-can-execute-delete-street.png
XML
<?xml version="1.0" ?>
<Workflow e="true" isvalid="true" syntaxVersion="11" version="0">
	<branch e="true" info="">
		<if e="true">
			<conditions e="true" op="And">
				<condition e="false">
					<var>Command.Name</var>
					<op>Equal</op>
					<arg>String:custom_del_street</arg>
				</condition>
				<condition e="false">
					<var>Entity.address1_line1</var>
					<op>ContainsData</op>
				</condition>
			</conditions>
			<action>
				<function e="false">
					<var>Command.IsEnabled</var>
					<func>Assign</func>
					<arg>Boolean:True</arg>
				</function>
			</action>
		</if>
		<if e="true">
			<conditions e="true" op="And">
				<condition e="false">
					<var>Command.Name</var>
					<op>Equal</op>
					<arg>String:custom_del_street</arg>
				</condition>
			</conditions>
			<action>
				<function e="false">
					<var>Command.IsEnabled</var>
					<func>Assign</func>
					<arg>Boolean:False</arg>
				</function>
			</action>
		</if>
	</branch>
</Workflow>

Disable Update GPS command

Users should not change the GPS position of a record, that already has the GPS position set. If the Entity.address1_longitude and Entity.address1_latitude fields contain data, UpdateGPS comand is disabled. Otherwise, it remains enabled.

Image / XML example
on can execute- disable update gps command
XML
<?xml version="1.0" ?>
<Workflow e="true" isvalid="true" syntaxVersion="11" version="0">
	<branch e="true" info="">
		<if e="true">
			<conditions e="true" op="And">
				<condition e="false">
					<var>Command.Name</var>
					<op>Equal</op>
					<arg>String:UpdateGPS</arg>
				</condition>
				<condition e="false">
					<var>Entity.address1_latitude</var>
					<op>ContainsData</op>
				</condition>
				<condition e="false">
					<var>Entity.address1_longitude</var>
					<op>ContainsData</op>
				</condition>
			</conditions>
			<action>
				<function e="false">
					<var>Command.IsEnabled</var>
					<func>Assign</func>
					<arg>Boolean:False</arg>
				</function>
			</action>
		</if>
		<if e="true">
			<conditions e="true" op="And">
				<condition e="false">
					<var>Command.Name</var>
					<op>Equal</op>
					<arg>String:UpdateGPS</arg>
				</condition>
			</conditions>
			<action>
				<function e="false">
					<var>Command.IsEnabled</var>
					<func>Assign</func>
					<arg>Boolean:True</arg>
				</function>
			</action>
		</if>
	</branch>
</Workflow>

Disable Delete command

You can add the Delete command but hide it in specific situations. If the current user is not an owner of specific record, the delete button is disabled for him. Otherwise, it remains enabled.

If Condition

Command.Name

Equals

Delete



Then

If Condition

Entity.ownerid

Does Not Equal Current User


Then Step

Command.isEnabled

Assign

False


Else Then Step

Command.isEnabled

Assign

True

Disable signature on Note attachment

You can disable the Signature option on Notes' Attachment.

Image / XML example
on can execute disable signature
XML
<?xml version="1.0"?>
<Workflow e="true" isvalid="true" syntaxVersion="11" version="0">
  <branch e="true" info="">
    <if e="true">
      <conditions e="true" op="And">
        <condition e="false">
          <var>Command.Name</var>
          <op>Equal</op>
          <arg>String:DocAction.CaptureInk</arg>
        </condition>
      </conditions>
      <action>
        <function e="false">
          <var>Command.IsEnabled</var>
          <func>Assign</func>
          <arg>Boolean:False</arg>
        </function>
      </action>
    </if>
  </branch>
</Workflow>

The tricky part can be setting the command’s name. It needs to be exactly DocAction.CaptureInk (Note: It’s case-sensitive!).

Replace Save with Save & Close

When saving forms, you can use either "save only" or "save and close" action. The default behavior is configured in project configuration > Save Button Action. The following rule can be used to override the standard form behavior for a particular form:

Image / XML example
on can execute -save
XML
<?xml version="1.0"?>
<Workflow e="true" isvalid="true" syntaxVersion="11" version="0">
  <branch e="true" info="">
    <if e="true">
      <conditions e="true" op="And">
        <condition e="false">
          <var>Command.Name</var>
          <op>Equal</op>
          <arg>String:Save</arg>
        </condition>
      </conditions>
      <action>
        <function e="false">
          <var>Command.IsEnabled</var>
          <func>Assign</func>
          <arg>Boolean:False</arg>
        </function>
      </action>
    </if>
    <if e="true">
      <conditions e="true" op="And">
        <condition e="false">
          <var>Command.Name</var>
          <op>Equal</op>
          <arg>String:SaveClose</arg>
        </condition>
      </conditions>
      <action>
        <function e="false">
          <var>Command.IsEnabled</var>
          <func>Assign</func>
          <arg>Boolean:True</arg>
        </function>
      </action>
    </if>
  </branch>
</Workflow>


Last updated: