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
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
FYI - The code is not well formatted in the email.
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?
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:
Hope this helps.
Thanks,
Lalaine
Works great, thanks for the simple solution Lalaine.