Developer Discussions

Discuss topics with other Hexagon Geospatial Power Portfolio developers and experts to get the most out of our products.
Showing results for 
Search instead for 
Do you mean 
Regular Contributor
Posts: 253
Registered: ‎05-01-2016

SDK Query Problem After Deleting Queries - Solved

[ Edited ]

 *****The problem was that i was reusing the query name and that was causing an error  when i deleted the query.  The query was deleted but the code terminated so the new query wasn't created.  On the next round, the query to delete was gone so the code carried through..  Need to increment the query name each time a new query is created and then delete the previous query.  All working well now****

I have 8 different queries that i run based on user's choice. Each has parameters that the user can specify.
When a new query is run, the previous queries are first deleted so there are no queries displaying on the map.
If same query is run twice in a row (parameters can be same or different) then an error occurs stopping the query from completing. 
I think the code i am using to delete the query succeeeds but then it encounters an error before it completes. So the query is gone and the next time
the querydelete runs there is no query so the code is able to continue. The code i am using to delete the queries is below the QueryFind code
function QueryFind(aparcel) {
    var string3;
    $"Queries cleared");
    iicount + iicount + 1;    //iicount is global and starts at -1
    var qName = "QueryByParcel";
    style = new Intergraph.WebSolutions.Core.WebClient.Platform.Style.AreaStyle(null, {
        styles: [{
            type: "SimpleLineStyle",
            color: "#00ff00",
            width: 3
        }, {
            type: "SimpleFillStyle",
            translucency: 1.0,
            color: "#ffffff"


    $"EPSG:3436", function () {
            queryName: qName,

            featureClassId: "D982BC597ACE629341904ADA4C432B175CC79CFA|MasterParcels_View",

            url: "http://cthse-gis/jd1/MapService.svc",
            applicationId: "JD_GOV",
            definitionName: "MapPublisher",
            style: style,
            addToLegend: true, filters: [
                operator: "like",
                operands: ["Parcel_ID", aparcel]
         function (result) {
                 analysisId: result.analysisId,
             }, function (result2) {

                 if (result.updated) {
                     $"Analysis updated");

                     analysisId: result.analysisId,
                 }, function (result2) {

                     function (res) {
                         var i = 0;
                         do {
                             i += 1;
                         } while ([i]);
                         $"Total # of queries = " + i);

                         iicount = i - 1;
                         var string1 = JSON.stringify([iicount].features);
                         var string2 = string1;
                         $"length of string2 = " + string2.length);

///////////////////////////////code to clear queries

    function clearall() {

                $"Clearing queries...")
                $"All Clear");
                $event.notify("measureClear", {});

            function getAnalysisId(name) {
           //"Name of query is " + name);
                var a = $analysisManager.findAnalysisByName(name);
            //      $"Analysis ID is " + a);
                return a && a.get_id();

            function deleteQuery(myQuery) {
                    analysisId: getAnalysisId(myQuery)
                }, function (q) {
                }, function (e) {
    //                console.log("Unable to find analysis ")