Modification of the Create Job Widget in Flex Viewer

4472
7
01-29-2013 04:48 AM
AlisonGaiser
Occasional Contributor
I am not a web developer, instead I am trying to figure out whether something can be done in order for someone else to develop it, so if this question seems rudimentary my apologies.

We have a workflow that is to be used when a Capital Works project is initiated that involves edits to our Road Centreline database. We would like the job creator to use the Flex Viewer to Create this job type as they are not ArcGIS users.

I have installed the 10.0 SP3 version of the Workflow Manager Flex Viewer and it seems to be working. The issue is that our naming convention for Jobs includes the Prefix value. For example the user would create a Job of the Type Capital Works. If they were using the Workflow Manager interface they would select the Job Type: Capital Works, toggle Prefix and enter a Unique number that defines the Capital works project. The name of the job then uses the value in the prefix field. For example the user would enter the prefix value ISD-1234 and the job would then be called ISD-1234_CapitalWorks_[JOB:ID].

The out of the box create job widget does not expose the Prefix field. I would like to modify the widget to include the prefix, but from my VERY limited knowledge, I do not see that as a parameter of Create Job operation. Can someone confirm if I am correct?

Thanks,
       Alison
0 Kudos
7 Replies
TopeBello
Occasional Contributor III
Hi Alison,

The ability to add prefix to the job is not directly available via the REST API. The JavaScript and Flex viewers both have this capability, and it is happening as an updated to the job properties after creation has completed. In summary - we create the job, get the new job's ID and update the job name based on the prefix/suffix created.

For you to replicate a similar behavior, you will need to modify the code of the widget. The source code can be found here - http://www.arcgis.com/home/item.html?id=1b972cde260f4523aa5138003de90fa7

I hope this helps.

Thanks,
Tope
0 Kudos
AlisonGaiser1
Occasional Contributor

Tope,

We are revisiting this interface with our upgrade to WMX 10.2.2. and have chosen to use the new JavaScript viewer. The Prefix and suffix fields are not exposed on the Create New Job widget, so do I need to modify this widget to add the fields, or do this in a two step process? Create the job, then prompt the user for the prefix?

Thanks,

     Alison

0 Kudos
TopeBello
Occasional Contributor III

Hi Alison,

I am happy that you have decided to go with the JavaScript viewer. This capability is not exposed on the UI of the JS viewer, so you will have to customize the create job widget.

Here is a sample that you can use to set that after creating the job -

                this.wmJobTask.createJob(args, user, function(data) {

var jobIds = data; // array of jobIDs

console.log("Jobs created successfully: ", jobIds);

                    // Update the first job

var prefix = "PrefixName";

var suffix = "SuffixName";

var newJobName = prefix + jobIds[0].name + suffix;

var params = {jobId:jobIds[0].jobId, name:newJobName};

                    this.wmJobTask.updateJob(params, user, function(data) {

console.log("Successfully updated job");

}, function(error) {

console.log("Error updating job");

});

                   

                }, function(error) {

console.log("Error creating jobs");

});

I hope this helps!

Thanks,

Tope

0 Kudos
TopeBello
Occasional Contributor III

FYI - The code is not well formatted in the email.

0 Kudos
AdamDrackley
Occasional Contributor III

Hey Tope, thanks for your code snippet.  I'm a developer working with Alison on implementing the WMX Javascript app, and I used your code as a base to perform the Job Update, but I'm feeling that there might be a simpler way.

Around line 1770 of WorkflowManager.js, in the createJob success callback, I have to perform a self.wmJobTask.queryJobsAdHoc function to grab the new Job's details before I can make the updateJob call, because otherwise I don't have access to the job's name as you do in your snippet.

Does this seem like the right area to implement your code above, or is there a better location to be making the updateJob call?

0 Kudos
LalaineLam
New Contributor II

Hi Adam,

WMJobTask has a getJob(jobId, callback, errback) method that you can use instead.  More information on WMJobTask can be found at http://workflowsample.esri.com/doc/javascript/jsapi/WMJobTask.html.

The sequence of calls for updating the job name would be:

  • WMJobTask.createJob(..) -- this returns the jobID of the newly created job
  • WMJobTask.getJob(jobID,...) -- get the job information
  • WMJobTask.updateJob(...) -- update job properties as needed

Hope this helps.

Thanks,

Lalaine

0 Kudos
AdamDrackley
Occasional Contributor III

Works great, thanks for the simple solution Lalaine.

0 Kudos