JS API 4.15: Print template issue

6881
16
Jump to solution
04-10-2020 04:09 AM
NicolasGIS
Occasional Contributor III

Hello,

I wanted to migrate to JS API 4.15 but noticed an issue with Print Widget: it does not honor the print templates from my 'Export Web Map' GPServer anymore. 

Here is an extract from the REST API:

Print widget properly displays them just like it used:

But when Posting the job, the following message is logged:

"dojo.js:253 [esri.core.Accessor] Accessor#set 'A4_Paysage' is not a valid value for this property, only the following values are valid: 'map-only', 'a3-landscape', 'a3-portrait', 'a4-landscape', 'a4-portrait', 'letter-ansi-a-landscape', 'letter-ansi-a-portrait', 'tabloid-ansi-b-landscape', 'tabloid-ansi-b-portrait'"

And MAP

Layout_Template:
MAP_ONLY

is sent rather than "A4_Paysage".

According to the release notes, there had been somes changes in the Print widget:

Release notes for 4.15 | ArcGIS API for JavaScript 4.15 

But I don't think that it means that this workflow is unsupported anymore, doesn't it ?

In the layout property of the templateOptions, it is stated "The print service provides out-of-the-box templates listed in possible values. The server administrator can add additional templates to the print service.". So if server administrator can add additional templates, JS API should accept them specially if it has been fetched from the service configuration.

This workflow used to work fine in previous versions 4.13 and 4.14.

Did I miss anything ?

Thanks,

Best regards,

Nicolas

Tags (2)
1 Solution

Accepted Solutions
Noah-Sager
Esri Regular Contributor

Ok, when you get a chance, can you please test with /next and let me know how it goes? The issue with custom template formats and layouts should be resolved, and if so, it will release at 4.16 this summer.
https://github.com/Esri/feedback-js-api-next

And yes, behind the scenes we do some name convention formatting for the Esri default templates. This formatting ensures that printing will work well across the Esri platform and with different versions of the print service, but we will look to see if we can add this information to the documentation so that people know better what to expect.

View solution in original post

16 Replies
Noah-Sager
Esri Regular Contributor

Thanks for reporting this, Nicholas. This workflow should certainly still be supported. Is your print service publicly accessible for testing? If so, could you provide the URL? Feel free to message it to me directly if you do not want to post it here.

0 Kudos
NicolasGIS
Occasional Contributor III

Thanks for your reply.

Happy to PM you the URL but can't find how to do so on Geonet !

0 Kudos
Noah-Sager
Esri Regular Contributor

No worries, I just messaged you.

0 Kudos
Noah-Sager
Esri Regular Contributor

Update: It's looking like a bug on our end due to more strictness with the PrintTemplate class. We're going to get this fixed. I haven't been able to find a workaround yet, but if I do, I will reply back with this information. When the fix is in, you can check it out on /next (will post back here when it's ready on /next as well). And thanks again for reporting and catching this.

MichaelVolz
Esteemed Contributor

Does this bug mean that you cannot have custom page sizes in your print template or just not custom print template names?

0 Kudos
NicolasGIS
Occasional Contributor III

I thought this bug was just related to custom print template names but it seems trickier than that.

I published again my custom "Export Web Map" GPServer using names in the following list of values:

'map-only', 'a3-landscape', 'a3-portrait', 'a4-landscape', 'a4-portrait', 'letter-ansi-a-landscape', 'letter-ansi-a-portrait', 'tabloid-ansi-b-landscape', 'tabloid-ansi-b-portrait'"

Then REST API looked like the following:

But the widget is translating those values and formatting them !

So if I leave my browser in French, I have the following value:

And if my browser is in English:

Then if I try to print, the following parameter is sent to the print service:

So it's not "a4-landscape" which is sent by the widget !

Now the JavaScript API does not complain anymore (no error logged) but the print service does ! Indeed, Print service returns the following error:

  1. error: {code: 400, message: "Unable to complete operation.",…}
    1. code: 400
    2. message: "Unable to complete operation."
    3. details: ["Error executing tool. Export Web Map"]

And having a look at the ArcGIS Server Manager log, the following error is logged:

 Error executing tool. Export Web Map : ERROR 000800: The value is not a member of a3-landscape | a3-portrait | a4-landscape | a4-portrait | MAP_ONLY. ERROR 000800: The value is not a member of a3-landscape | a3-portrait | a4-landscape | a4-portrait | MAP_ONLY.

So I believe there is no way to have a custom print service with JS API 4.15, unless Noah Sager‌ finds a workaround ?

0 Kudos
NicolasGIS
Occasional Contributor III

On a side note Noah Sager‌, I wanted to underline that those translations done by the Print widget can be an issue with versions prior to 4.15.

Indeed, after having renamed my templates, the print widget of my app built with 4.14 was broken as well and also get the very same error 400 !

Fortunately, JS API seems to only translate those very specific values:

'map-only', 'a3-landscape', 'a3-portrait', 'a4-landscape', 'a4-portrait', 'letter-ansi-a-landscape', 'letter-ansi-a-portrait', 'tabloid-ansi-b-landscape', 'tabloid-ansi-b-portrait'" and does not try to do some clever translation with "A4_Paysage" !

Thanks

0 Kudos
Noah-Sager
Esri Regular Contributor

Nicolas GIS wrote:

Indeed, after having renamed my templates, the print widget of my app built with 4.14 was broken as well and also get the very same error 400 !

I'm not sure I follow. So you renamed the templates from something like:

Choice List: 

[ A3 Landscape, A3 Portrait, A4 Landscape, A4 Portrait, Letter ANSI A Landscape, Letter ANSI A Portrait, Tabloid ANSI B Landscape, Tabloid ANSI B Portrait, MAP_ONLY ]

to:

Choice List: 

['map-only', 'a3-landscape', 'a3-portrait', 'a4-landscape', 'a4-portrait', 'letter-ansi-a-landscape', 'letter-ansi-a-portrait', 'tabloid-ansi-b-landscape', 'tabloid-ansi-b-portrait`]

And this does not work with the 4.14 print widget? But custom names (e.g. not ones in the Choice List by default) do work fine?

0 Kudos
NicolasGIS
Occasional Contributor III

So I renamed my templates from:

to:

in the hope to pleased JS API 4.15 accessor values list.

Then I try to print with JS API 4.15 and did not get any javascript error but an ArcGIS Server one because the widget translated those values in French to "A4 (Paysage)" (cf. nls file) and in English to "A4 landscape" (cf. nls). Thus the 400 errors. 

Then I try to print with JS API 4.14 and get the very same ArcGIS Server error.

So renaming my templates to "a3-landscape", "a3-portrait", "a4-landscape" and "a4-portrait" broke my JS API 4.14 app. I reverted back my print service with templates "A3_Paysage", "A3_Portrait", "A4_Paysage", "A4_Portrait" and it worked again as those values are not translated by the widget.

Does that make sense ?

Thanks

0 Kudos