I'm writing a custom GP tool for printing with 10.1. I need to pass some additional parameters into GP tool. I'm using printTask from jsapi and I couldn't add more parameters just by adding to PrintParameters.

ptemplate.preserveScale = false;
params.template = ptemplate;
params.MyNewParameter = 'testing';  
printTask.execute(params, printComplete);

I already have a workaround by adding it as URL parameter gpurl?MyNewParameter='testing'.

In reality my parameters are much complex than this, and I'm seeking for better solution.

Technologies are:

  • Arcgis server geo processing
  • Esri JSAPI
  • Arcpy
  • Are you doing this using an ArcGIS for Server Geoprocessing Service based on an ArcGIS for Desktop authored Python script tool? If not, can you edit your question and tags to make what you are doing a little clearer, please?
    – PolyGeo
    Commented Sep 26, 2013 at 7:47
  • Hi thanks .. Forgot to mention that .. I've edited the question Commented Sep 26, 2013 at 13:03

3 Answers 3


There's two ways of passing extra information into your JavaScript PrintTask, depending on what you want to do with them.

If you need to pass in custom parameters to handle logic within your custom GP tool, you should use the PrintParameters.extraParameters property. For example:

params.extraParameters = {
    "lost": false,
    "found": true,
    "name": "John Doe",
    "answer": 42

params.extraParameters.MyNewParameter = 'testing';

If you're simply inserting new text into your map, you can use the customTextElements property of your PrintTemplate.layoutOptions to insert them.

  1. In ArcMap, when you're editing the map you're going to use for the print template, add text using the drawing toolbar.
  2. Double-click on the textbox to bring up its properties.
  3. Under the Size and Position tab, there's an "Element Name" blank. Fill that in with a unique tag name (like an id in HTML)
  4. In your JavaScript app, when you're updating your print template, add those tags and the custom text you want to insert in them. For example:

     ptemplate.layoutOptions.customTextElements = [
         {"rightlabel": "East"},
         {"leftlabel": "West"},
         {"subtitle": "Check out this great map!"},
         {"disclaimer": "Don't sue me if you get lost using this map."}
     ptemplate.layoutOptions.customTextElements[0] = {"almost_forgot":user_text};

The advantage of this is that it is faster to insert text than iterating through the text elements and replacing elements in ArcPy.


Use the extraParameters property of esri.tasks.PrintParameters: https://developers.arcgis.com/en/javascript/jsapi/printparameters.html#extraparameters

params.extraParameters = { Scale: 100000 };

The customTextElements takes an array of objects. So the correct format would be:

ptemplate.layoutOptions.customTextElements = [
         {"rightlabel": "East"},
         {"leftlabel": "West"},
         {"subtitle": "Check out this great map!"},
         {"disclaimer": "Don't sue me if you get lost using this map."}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.