Call GP Service

473
3
Jump to solution
04-22-2020 05:25 AM
jaykapalczynski
Frequent Contributor

I had a python script that I published to a service.  I was calling that service as such below and everything was working great.

  1. In the database i created a table and then a relationship class that references the Feature Class I was previously updating.
  2. Immediately this started throwing errors when I tried to run the python script calling for an edit session.
  3. I modified the python script to include an edit start and edit close
  4. I can now successfully run this script from ArcCatalog
  5. After running from ArcCatalog I republished this to a service
  6. As I have been doing all along I call this service and pass it a parameter.

Now the job fails.  Not sure why.  I can manually run this from ArcCatalog but not when I call from JavaScript like I did in the past.

Do I have to do something differently now that this Feature Class I am trying to write too is a part of a Relationship Class?????

        btnGISPush_Click: function () {
            var dictstring = document.getElementById(JSONstring).value;
            var params1 = {
                request: dictstring
            };
            window.gpJSON.execute(params1).then(function (resultVal) {
                console.log(resultVal.results[0].value);
                var finalGPResults = resultVal.results[0].value;
            },
                function (err) {
                    console.log(err);
                }
            );
        }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
1 Solution

Accepted Solutions
jaykapalczynski
Frequent Contributor

I have no idea what happened...I deleted everything including FC and tables and rebuilt everything moving forward....it works now....sometimes don't ask why...

View solution in original post

0 Kudos
3 Replies
jaykapalczynski
Frequent Contributor

This is the error I am getting.....funny though when I run it from the GP Tool in ArcCatalog it runs fine

0 Kudos
jaykapalczynski
Frequent Contributor

I went in and removed the Relationship Class from the Database

Republished the Service and the GP Tool Service

Reran my code from JavaScript to send the GP Tool a parameter and everything worked perfect...

So it seems that the Relationship Class is causing the error....Not sure where or what I have to modify to get this to work with a Relationship class....

QUESTIONS:

Does the Python code need to change to handle the Relationship Class???

How would I write to the Feature Class as seen below and then write to the related table as well...

      Say I am creating anew feature and pass it the geometry and fields as seen below.

      Then I update a Field (Field1) in the related table with the 'UnqiueID'

OR 

Is my issue on the JavaScript side???  I cant see how that would be the case but the Relationship Class is definitly causing the error...

    workspace = r"E:/ArcGISProjects/CountySelection/cccc.sde"
    edit = arcpy.da.Editor(workspace)
    # Edit session is started without an undo/redo stack for versioned data
    #  (for second argument, use False for unversioned data)
    edit.startEditing(False, False)
    print "edit started"
    # Create update cursor
    with arcpy.da.InsertCursor(inputFeatureclass, ['SHAPE@', 'ADDRESSgeocode', 'DISTANCEparameter', 'UNIQUEIDparameter', 'COUNTYLIST', 'UnqiueID']) as cursor:
        # Start an edit operation
        edit.startOperation()
        # Perform edits
        ## CREATE THE NEW MULTI PART POLYGON IN THE FC
        cursor.insertRow([geometries[0], searchAddress, searchDistance, searchid, txt_list, validGuid])
        ## Delete cursor object
        del cursor

    # Stop the edit operation.
    edit.stopOperation()
    # Stop the edit session and save the changes
    edit.stopEditing(True)
    print "edit ended"‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
jaykapalczynski
Frequent Contributor

I have no idea what happened...I deleted everything including FC and tables and rebuilt everything moving forward....it works now....sometimes don't ask why...

0 Kudos