{"action":"created","issue":{"url":"https://api.github.com/repos/Esri/ArcREST/issues/66","labels_url":"https://api.github.com/repos/Esri/ArcREST/issues/66/labels{/name}","comments_url":"https://api.github.com/repos/Esri/ArcREST/issues/66/comments","events_url":"https://api.github.com/repos/Esri/ArcREST/issues/66/events","html_url":"https://github.com/Esri/ArcREST/issues/66","id":92226575,"number":66,"title":"Create/Modify/Delete Relationships","user":{"login":"DShokes","id":3903212,"avatar_url":"https://avatars.githubusercontent.com/u/3903212?v=3","gravatar_id":"","url":"https://api.github.com/users/DShokes","html_url":"https://github.com/DShokes","followers_url":"https://api.github.com/users/DShokes/followers","following_url":"https://api.github.com/users/DShokes/following{/other_user}","gists_url":"https://api.github.com/users/DShokes/gists{/gist_id}","starred_url":"https://api.github.com/users/DShokes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DShokes/subscriptions","organizations_url":"https://api.github.com/users/DShokes/orgs","repos_url":"https://api.github.com/users/DShokes/repos","events_url":"https://api.github.com/users/DShokes/events{/privacy}","received_events_url":"https://api.github.com/users/DShokes/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Esri/ArcREST/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-06-30T23:48:03Z","updated_at":"2015-10-20T11:21:45Z","closed_at":"2015-10-20T11:21:45Z","body":"Now that relationships are supported in Collector for ArcGIS and soon the online map viewer, being able to modify the relationships in a hosted service would be powerful and could prevent having to republish.\r\n\r\nThis can be done on feature layers through updateDefinition, but has to be done on both layers properly. For example if you wanted to create a 1:M relationship with Layer0's GlobalID as the origin and a GUID field from Layer1, you would run two updateDefinitions:\r\nThe first would look like:\r\n```JSON \r\n{\r\n\"relationships\" : [\r\n    {\r\n      \"id\" : 0, \r\n      \"name\" : \"Layer1sinLayer0\", \r\n      \"relatedTableId\" : 1, \r\n      \"cardinality\" : \"esriRelCardinalityOneToMany\", \r\n      \"role\" : \"esriRelRoleOrigin\", \r\n      \"keyField\" : \"GlobalID\", \r\n      \"composite\" : false\r\n    }]\r\n}\r\n```\r\nAnd the second would look like:\r\n```\r\n{\r\n\"relationships\" : [\r\n    {\r\n      \"id\" : 0, \r\n      \"name\" : \"Layer1sinLayer0\", \r\n      \"relatedTableId\" : 0, \r\n      \"cardinality\" : \"esriRelCardinalityOneToMany\", \r\n      \"role\" : \"esriRelRoleDestination\", \r\n      \"keyField\" : \"RelatedGUID\", \r\n      \"composite\" : false\r\n    }]\r\n}\r\n```\r\n\r\nA function to do both admin definition updates or deletes may be unnecessary. I.e. ``` featureservice.createRelationship( originLayerID, originField, destinationLayerID, destinationField, composite=false)```. \r\nWhat about these functions: ```createRelationship(layerID,relatedTableId,role,keyField,composite=false)``` and ```deleteRelationship(layerID,relationshipid)```?  These could be run for both layers in the relationship.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/Esri/ArcREST/issues/comments/149531654","html_url":"https://github.com/Esri/ArcREST/issues/66#issuecomment-149531654","issue_url":"https://api.github.com/repos/Esri/ArcREST/issues/66","id":149531654,"user":{"login":"achapkowski","id":5131271,"avatar_url":"https://avatars.githubusercontent.com/u/5131271?v=3","gravatar_id":"","url":"https://api.github.com/users/achapkowski","html_url":"https://github.com/achapkowski","followers_url":"https://api.github.com/users/achapkowski/followers","following_url":"https://api.github.com/users/achapkowski/following{/other_user}","gists_url":"https://api.github.com/users/achapkowski/gists{/gist_id}","starred_url":"https://api.github.com/users/achapkowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/achapkowski/subscriptions","organizations_url":"https://api.github.com/users/achapkowski/orgs","repos_url":"https://api.github.com/users/achapkowski/repos","events_url":"https://api.github.com/users/achapkowski/events{/privacy}","received_events_url":"https://api.github.com/users/achapkowski/received_events","type":"User","site_admin":false},"created_at":"2015-10-20T11:21:45Z","updated_at":"2015-10-20T11:21:45Z","body":"ok will do, I'm marking this as closed."}}