Select to view content in your preferred language

Relationship class is read only

1215
10
08-01-2022 05:40 AM
MartinBertrand
New Contributor

I created a relationship class that is attributed and I can't edit it via Argis Desktop nor via sdk?

0 Kudos
10 Replies
Aashis
by Esri Contributor
Esri Contributor

Currently, there is no way to update the relationship class via the Pro SDK.

You should use Geo Processing tools to update relationship class'  relationship rules,  split policy, migration , etc.

I am curious to know what you are editing.

0 Kudos
PierreMasson
Regular Contributor

I've created 2 simple stand alone tables. Clients & Orders.
Clients: ObjectId, Name, FirstName, Email
Orders: ObjectId, ClientId, OrderDate

Then I created an attributed Relationship Class between the 2. Like many client can have many orders.And added a IsShipped (short) field to it.

I add a client manually, then I do the same for the Orders table where I set the apporiate ClientId.

Now I want to manually add an entry in the relationship class, but it's read-only. 

I don't understand why. We were doing this easily a few months ago and it was working great. Of course we were doing it programatically in a more complexe data model than that but we hit that problem and we are trying to isolate the problem. This is the smaller we came up with. Why can't we add relationship data? Why is it read only??

PierreMasson_0-1659363087187.png

Please help

0 Kudos
Aashis
by Esri Contributor
Esri Contributor

What is the version of Pro and the geodatabase type, to see if we can reproduce the issue for investigation? 

0 Kudos
PierreMasson
Regular Contributor

ArcGIS Pro 2.9.2
Enterprise GeoDatabase on MS SQL.

0 Kudos
Aashis
by Esri Contributor
Esri Contributor

Moved to the Pro forum, not related to the  Pro SDK.

Tags (1)
0 Kudos
BarryNorthey
Frequent Contributor

You had to be using a Standard or Advanced license to create the relationship class but a reminder for those who might not know that relationship classes are read-only and cannot be edited when using a Basic license. While citing the version of AGP is important, the license level can sometimes be more important.

0 Kudos
PierreMasson
Regular Contributor

Using Standard

0 Kudos
PierreMasson
Regular Contributor

Just run this script (replace the 3rd line by your database sde file. Then add data in both tables and try to add a record in  rel_Cars_CarColors. It's read only..

import arcpy
import sys



gdb = 'YOUR SDE PATH FILE HERE'
arcpy.env.workspace = gdb

resObj = arcpy.CreateTable_management(gdb, 'Cars')
tbl = resObj.getOutput(0)
arcpy.AddField_management('Cars', 'Make', 'TEXT', field_length=250, field_alias='Make', field_is_nullable='NON_NULLABLE', field_is_required='REQUIRED')
arcpy.AddField_management('Cars', 'Model', 'TEXT', field_length=250, field_alias='Model', field_is_nullable='NON_NULLABLE', field_is_required='REQUIRED')
arcpy.AddField_management('Cars', 'Year', 'LONG', field_alias='Year', field_is_nullable='NON_NULLABLE', field_is_required='REQUIRED')


resObj = arcpy.CreateTable_management(gdb, 'CarColors')
tbl = resObj.getOutput(0)
arcpy.AddField_management('CarColors', 'ColorName', 'TEXT', field_length=250, field_alias='Color Name', field_is_nullable='NON_NULLABLE', field_is_required='REQUIRED')
arcpy.AddField_management('CarColors', 'ColorCodesRGB', 'TEXT', field_length=6, field_alias='RGB', field_is_nullable='NON_NULLABLE', field_is_required='REQUIRED')

arcpy.CreateRelationshipClass_management(origin_table='Cars', destination_table='CarColors',
                                                     out_relationship_class='rel_Cars_CarColors', 
                                                     relationship_type='SIMPLE', forward_label='AvailableColors', backward_label='Cars',
                                                     message_direction='Both', cardinality='MANY_TO_MANY', attributed='ATTRIBUTED',
                                                     origin_primary_key='OBJECTID', origin_foreign_key='CarId',
                                                     destination_primary_key='OBJECTID', destination_foreign_key='CarColorId')

tbl = 'rel_Cars_CarColors'
arcpy.AddField_management('rel_Cars_CarColors', 'Status', 'SHORT', field_is_nullable='NON_NULLABLE', field_is_required='REQUIRED')
0 Kudos
PierreMasson
Regular Contributor

Nobody as a solution? I think it's a bug

0 Kudos