Popup information not published to ArcGIS Enterprise when using Arcpy?

411
3
10-30-2020 04:26 AM
JoëlHempenius3
Occasional Contributor

I've automated sharing my mapservices to ArcGIS Enterprise using arcpy and now I see a difference on the configured popups between the services I share manually from Pro and the services I Share using Arcpy. When I share manually, the popup information is also shared in ArcGIS Enterprise and when I configure the mapservice in a new map in ArcGIS Enterprise the popup configuration  is the same as ArcGIS Pro. When I share the service from Arcpy and add the service to a new map in ArcGIS Enterprise, there is no popup configuration and I need to do the popup configuration again in the webmap. 

Using Ago-assistant, I dug a little deeper and found the service I shared manually has a data section containing the popup configuration and the service I shared using Arcpy doesn't have this.

Screenshots to illustrate this:

The services shared manually from ArcGIS Pro has the data section bottom right with the popup info:

The service shared using Arcpy doesn't show the data item:

From the network tab in dev console I see a /data? request, but this gives a 200OK with 0 content length. 

I tried a very minimal script from this page (MapImageSharingDraft—ArcGIS Pro | Documentation )  and modified it only to publish my pro project to my server, but this gives the same result.

Does anybody know how I can publish the popupinfo with the service from Arcpy?

-Joël Hempenius.

Languages: JavaScript, Python and Dunglish
3 Replies
MaxSquires
Occasional Contributor

That was a very well written question and i thought it had put me on the track to finding the answer i'm looking for as well, but alas, i had to work around it.  meanwhile, here are my thoughts on the matter:

It seems to me that given the additional data section you mention here we could use python requests to give the server the data parameter, but that doesn't explain why the arcpy sharing of the service is stripping out this inherent functionality (configure popups) of arcgis pro. 

I have inspected the service definition file that is generated in the arcpy publication process and it has the popupinfo section but it is ignored at the upload service definition stage.

MaxSquires_0-1614077109760.png

unfortunately i was unable publish the service with the popups reflected in the service as i wanted.

it seems to be a function of the hosted feature layer. i can't seem to add a data element to an existing feature service.  but a hosted feature layer does have this property.  well, i should say, the property is not empty in the case of the hosted feature layer.

the problem with that, as i understand it, is that if you are working with live data, the hosted feature layer resides in the internal portal database and therefore would need to be recreated every time the data updates in the real backend.  

I may have missed something obvious here and am eagerly awaiting someone to point it out to me.

for me the workaround is injecting the popup info in the client application.  this is not ideal because anywhere else you consume this service the popups will also have to be manually configured i.e. anywhere else in the ArcGIS Enterprise

import * as somelayer_popup_template from '../../../content/popupTemplates/somelayer.json';

//more stuff

if (featLayer.title.toLowerCase() === "some layer title") {
                                        featLayer.popupTemplate = PopupTemplate.fromJSON(somelayer_popup_template.popupInfo);
                                    }

where

somelayer.json is like:

{"popupInfo": {

	"title": "Some Value: {some_fieldname}",
	"fieldInfos": [{
		"fieldName": "some_field",
		"visible": false,
		"isEditable": false,
		"format": {
			"places": 0,
			"digitSeparator": true
		},
                 ...],
	"description": "<div>some html here</div>"
        }
}


maybe someone knows of a way to post a new data element to an existing portal item?

0 Kudos
JoëlHempenius3
Occasional Contributor

Posting a new data element to an existing portal item is easy using the python api:

given that you have succesfully logged in to your GIS and have the itemid of the mapservice and a portalLogo File path variable and you also want to set the description in Portal for the mapservice:

portalitem = gis.content.get(itemid)
item_properties ={ 'description' :  description}
item_properties['text'] =data
portalitem.update(item_properties=item_properties, data=None, thumbnail=portalLogo, metadata=None)

and the data object should be structured like this, in this case I have two layers with "Allow assignment of unique numeric IDs for sharing web layers" enabled in the map:

{
    "layers": [
        {
            "id": 0,
            "name": "Adreslocatie",
            "popupInfo": {
                "title": "{namespace}",
                "mediaInfos": [],
                "fieldInfos": [
                    {
                        "fieldName": "OBJECTID",
                        "visible": true,
                        "isEditable": false,
                        "label": "OBJECTID"
                    },
                    {
                        "fieldName": "",
                        "visible": true,
                        "isEditable": true,
                        "format": {
                            "places": 6,
                            "digitSeparator": false
                        },
                        "label": "BAR_ID"
                    },
                    {
                        "fieldName": "",
                        "visible": true,
                        "isEditable": true,
                        "label": "LAST_MODIFIED"
                    },
                    {
                        "fieldName": "ID",
                        "visible": true,
                        "isEditable": true,
                        "format": {
                            "places": 6,
                            "digitSeparator": false
                        },
                        "label": "ID"
                    },
                    {
                        "fieldName": "",
                        "visible": true,
                        "isEditable": true,
                        "label": "Bag Id"
                    },
                    {
                        "fieldName": "BAG_OBJECT",
                        "visible": true,
                        "isEditable": true,
                        "label": "Bag Object"
                    },
                    {
                        "fieldName": "",
                        "visible": true,
                        "isEditable": true,
                        "label": "GEOMETRIE_AANWEZIG"
                    },
                    {
                        "fieldName": "",
                        "visible": true,
                        "isEditable": true,
                        "format": {
                            "places": 6,
                            "digitSeparator": false
                        },
                        "label": "ORIENTATION"
                    },
                    {
                        "fieldName": "GEMEENTENAAM",
                        "visible": true,
                        "isEditable": true,
                        "label": "GEMEENTENAAM"
                    },
                    {
                        "fieldName": "HUISLETTER",
                        "visible": true,
                        "isEditable": true,
                        "label": "HUISLETTER"
                    },
                    {
                        "fieldName": "HUISNUMMER",
                        "visible": true,
                        "isEditable": true,
                        "format": {
                            "places": 0,
                            "digitSeparator": false
                        },
                        "label": "HUISNUMMER"
                    },
                    {
                        "fieldName": "HUISNUMMER_TOEVOEGING",
                        "visible": true,
                        "isEditable": true,
                        "label": "Huisnummer Toevoeging"
                    },
                    {
                        "fieldName": "PLAATSNAAM",
                        "visible": true,
                        "isEditable": true,
                        "label": "PLAATSNAAM"
                    },
                    {
                        "fieldName": "POSTCODE",
                        "visible": true,
                        "isEditable": true,
                        "label": "POSTCODE"
                    },
                    {
                        "fieldName": "STRAATNAAM",
                        "visible": true,
                        "isEditable": true,
                        "label": "STRAATNAAM"
                    },
                    {
                        "fieldName": "",
                        "visible": true,
                        "isEditable": true,
                        "label": "SE_ANNO_CAD_DATA"
                    }
                ],
                "popupElements": [
                    {
                        "fieldInfos": [
                            {
                                "fieldName": "OBJECTID",
                                "visible": true,
                                "isEditable": false,
                                "label": "OBJECTID"
                            },
                            {
                                "fieldName": "",
                                "visible": true,
                                "isEditable": true,
                                "format": {
                                    "places": 6,
                                    "digitSeparator": false
                                },
                                "label": "BAR_ID"
                            },
                            {
                                "fieldName": "",
                                "visible": true,
                                "isEditable": true,
                                "label": "LAST_MODIFIED"
                            },
                            {
                                "fieldName": "ID",
                                "visible": true,
                                "isEditable": true,
                                "format": {
                                    "places": 6,
                                    "digitSeparator": false
                                },
                                "label": "ID"
                            },
                            {
                                "fieldName": "",
                                "visible": true,
                                "isEditable": true,
                                "label": "Bag Id"
                            },
                            {
                                "fieldName": "BAG_OBJECT",
                                "visible": true,
                                "isEditable": true,
                                "label": "Bag Object"
                            },
                            {
                                "fieldName": "",
                                "visible": true,
                                "isEditable": true,
                                "label": "GEOMETRIE_AANWEZIG"
                            },
                            {
                                "fieldName": "",
                                "visible": true,
                                "isEditable": true,
                                "format": {
                                    "places": 6,
                                    "digitSeparator": false
                                },
                                "label": "ORIENTATION"
                            },
                            {
                                "fieldName": "GEMEENTENAAM",
                                "visible": true,
                                "isEditable": true,
                                "label": "GEMEENTENAAM"
                            },
                            {
                                "fieldName": "HUISLETTER",
                                "visible": true,
                                "isEditable": true,
                                "label": "HUISLETTER"
                            },
                            {
                                "fieldName": "HUISNUMMER",
                                "visible": true,
                                "isEditable": true,
                                "format": {
                                    "places": 0,
                                    "digitSeparator": false
                                },
                                "label": "HUISNUMMER"
                            },
                            {
                                "fieldName": "HUISNUMMER_TOEVOEGING",
                                "visible": true,
                                "isEditable": true,
                                "label": "Huisnummer Toevoeging"
                            },
                            {
                                "fieldName": "PLAATSNAAM",
                                "visible": true,
                                "isEditable": true,
                                "label": "PLAATSNAAM"
                            },
                            {
                                "fieldName": "POSTCODE",
                                "visible": true,
                                "isEditable": true,
                                "label": "POSTCODE"
                            },
                            {
                                "fieldName": "STRAATNAAM",
                                "visible": true,
                                "isEditable": true,
                                "label": "STRAATNAAM"
                            },
                            {
                                "fieldName": "",
                                "visible": true,
                                "isEditable": true,
                                "label": "SE_ANNO_CAD_DATA"
                            }
                        ],
                        "type": "fields"
                    }
                ],
                "expressionInfos": [],
                "description": "",
                "layerOptions": {
                    "showNoDataRecords": true
                },
                "relatedRecordsInfo": null,
                "showAttachments": true,
                "showLastEditInfo": true
            }
        },
        {
            "id": 1,
            "name": "Markeringsobject (locatie)",
            "popupInfo": {
                "title": "{namespace}",
                "mediaInfos": [],
                "fieldInfos": [
                    {
                        "fieldName": "OBJECTID",
                        "visible": true,
                        "isEditable": false,
                        "label": "OBJECTID"
                    },
                    {
                        "fieldName": "BAR_ID",
                        "visible": true,
                        "isEditable": true,
                        "format": {
                            "places": 6,
                            "digitSeparator": false
                        },
                        "label": "BAR_ID"
                    },
                    {
                        "fieldName": "LAST_MODIFIED",
                        "visible": true,
                        "isEditable": true,
                        "label": "LAST_MODIFIED"
                    },
                    {
                        "fieldName": "ID",
                        "visible": true,
                        "isEditable": true,
                        "format": {
                            "places": 6,
                            "digitSeparator": false
                        },
                        "label": "ID"
                    },
                    {
                        "fieldName": "OPGEVOERD_DOOR",
                        "visible": true,
                        "isEditable": true,
                        "label": "Opgevoerd Door"
                    },
                    {
                        "fieldName": "GEWIJZIGD_DOOR",
                        "visible": true,
                        "isEditable": true,
                        "label": "Gewijzigd Door"
                    },
                    {
                        "fieldName": "OPGEVOERD_DATUM",
                        "visible": true,
                        "isEditable": true,
                        "label": "Opgevoerd Datum"
                    },
                    {
                        "fieldName": "GEWIJZIGD_DATUM",
                        "visible": true,
                        "isEditable": true,
                        "label": "Gewijzigd Datum"
                    },
                    {
                        "fieldName": "NAN",
                        "visible": true,
                        "isEditable": true,
                        "label": "NAN"
                    },
                    {
                        "fieldName": "SOORT",
                        "visible": true,
                        "isEditable": true,
                        "label": "SOORT"
                    },
                    {
                        "fieldName": "OPMERKING",
                        "visible": true,
                        "isEditable": true,
                        "label": "OPMERKING"
                    },
                    {
                        "fieldName": "GEOMETRIE_AANWEZIG",
                        "visible": true,
                        "isEditable": true,
                        "label": "GEOMETRIE_AANWEZIG"
                    },
                    {
                        "fieldName": "ORIENTATION",
                        "visible": true,
                        "isEditable": true,
                        "format": {
                            "places": 6,
                            "digitSeparator": false
                        },
                        "label": "ORIENTATION"
                    },
                    {
                        "fieldName": "",
                        "visible": true,
                        "isEditable": true,
                        "label": "SE_ANNO_CAD_DATA"
                    }
                ],
                "popupElements": [
                    {
                        "fieldInfos": [
                            {
                                "fieldName": "OBJECTID",
                                "visible": true,
                                "isEditable": false,
                                "label": "OBJECTID"
                            },
                            {
                                "fieldName": "BAR_ID",
                                "visible": true,
                                "isEditable": true,
                                "format": {
                                    "places": 6,
                                    "digitSeparator": false
                                },
                                "label": "BAR_ID"
                            },
                            {
                                "fieldName": "LAST_MODIFIED",
                                "visible": true,
                                "isEditable": true,
                                "label": "LAST_MODIFIED"
                            },
                            {
                                "fieldName": "ID",
                                "visible": true,
                                "isEditable": true,
                                "format": {
                                    "places": 6,
                                    "digitSeparator": false
                                },
                                "label": "ID"
                            },
                            {
                                "fieldName": "OPGEVOERD_DOOR",
                                "visible": true,
                                "isEditable": true,
                                "label": "Opgevoerd Door"
                            },
                            {
                                "fieldName": "GEWIJZIGD_DOOR",
                                "visible": true,
                                "isEditable": true,
                                "label": "Gewijzigd Door"
                            },
                            {
                                "fieldName": "OPGEVOERD_DATUM",
                                "visible": true,
                                "isEditable": true,
                                "label": "Opgevoerd Datum"
                            },
                            {
                                "fieldName": "GEWIJZIGD_DATUM",
                                "visible": true,
                                "isEditable": true,
                                "label": "Gewijzigd Datum"
                            },
                            {
                                "fieldName": "NAN",
                                "visible": true,
                                "isEditable": true,
                                "label": "NAN"
                            },
                            {
                                "fieldName": "SOORT",
                                "visible": true,
                                "isEditable": true,
                                "label": "SOORT"
                            },
                            {
                                "fieldName": "OPMERKING",
                                "visible": true,
                                "isEditable": true,
                                "label": "OPMERKING"
                            },
                            {
                                "fieldName": "GEOMETRIE_AANWEZIG",
                                "visible": true,
                                "isEditable": true,
                                "label": "GEOMETRIE_AANWEZIG"
                            },
                            {
                                "fieldName": "ORIENTATION",
                                "visible": true,
                                "isEditable": true,
                                "format": {
                                    "places": 6,
                                    "digitSeparator": false
                                },
                                "label": "ORIENTATION"
                            },
                            {
                                "fieldName": "",
                                "visible": true,
                                "isEditable": true,
                                "label": "SE_ANNO_CAD_DATA"
                            }
                        ],
                        "type": "fields"
                    }
                ],
                "expressionInfos": [],
                "description": "",
                "layerOptions": {
                    "showNoDataRecords": true
                },
                "relatedRecordsInfo": null,
                "showAttachments": true,
                "showLastEditInfo": true
            }
        }
    ]
}

 

This solved the problem for me and I get popups on the mapservice after publishing from python with the code example

 

-Joël Hempenius.

Languages: JavaScript, Python and Dunglish
Mostafa_Ghiyasvand
New Contributor

Very helpful!! Thank you so much. It still took one day for me to change the code a bit to got it to work in my project. Here the changes that I made:

portalitem = gis.content.get(itemid)
item_properties ={ 'description' : description}
item_properties['text'] =data
portalitem.update(item_properties=item_properties)

0 Kudos