AnsweredAssumed Answered

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

Question asked by geoffreywestgis on Sep 12, 2014
Latest reply on Sep 22, 2014 by geoffreywestgis

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[i].contentType.indexOf("image") != 0) {
                fileTBody.appendChild(CreateData(files[i].name, files[i].url, files[i].size, files[i].contentType));
            }
        }


        for (var i = 0; i < files.length; i++) {
            if (files[i].contentType.indexOf("image") >= 0) {
                fileTBody.appendChild(CreateData(files[i].name, files[i].url, files[i].size, files[i].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"));
        }
    });
}

Outcomes