Creating a Job from a Completed Form
Within WorkMobile there is a feature which allows you to build simple workflows by creating a job from a completed form, i.e. a mobile user completes a form within the App, sends it back to the server and the completed data is then copied or part copied to a new form and sent back out to either the same user or another user as a job.
You can achieve the same thing using WMTool using the makejobs command:
java -jar wmtool.jar makejobs --username username --password password --input in.csv --jobtypeid id
[ --allocateback ] --csv --bom --output out.csv
Breaking the above down, the file in.csv contains the list of completed records that you'll use to create the jobs. Each record in the file will create a single job. This file would be created either using the WorkMobile portal and downloading data as CSV, or using the formdata command in WMTool.
Next you need to tell WMTool which predefined jobtype that you wish to map the data onto. This is done by passing in the id of the jobtype using the --jobtypeid parameter.
When the command runs, it actually outputs a file which you can then use with WMTool and the importjobs command. You specify the the output file name and type using the --csv, --bom and --output parameters.
Finally you can use the optional --allocateback parameter to indicate that the allocated user for the list of jobs should be the same user that uploaded the original form data.
When the process runs, values from the completed form data are copied to any field with an identical field name within the jobtype. There are a number of 'special' fields These names must match precisely, all be lowercase and contain no spaces. These fields are:-
- A checkbox named makejob. If this exists and is set to false or unticked, no job will be created for this completed record. In practice, you can then set this value with an expression to dictate if this record should effectively 'kick-off' the creation of a follow-up job. For example you may have an audit or inspection form which if something critical fails you my wish to have a job automatically created which instructs somebody to go out and fix it. In this case you can build some logic into your forms using expressions and effectively set the makejob flag.
- A textbox named jobdescription. The contents of this field will be copied to the concrete field jobdescription which forms part of the job.
- a calendar field named jobstartdate. The contents of this field will be copied to the concrete field EstimatedStartDate which forms part of the job.
- A textbox or dropdown named joballocate. The contents of this field should contain a valid mobile username. If this is the case then the job will be allocated to that user. If it doesn't exist then the job will remain in the unallocated status unless the --allocateback parameter is specified.