Select to view content in your preferred language

How to set parameters within Local Government Public Service Information .js for ArcGIS JavaScript API

982
2
Jump to solution
09-12-2014 02:09 PM
GeoffreyWest
Occasional Contributor III

I have successfully downloaded and installed the application on my IIS web server for development testing.  I would like to configure it with my own parameters.  I am having difficulty understanding how the JavaScript form function talks to the JSON file from the config.js and the servicerequest.js.

I have gone as far to rename my fields to REQUESTTYPE in my feature layer, but the request drop down still does not populate.  Here is a sample of my js.  I have tried

ServiceRequest: { Instructions: "<br/><b>Submit a Request for Service:</b> <br/> <br/>Please search for an address or click directly on the map to locate your request for service. Then, provide details about the request below and click Submit to initiate your request. You'll be provided a Request # that can be used to track the status of your request. If you find a request has already been submitted by another party, you can click on the existing request, provide additional comments and increase the importance of the request.<br /><br/><b>Please note:</b> Attachments can be used to submit a photo, video or other document related to a service request.<br/>",

        LayerInfo: {

            Key: "serviceRequest",

            LayerURL: "http://myHost/arcgis/rest/services/PublicInfoMapService/FeatureServer/0",

            OutFields: "*",

            RequestTypeFieldName: "REQUESTTYPE",

            //Set the attribute for requestID used for creating a new request

          

            CommentsLayerURL: "http://myHost/arcgis/rest/services/PublicInfoMapService/FeatureServer/1",

            CommentsOutFields: "*",

            //Set the primary key attribute for the comments

            CommentId: "${CommentsLayer}"

        },

My assumption is that this snippet works in coordination with the service request functions listed below.  My JavaScript knowledge is somewhat limited, but this seems like it should be a fairly simple task, any assistance would be greatly appreciated.

//function to add service request layer on map

function AddServiceRequestLayerOnMap() {

    var serviceRequestLayer = new esri.layers.FeatureLayer(serviceRequestLayerInfo.LayerURL, {

        mode: esri.layers.FeatureLayer.MODE_SNAPSHOT,

        outFields: [serviceRequestLayerInfo.OutFields],

        id: serviceRequestLayerInfo.Key,

        displayOnPan: false,

        visible: false

    });

    map.addLayer(serviceRequestLayer);

    if (defaultServiceTab == 1) {

        ShowLoadingMessage("Loading...");

    }

    var serviceRequestLayerHandle = dojo.connect(serviceRequestLayer, "onUpdateEnd", function (features) {

        AddServiceLegendItem(this);

        PopulateRequestTypes(serviceRequestLayer.fields);

        HideLoadingMessage();

    });

    dojo.connect(serviceRequestLayer, "onClick", function (evt) {

        if (singleClickFlag) {

            ShowServiceRequestDetails(evt.mapPoint, evt.graphic.attributes);

            singleClickFlag = false;

        }

        setTimeout(function () {

            singleClickFlag = true;

        }, 1000);

        //For cancelling event propagation

        evt = (evt) ? evt : event;

        evt.cancelBubble = true;

        if (evt.stopPropagation) {

            evt.stopPropagation();

        }

    });

    dojo.connect(serviceRequestLayer, "onMouseOver", function (evt) {

        map.setMapCursor('pointer');

    });

    dojo.connect(serviceRequestLayer, "onMouseOut", function (evt) {

        map.setMapCursor('crosshair');

    });

    var serviceRequestCommentLayer = new esri.layers.FeatureLayer(serviceRequestLayerInfo.CommentsLayerURL, {

        mode: esri.layers.FeatureLayer.MODE_SELECTION,

        outFields: [serviceRequestLayerInfo.CommentsOutFields],

        id: serviceRequestLayerInfo.Key + "Comments"

    });

    map.addLayer(serviceRequestCommentLayer);

}

//function to showinfowindow

function ShowServiceRequestDetails(mapPoint, attributes) {

    infoWindowDescriptionFields = [];

    selectedServiceStatus = attributes.STATUS;

    if (!attributes.REQUESTID || attributes.REQUESTID == showNullValueAs) {

        attributes.REQUESTID = showNullValueAs;

        map.infoWindow.setTitle("<span id='spanInfoTitle' title='" + attributes.REQUESTID + "' style='color:white; font-size:11px; font-weight:bolder; font-family:Verdana;'> Service Request ID:" + attributes.REQUESTID + "</span>");

    }

    else {

        map.infoWindow.setTitle("<span id='spanInfoTitle' title='" + attributes.REQUESTID + "' style='color:white; font-size:11px; font-weight:bolder; font-family:Verdana;'> Service Request ID: #" + attributes.REQUESTID + "</span>");

    }

    var mainTabContainer = CreateServiceRequestTabContainer(attributes);

    map.infoWindow.setContent(mainTabContainer.domNode);

    mainTabContainer.resize();

    var windowPoint = map.toScreen(mapPoint);

    map.infoWindow.resize(310, 200);

    setTimeout(function () {

        map.infoWindow.show(mapPoint, GetInfoWindowAnchor(windowPoint, 310));

        mainTabContainer.resize();

        for (var index in infoWindowDescriptionFields) {

            CreateScrollbar(dojo.byId(index), dojo.byId(infoWindowDescriptionFields[index]));

        }

        CreateScrollbar(dojo.byId('divDetailsContainer'), dojo.byId('divDetailsContent'));

    }, 1000);

    FetchRequestComments(attributes.REQUESTID);

    FetchAttachmentDetails(attributes[map.getLayer(serviceRequestLayerInfo.Key).objectIdField]);

    RemoveChildren(dojo.byId("divAttachmentsData"));

    RemoveChildren(dojo.byId("divCommentsContent"));

    CreateRatingWidget(dojo.byId('commentRating'));

    ToggleCommentsView(false);

}

//function to fetch attachment details

function FetchAttachmentDetails(objectID) {

    map.getLayer(serviceRequestLayerInfo.Key).queryAttachmentInfos(objectID, function (files) {

        var fileTable = document.createElement("table");

        var fileTBody = document.createElement("tbody");

        fileTable.appendChild(fileTBody);

        for (var i = 0; i < files.length; i++) {

            if (files.contentType.indexOf("image") != 0) {

                fileTBody.appendChild(CreateData(files.name, files.url, files.size, files.contentType));

            }

        }

        for (var i = 0; i < files.length; i++) {

            if (files.contentType.indexOf("image") >= 0) {

                fileTBody.appendChild(CreateData(files.name, files.url, files.size, files.contentType));

            }

        }

        fileTable.appendChild(fileTBody);

        if (files.length == 0) {

            var trNoAttachments = document.createElement("tr");

            var tdNoAttachments = document.createElement("td");

            trNoAttachments.appendChild(tdNoAttachments);

            tdNoAttachments.innerHTML = "No attachments found.";

            fileTBody.appendChild(trNoAttachments);

        }

        dojo.byId("divAttachmentsData").appendChild(fileTable);

        if (file.length > 0) {

            CreateScrollbar(dojo.byId("divAttachments"), dojo.byId("divAttachmentsData"));

        }

    });

}

0 Kudos
1 Solution

Accepted Solutions
YueWu1
by Esri Regular Contributor
Esri Regular Contributor

Hello Geoffrey,

Thanks for contact with us. I think its better to share the solution about how to populate the drop down list about the Service Request Type here:

- The ServiceRequestType dropdown info get from the field name called “REQUESTTYPE” from the live feature service: (http://services.arcgis.com/b6gLrKHqgkQb393u/ArcGIS/rest/services/ServiceRequestTryItLive/FeatureServ...)

- Checked the LocalGovernment.gdb file downloaded from the local government template. Click the “CitizenService” feature dataset – “ServiceRequest” feature class – right click “ServiceRequest” – choose subTypes tab – click “Domains..” button

- On the config.js file, the RequestTypeFieldName point to: "REQUESTTYPE", all the dropdown values come from the code value of Domain in “ServiceRequestType”

- I attached a screenshot about the how to view the domain from the ArcMap. Technically, two things you should keep in mind:

  1. Setup your own data follow this structure and the dropdown menu should populate correctly.

  2. On the config.js file, call the right field name which content the “domain” of all the servicesRequestType

View solution in original post

0 Kudos
2 Replies
YueWu1
by Esri Regular Contributor
Esri Regular Contributor

Hello Geoffrey,

Thanks for contact with us. I think its better to share the solution about how to populate the drop down list about the Service Request Type here:

- The ServiceRequestType dropdown info get from the field name called “REQUESTTYPE” from the live feature service: (http://services.arcgis.com/b6gLrKHqgkQb393u/ArcGIS/rest/services/ServiceRequestTryItLive/FeatureServ...)

- Checked the LocalGovernment.gdb file downloaded from the local government template. Click the “CitizenService” feature dataset – “ServiceRequest” feature class – right click “ServiceRequest” – choose subTypes tab – click “Domains..” button

- On the config.js file, the RequestTypeFieldName point to: "REQUESTTYPE", all the dropdown values come from the code value of Domain in “ServiceRequestType”

- I attached a screenshot about the how to view the domain from the ArcMap. Technically, two things you should keep in mind:

  1. Setup your own data follow this structure and the dropdown menu should populate correctly.

  2. On the config.js file, call the right field name which content the “domain” of all the servicesRequestType

0 Kudos
GeoffreyWest
Occasional Contributor III

Hi Yue,

This solution works.  We are now receiving the error below.  The proxy.ashx is configured correctly, but when submitting an edit, the message "creating service request" remains on the map.  There are no errors in the console or network.  We are able to ping other addresses when switch the mustMatch parameter to false, and hit our own server when it is true.

EDIT: The ajax function to apply edits returns 200 OK, but this screen still appears, and the updated data does not appear in my database.

creating service request.JPG

0 Kudos