AnsweredAssumed Answered

Submit job to GP Service and use string input, not default value?

Question asked by MollyKFoley on Apr 2, 2018
Latest reply on Apr 2, 2018 by MollyKFoley

I'm having issues submitting string input to a GP Service. Using AGS 10.4.1. The service has one input parameter of string type, but every time I run the service it runs it with the default string input rather than the value I am passing to the GP Service. How do you get it to accept your new string input? I'm calling the service from Javascript API 3.23. I upload a zip file and accept string input from a form element:


<form id="uploadForm" method="post" enctype="multipart/form-data">
      State Abbreviation: <input type="text" name="stateAbbrev" id="stateAbbrev"><br>
      <label class="custom-file-upload"><input type="file" name="file" id="dataUpload"/>File Upload</label>     
      <input type="button" value="Upload" id="upload"/>


Then, after clicking the upload button, it gets to this function:

function uploadSucceeded(response) {
      var itemID = response["item"].itemID;
      var dataFile = new esri.tasks.DataFile();
      dataFile.itemID = itemID;
      var stateAbbrv = document.getElementById("stateAbbrev").value;
      console.log("File upload successful");
      var params = {"Input_Zip_File": dataFile, "State_Abbreviation": stateAbbrv};
      console.log('Input parameters: '+ dojo.toJson(params));
      gp.submitJob(params, gpJobComplete, gpJobStatus, function(error){
        console.error(error.jobStatus + '(' + error.jobId + '):' + dojo.toJson(error));


In the function above, the line

var params = {"Input_Zip_File": dataFile, "State_Abbreviation": stateAbbrv};

sets the State_Abbreviation parameter to the new user-supplied string input. This prints out correctly in the browser console:

Input parameters: {"Input_Zip_File":{"itemID":"i0cd7358b-f7d4-4238-8d10-4bbdc624e895"},"State_Abbreviation":"AR"}


But, using messages in the browser console, I can see it's running the GP Service using the default string input of "TN" which is the value the GP Service was published with (thus it becomes the default value). I need to somehow override that value, but I can't figure out how?