<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to create readonly field with default value in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-create-readonly-field-with-default-value/m-p/778448#M1096</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a feature class (SQL Server table) that contains data from multiple clients (organizations). I want to expose the data, but control access so an org can only view/update its own data. I've created a flow as shown below (this is done for each org)&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Create a layer file (.lyrx) with a query definition against the single table to pull out the org's data (the table has a key field - ORG_ID)&lt;/LI&gt;&lt;LI&gt;Create a project (.aprx) based on the layer file and publish a REST endpoint on my ArcGIS server&lt;/LI&gt;&lt;LI&gt;Create a feature service in ArcGIS Online based on the REST endpoint&lt;/LI&gt;&lt;LI&gt;Share the feature service into an AGOL group where I have invited only members of the organization&lt;/LI&gt;&lt;LI&gt;From that feature service I build web maps, web mapping apps, surveys etc and share them into the group also&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This all works very nicely and I've scripted it so it is easy to onboard new orgs. But I have one problem I can't solve.&amp;nbsp; I need to make sure that the ORG_ID is not altered for existing records (I think I can accomplish this by hiding the field in the layer definition) and I need to make sure that the ORG_ID is correct on added records. I've looked into SOE's and DB triggers. The trouble there is there isn't enough context to know what the value is supposed to be. I tried many other approaches but nothing has worked completely.&amp;nbsp; &amp;nbsp;Any suggestions?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 03 May 2019 13:34:11 GMT</pubDate>
    <dc:creator>DonMorrison1</dc:creator>
    <dc:date>2019-05-03T13:34:11Z</dc:date>
    <item>
      <title>How to create readonly field with default value</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-create-readonly-field-with-default-value/m-p/778448#M1096</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a feature class (SQL Server table) that contains data from multiple clients (organizations). I want to expose the data, but control access so an org can only view/update its own data. I've created a flow as shown below (this is done for each org)&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Create a layer file (.lyrx) with a query definition against the single table to pull out the org's data (the table has a key field - ORG_ID)&lt;/LI&gt;&lt;LI&gt;Create a project (.aprx) based on the layer file and publish a REST endpoint on my ArcGIS server&lt;/LI&gt;&lt;LI&gt;Create a feature service in ArcGIS Online based on the REST endpoint&lt;/LI&gt;&lt;LI&gt;Share the feature service into an AGOL group where I have invited only members of the organization&lt;/LI&gt;&lt;LI&gt;From that feature service I build web maps, web mapping apps, surveys etc and share them into the group also&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This all works very nicely and I've scripted it so it is easy to onboard new orgs. But I have one problem I can't solve.&amp;nbsp; I need to make sure that the ORG_ID is not altered for existing records (I think I can accomplish this by hiding the field in the layer definition) and I need to make sure that the ORG_ID is correct on added records. I've looked into SOE's and DB triggers. The trouble there is there isn't enough context to know what the value is supposed to be. I tried many other approaches but nothing has worked completely.&amp;nbsp; &amp;nbsp;Any suggestions?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 May 2019 13:34:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-create-readonly-field-with-default-value/m-p/778448#M1096</guid>
      <dc:creator>DonMorrison1</dc:creator>
      <dc:date>2019-05-03T13:34:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to create readonly field with default value</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-create-readonly-field-with-default-value/m-p/778449#M1097</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well I came up with a very dirty solution on this that seems to work and I'll go with it until something more elegant comes up.&amp;nbsp; I create my REST service names such that I can derive the desired key field values from them. Then I wrote an SOI that:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;intercepts all &lt;SPAN&gt;"applyEdit"&amp;nbsp;&lt;/SPAN&gt;REST requests&lt;/LI&gt;&lt;LI&gt;Gets the service name it's running on behalf of (from the &lt;SPAN&gt;server environment&amp;nbsp;&lt;/SPAN&gt;"CfgName" property) and derives the desired key field value. For example if the service name is "COMPANYA_WIDGETS", the derived key value is "COMPANYA"&lt;/LI&gt;&lt;LI&gt;Digs into the received json and sets the key field is being set to the desired value before passing it on to be processed by the server.&amp;nbsp; I simply did a regular expression replacement like this:&lt;/LI&gt;&lt;/OL&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;string pattern = "\"Org_ID\":\"[^\"]*\",";
operationInput = Regex.Replace(operationInput, pattern, "\"Org_ID\":\"" + orgID + "\",");&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 08:46:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-create-readonly-field-with-default-value/m-p/778449#M1097</guid>
      <dc:creator>DonMorrison1</dc:creator>
      <dc:date>2021-12-12T08:46:32Z</dc:date>
    </item>
  </channel>
</rss>

