<?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: Survey123: pulldata from another survey in ArcGIS Survey123 Questions</title>
    <link>https://community.esri.com/t5/arcgis-survey123-questions/survey123-pulldata-from-another-survey/m-p/1199598#M44129</link>
    <description>&lt;P&gt;Since querying a feature service would require access to the service URL, I don't think this would be possible in the scenario described above.&lt;/P&gt;</description>
    <pubDate>Thu, 04 Aug 2022 20:16:20 GMT</pubDate>
    <dc:creator>BenBaker1</dc:creator>
    <dc:date>2022-08-04T20:16:20Z</dc:date>
    <item>
      <title>Survey123: pulldata from another survey</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/survey123-pulldata-from-another-survey/m-p/1133072#M39724</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;In first&amp;nbsp; survey I have ID number question which user type.&lt;BR /&gt;In 2nd survey I want user to type ID and bring all information from first Survey which they type ID on that. I know I can do this by JaveScript and pulldata but I don't know JS. basically,&amp;nbsp; I need users put ID number and then all info from first survey show on 2nd survey.&lt;/P&gt;&lt;P&gt;I appreciate if I have step by step instruction with JS code.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jan 2022 20:33:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/survey123-pulldata-from-another-survey/m-p/1133072#M39724</guid>
      <dc:creator>anonymous55</dc:creator>
      <dc:date>2022-01-12T20:33:43Z</dc:date>
    </item>
    <item>
      <title>Re: Survey123: pulldata from another survey</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/survey123-pulldata-from-another-survey/m-p/1133680#M39766</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/195450"&gt;@anonymous55&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is an example available in ArcGIS Survey123 Connect that demonstrates how to use a JavaScript function to query a feature service and pull the data into the survey.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is another example that queries a hosted feature layer in Living Atlas and returns information from the service.&amp;nbsp;&lt;/P&gt;&lt;P&gt;All that would need to be done is to switch the feature service URL with the one you are interested in, update the where clause when making the &lt;A href="https://developers.arcgis.com/rest/services-reference/enterprise/query-feature-service-layer-.htm" target="_self"&gt;query&lt;/A&gt;, and add a token if your feature service is secure.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jan 2022 23:27:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/survey123-pulldata-from-another-survey/m-p/1133680#M39766</guid>
      <dc:creator>ZacharySutherby</dc:creator>
      <dc:date>2022-01-13T23:27:02Z</dc:date>
    </item>
    <item>
      <title>Re: Survey123: pulldata from another survey</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/survey123-pulldata-from-another-survey/m-p/1148629#M40886</link>
      <description>&lt;P&gt;Zach,&lt;/P&gt;&lt;P&gt;You mentioned is your data is secure to "&lt;SPAN&gt;add a token if your feature service is secure." how would i go about doing that where does that go?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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,token) {&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 = "[Feature Service URL]"&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;if(token){&lt;BR /&gt;url = url + "&amp;amp;token=" + token;&lt;BR /&gt;}&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;</description>
      <pubDate>Mon, 28 Feb 2022 16:25:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/survey123-pulldata-from-another-survey/m-p/1148629#M40886</guid>
      <dc:creator>CHedger1227</dc:creator>
      <dc:date>2022-02-28T16:25:11Z</dc:date>
    </item>
    <item>
      <title>Re: Survey123: pulldata from another survey</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/survey123-pulldata-from-another-survey/m-p/1187522#M43492</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 downloaded the script and have it working with your data. Now, I am trying to replace parameters to work with my own data, but am getting an error. Here's a few images of what I'm getting.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;/*
 * JavaScript functions for Survey123
 */

function returnFeatures(ID) {

    // Output value.  Initially set to an empty string (XLSForm null)
	let outValue = "";
//The service URL of the layer I'm trying to query
	let layerURL = "https://services.mh-gis.com/server/rest/services/Address/SiteAddressPoint/FeatureServer/0"
	
	
	// Set up query parameters
	let f = "f=json";
//FULLADDR is the field I'm trying to match to within the service
	let where = "where=FULLADDR="+ID;
	let outFields = "outFields=*";
	let returnGeometry = "returnGeometry=false";
	let returnCount = "returnCount=1";
	let parameters = [f,where,outFields,returnGeometry,returnCount].join("&amp;amp;");
	
	let url = `${layerURL}/query?${parameters}`;
	

	// Create the request object
	let xhr = new XMLHttpRequest();
	// Make the request.  Note the 3rd parameter, which makes this a synchronous request
	xhr.open("GET", url, false);
	xhr.send();
	
	
	// Process the result
	if (xhr.readyState === xhr.DONE) {
		if (xhr.status !== 200) {
			// The http request did not succeed
			return "bad request: " + url
		} else {
				// Parse the response into an object
			let response = JSON.parse(xhr.responseText);
			if (response.error) {
				// There was a problem with the query
			} else {
				if (response.features[0]) {
					outValue = JSON.stringify(response.features[0]);
				} else {
					// No features found
				}
			}
		}
	}
	return outValue;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="BenBaker1_0-1656448886055.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/44700i0F77BAB64702D571/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BenBaker1_0-1656448886055.png" alt="BenBaker1_0-1656448886055.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="BenBaker1_1-1656448947187.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/44702iA3D8BEB12420F3D2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BenBaker1_1-1656448947187.png" alt="BenBaker1_1-1656448947187.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you have any thoughts on why it's not finding f_id? I can't find find where else to define it in the script or the calculation?&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2022 20:45:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/survey123-pulldata-from-another-survey/m-p/1187522#M43492</guid>
      <dc:creator>BenBaker1</dc:creator>
      <dc:date>2022-06-28T20:45:22Z</dc:date>
    </item>
    <item>
      <title>Re: Survey123: pulldata from another survey</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/survey123-pulldata-from-another-survey/m-p/1187960#M43513</link>
      <description>&lt;P&gt;The issue I was having was a syntax error. I did not put f_id in brackets as ${f_id}. However, I did have further issues passing the parameter as text before the script worked. Since there are spaces in the address, I had to add additional quotes to the query line:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;let where = "where=FULLADDR="+"'"+ID+"'";&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 29 Jun 2022 18:22:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/survey123-pulldata-from-another-survey/m-p/1187960#M43513</guid>
      <dc:creator>BenBaker1</dc:creator>
      <dc:date>2022-06-29T18:22:58Z</dc:date>
    </item>
    <item>
      <title>Re: Survey123: pulldata from another survey</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/survey123-pulldata-from-another-survey/m-p/1199539#M44116</link>
      <description>&lt;P&gt;So this solution could not be used offline?&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/251557"&gt;@ZacharySutherby&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2022 18:14:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/survey123-pulldata-from-another-survey/m-p/1199539#M44116</guid>
      <dc:creator>KKing</dc:creator>
      <dc:date>2022-08-04T18:14:42Z</dc:date>
    </item>
    <item>
      <title>Re: Survey123: pulldata from another survey</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/survey123-pulldata-from-another-survey/m-p/1199598#M44129</link>
      <description>&lt;P&gt;Since querying a feature service would require access to the service URL, I don't think this would be possible in the scenario described above.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2022 20:16:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/survey123-pulldata-from-another-survey/m-p/1199598#M44129</guid>
      <dc:creator>BenBaker1</dc:creator>
      <dc:date>2022-08-04T20:16:20Z</dc:date>
    </item>
  </channel>
</rss>

