<?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 Re: Check In and Out form that shows the current status in the form in ArcGIS Survey123 Questions</title>
    <link>https://community.esri.com/t5/arcgis-survey123-questions/check-in-and-out-form-that-shows-the-current/m-p/1147134#M40734</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/549363"&gt;@CHedger1227&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;One option would be to use a custom JavaScript function that queries the feature service based on an item selected from a choice list. Say for example you have a choice list with all the items and a user selects item 1, the JavaScript function would then query the feature service looking up the status of item 1 and return the status.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please see this post for an example on using a custom JavaScript function for querying a feature service:&amp;nbsp;&lt;A href="https://community.esri.com/t5/arcgis-survey123-questions/survey123-pulldata-from-another-survey/m-p/1133680/highlight/true#M39766" target="_blank" rel="noopener"&gt;https://community.esri.com/t5/arcgis-survey123-questions/survey123-pulldata-from-another-survey/m-p/1133680/highlight/true#M39766&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then based on the response you can set some logic in your form it the item is checked out to prevent the form from being submitted.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 23 Feb 2022 18:46:19 GMT</pubDate>
    <dc:creator>ZacharySutherby</dc:creator>
    <dc:date>2022-02-23T18:46:19Z</dc:date>
    <item>
      <title>Check In and Out form that shows the current status in the form</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/check-in-and-out-form-that-shows-the-current/m-p/1146995#M40716</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;I am creating a check In/ Out form that will use one form to do this. Is there a way I can have it show the current status of each item in the form when they open it? I have created a dashboard that shows this but the people want to see it in the form itself.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example - item 1 is currently checked out of the office so when you open up the form choose item 1 from the drop down it will prepopulate and tell you it is currently checked out, you can add in a new record to check it in and it will create a new record.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this makes sense.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is welcome.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Feb 2022 15:33:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/check-in-and-out-form-that-shows-the-current/m-p/1146995#M40716</guid>
      <dc:creator>CHedger1227</dc:creator>
      <dc:date>2022-02-23T15:33:10Z</dc:date>
    </item>
    <item>
      <title>Re: Check In and Out form that shows the current status in the form</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/check-in-and-out-form-that-shows-the-current/m-p/1147134#M40734</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/549363"&gt;@CHedger1227&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;One option would be to use a custom JavaScript function that queries the feature service based on an item selected from a choice list. Say for example you have a choice list with all the items and a user selects item 1, the JavaScript function would then query the feature service looking up the status of item 1 and return the status.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please see this post for an example on using a custom JavaScript function for querying a feature service:&amp;nbsp;&lt;A href="https://community.esri.com/t5/arcgis-survey123-questions/survey123-pulldata-from-another-survey/m-p/1133680/highlight/true#M39766" target="_blank" rel="noopener"&gt;https://community.esri.com/t5/arcgis-survey123-questions/survey123-pulldata-from-another-survey/m-p/1133680/highlight/true#M39766&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then based on the response you can set some logic in your form it the item is checked out to prevent the form from being submitted.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Feb 2022 18:46:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/check-in-and-out-form-that-shows-the-current/m-p/1147134#M40734</guid>
      <dc:creator>ZacharySutherby</dc:creator>
      <dc:date>2022-02-23T18:46:19Z</dc:date>
    </item>
    <item>
      <title>Re: Check In and Out form that shows the current status in the form</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/check-in-and-out-form-that-shows-the-current/m-p/1148133#M40841</link>
      <description>&lt;P&gt;Zach,&lt;/P&gt;&lt;P&gt;Thank you for the response.&lt;/P&gt;&lt;P&gt;I am not very familiar with JavaScript. I was able to look and somewhat understand your code. BUT i am getting an error that reads:&lt;/P&gt;&lt;P&gt;@javascript error:SyntaxError: JSON.parse: Parse error in queryLayer.js:returnFeatures&lt;/P&gt;&lt;P&gt;I changed my ID field and the URL, the data requires a token so i believe i&amp;nbsp; added it but am not sure i added it in the correct spot. I put it in the layerURL right after the FeatureServer/1.&lt;/P&gt;&lt;P&gt;Do you have any idea what it could be?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Feb 2022 19:46:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/check-in-and-out-form-that-shows-the-current/m-p/1148133#M40841</guid>
      <dc:creator>CHedger1227</dc:creator>
      <dc:date>2022-02-25T19:46:14Z</dc:date>
    </item>
    <item>
      <title>Re: Check In and Out form that shows the current status in the form</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/check-in-and-out-form-that-shows-the-current/m-p/1148636#M40887</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/251557"&gt;@ZacharySutherby&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was able to fix the Parse Error but i have a couple of issues still.&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. I am having issues with the token. I am unsure of how to add in the token to the JavaScript.&lt;/P&gt;&lt;P&gt;2. I can only get it to work with the ObjectID is there a way I can get it to work with a field that is not the ObjectID? if so how would I do that?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;PRE&gt;/*&lt;BR /&gt;* JavaScript functions for Survey123&lt;BR /&gt;*/&lt;BR /&gt;&lt;BR /&gt;function returnFeatures(ID) {&lt;BR /&gt;&lt;BR /&gt;// Output value. Initially set to an empty string (XLSForm null)&lt;BR /&gt;let outValue = "";&lt;BR /&gt;&lt;BR /&gt;let layerURL = "https://.../ArcGIS/rest/services/.../FeatureServer/1"&lt;BR /&gt;&lt;BR /&gt;// Set up query parameters&lt;BR /&gt;let f = "f=json";&lt;BR /&gt;let where = "where=OBJECTID="+ID;&lt;BR /&gt;let outFields = "outFields=*";&lt;BR /&gt;let returnGeometry = "returnGeometry=false";&lt;BR /&gt;let returnCount = "returnCount=1";&lt;BR /&gt;let parameters = [f,where,outFields,returnGeometry,returnCount].join("&amp;amp;");&lt;BR /&gt;&lt;BR /&gt;let url = `${layerURL}/query?${parameters}`;&lt;BR /&gt;&lt;BR /&gt;// Create the request object&lt;BR /&gt;let xhr = new XMLHttpRequest();&lt;BR /&gt;// Make the request. Note the 3rd parameter, which makes this a synchronous request&lt;BR /&gt;xhr.open("GET", url, false);&lt;BR /&gt;xhr.send();&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;// Process the result&lt;BR /&gt;if (xhr.readyState === xhr.DONE) {&lt;BR /&gt;if (xhr.status !== 200) {&lt;BR /&gt;// The http request did not succeed&lt;BR /&gt;return "bad request: " + url&lt;BR /&gt;} else {&lt;BR /&gt;// Parse the response into an object&lt;BR /&gt;let response = JSON.parse(xhr.responseText);&lt;BR /&gt;if (response.error) {&lt;BR /&gt;// There was a problem with the query&lt;BR /&gt;} else {&lt;BR /&gt;if (response.features[0]) {&lt;BR /&gt;outValue = JSON.stringify(response.features[0]);&lt;BR /&gt;} else {&lt;BR /&gt;// No features found&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;return outValue;&lt;BR /&gt;}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2022 16:44:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/check-in-and-out-form-that-shows-the-current/m-p/1148636#M40887</guid>
      <dc:creator>CHedger1227</dc:creator>
      <dc:date>2022-03-01T16:44:29Z</dc:date>
    </item>
    <item>
      <title>Re: Check In and Out form that shows the current status in the form</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/check-in-and-out-form-that-shows-the-current/m-p/1149181#M40921</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/549363"&gt;@CHedger1227&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can extract the token using `&lt;SPAN&gt;pulldata("@property", 'token')` please see &lt;A href="https://doc.arcgis.com/en/survey123/desktop/create-surveys/prepopulateanswers.htm#ESRI_SECTION1_D52683929B1C4543B236BAC00E7F1876" target="_self"&gt;this documentation&lt;/A&gt; for more information.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Essentially what the JavaScript function is doing is querying the feature service to return information. To work with a different field you will need to change the where clause to be "where=&amp;lt;some field&amp;gt;=&amp;lt;some value&amp;gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the example you have above it's set to `"where=OBJECTID="+ID` so the query is looking up based on objectId.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please see &lt;A href="https://developers.arcgis.com/rest/services-reference/enterprise/query-feature-service-layer-.htm" target="_self"&gt;this documentation&lt;/A&gt; for more information on querying a feature service.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please note we also have a &lt;A href="https://community.esri.com/t5/arcgis-survey123-blog/extending-survey123-smart-forms-with-custom-js/ba-p/898782#toc-hId-1139683507" target="_self"&gt;JavaScript sample available in Survey123 Connect&lt;/A&gt; that can be used for reference and additional examples.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2022 17:13:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/check-in-and-out-form-that-shows-the-current/m-p/1149181#M40921</guid>
      <dc:creator>ZacharySutherby</dc:creator>
      <dc:date>2022-03-01T17:13:18Z</dc:date>
    </item>
  </channel>
</rss>

