Survey123 Tricks of the Trade: pulldata("@layer")

60225
51
10-26-2022 10:49 AM
IsmaelChivite
Esri Notable Contributor
21 51 60.2K

 

 

The pulldata("@layer") function was introduced with Survey123 version 3.16 (October 2022). It allows you to query an ArcGIS layer and retrieve data from it.  In this blog, I will explore common scenarios for this function and describe design best practices and limitations.

A bit of context first

 

Querying ArcGIS layers using XLSForm expressions is not a new concept. Back in the day, I described how to do it using custom JavaScript functions.  Using custom JS functions gives you great flexibility, but you need to know how to write JavaScript, and most importantly, you can't execute a custom JS function if you share a survey publicly.

The new pulldata("@layer") function simplifies the syntax for querying ArcGIS layers, and it can be used in public surveys too!

 

Point-in-polygon calculations using a map

 

The animation below shows a typical scenario for pulldata("@layer"). A calculation takes the location set in the map, and triggers a point-in-polygon query to retrieve a value from the intersecting polygon; a parcel's APN (Assessor Parcel Number) in this case. 

Survey123_APN.gif

I can think of a gazillion cases where point-in-polygon queries will be handy... just think of the polygon layers you may have: parcels, soils, fire perimeters, sales territories, evacuation zones, city boundaries...  

 

Point-in-polygon calculations using an address location

 

Point-in-polygon queries do not strictly require a map in your form: They require a location and a polygon layer.  In the example below, the respondent enters an address, and a point-in-polygon query is triggered to automatically calculate the City Code that applies to that location. In this case, the location for your point-in-polygon query does not come from a map, but an address.  The City Code comes from the feature layer targeted in your point-in-polygon query.

Survey123_Zoning.gif

Point-in-polygon calculations will help you make your forms geographically smarter. You can choose to display the geo-calculated values in the form, or keep them hidden.

 

Point-in-polygon queries for data validation

 

You can use the output of pulldata("@layer") to calculate a value, like in the examples above, or to feed a data validation rule. In the next animation, a point-in-polygon query checks if a reported incident falls within a City of Redlands public park. If it does, the report is accepted. If it does not, the user will not be able to submit the form.

Survey123_Park.gif

Again, we are essentially doing a point-in-polygon query using pulldata("@layer"). In this case, the output of the query is used to check the integrity of the data.

 

Calculate values using an attribute query

 

In the example below the respondent enters a customer number and the form automatically populates contact information about that customer.  That is all done through pulldata("@layer"): The customer number is used to find a record in the customer layer. If found, the name and email attributes are populated.

Survey123_Lookup.gif

Customers, assets, buildings, parts... You can query any ArcGIS layer or table as long as, of course, the user completing the form has access to the layer or table.

 

Count records in a table or layer

 

Another common use case is that in which you want a survey to stop accepting responses once a certain number of records are submitted. This is also something pulldata("@layer") can do for you. Check out the next screenshot: Through a query to the signup table, we can tell how many people already signed up. A constraint in the form uses this value to allow (or not allow) another person to submit the survey.

 

Survey123_TooManyRecords.png

Now that we have reviewed some common scenarios, we are going to get hands on... 

 

Getting started with pulldata("@layer")

 

If you have read this far, you will be eager to start. The pulldata("@layer") syntax is described in this help topic. Have a good read of this topic as it describes the basics very well.

 

Point-in-polygon query to retrieve a single attribute: pulldata("@layer", "getValueAt")

This three-minute video shows, step-by-step, how to construct a simple point-in-polygon query using the World Administrative Divisions layer from ArcGIS Online.  If you want to follow along, make sure you have Survey123 Connect version 3.16 or newer.

 

For your reference, you will find the getValueAt.xlsx file attached at the bottom of this post.

The getValueAt_Constraint.xlsx file shows how you can use the calculated value from the point-in-polygon query to ensure the location chosen by the user falls within a polygon. 

 

Point-in-polygon query to retrieve multiple attributes: pulldata("@layer", "getRecordAt")

Another three-minute step-by-step video building on the previous one. In this case, the getRecordAt operation is used to do a point-in-polygon query and get an entire record. Using the pulldata("@json") function, the record is parsed locally to get multiple attributes efficiently.

Find the getRecordAt.xlsx file in the attachments section below for reference.

 

Refining point-in-polygon queries using extra parameters

On top of the well defined parameters you can pass to the getRecord and getRecordAt operations, you can also pass extra parameters to the feature layer url  to perform some more advanced queries. For example:

  • distance: This parameter allows you to buffer the input geometry (geopoint) to find polygons within a given distance. By default, the distance units come in meters, but you can also specify other units. For example, the following expression will apply a buffer of 1600 feet to the provided location (geopoint) and find any intersecting polygons in the critical habitats layer.

pulldata("@layer", "getRecordAt", "https://services.arcgis.com/QVENGdaPbd4LUkLV/ArcGIS/rest/services/USFWS_Critical_Habitat/FeatureServ...?distance=1600&units=esriSRUnit_Foot", ${location})

I highlighted in blue the key part where the distance and units are specified. These extra parameters are added to the URL. You need to add a question mark (?) to start adding extra parameters and then separate them with an ampersand symbol (&).

  • gdbVersion: This parameter is useful if you want to query a versioned multi-user geodatabase feature layer. 
  • orderByFields: If you expect your query to return more than one value, you can use this parameter to sort the results. For example, say you use getRecord to get all tickets submitted by a user. You can use orderByFields to sort all tickets by date in descending order. This will make your getRecord operation to give you back the latest ticket submitted.
  • outStatistics and groupByFieldsForStatistics: Ideal when you want to retrieve stats from your layer, rather than a unique record or value.  This is how, for example, you will want to get a count of records in a layer.

Check the Query (Feature layer) help topic to learn more about all the extra parameters you can use. The Request Parameters section in this help topic describes the parameters that you cannot use. 

Advanced techniques with pulldata("@layer")

 

Survey123 Connect includes a sample called Query a Feature Layer. Have a look at it, as it illustrates some advanced techniques you can leverage to gather statistics and construct dynamic queries.

Survey123 Connect Query Layer Sample.png

 

 

A few extra tips and things you should know

 

  • Public surveys: Unlike custom JS functions, you can use pulldata("@layer") with public surveys.
  • No offline support: The pulldata("@layer") function only works while online. This makes it particularly useful for web surveys, although if your device is connected, it will also work in the Survey123 field app.
  • Support starts with version 3.16: If you go into Survey123 Connect and you can't even get the samples to work, check your Connect version. You need 3.16 or newer for this function to work in Connect.  All surveys published with version 3.16 or newer will work in the web app.  For the field app, ensure users have the latest version of Survey123 installed on their devices. Otherwise, your pulldata("@layer") function will be ignored.
  • You do not need to add a layer to a map before you query it: I think this one should be obvious already, but I will add it just in case. You do not need to add a layer to your survey map before you can query it. In fact, you do not need a map in your survey to do a query.  All you need to do is to pass the URL of your layer to the function.
  • About tokens: When using pulldata("@layer") you do not need to worry about tokens. Since the token of the signed in user is passed automatically to the function.
  • concat() is your friend: When composing a SQL WHERE filter, use the concat() function. For example:
    • Good: concat("MANHOLE_ID='", ${question1},"'")
    • Bad: MANHOLE_ID='${question1}'
  • SQL tips: Where statements can sometimes be tricky.
    • Quote if you work with a text field: concat("MANHOLE_ID='", ${question1},"'")
    • Do not quote if numeric: concat("MANHOLE_ID=", ${question1})
    • What is the SQL to query records in the last 15 days? Check the solution here.
  • Layer sharing: Make sure the layers you query are appropriately shared. For example, you cannot expect a private layer to be available in a public survey. Do not dream of Survey123 magically letting you query a layer the signed in user does not have access to.  If Survey123 cannot access a layer you reference in pulldata("@layer"), the output of the function will be empty. The user will not see an error or warning.
  • Layer capabilities: The layers you query need to be queryable. This may seem obvious, but it may catch you out.  If the data you are querying is sensitive, consider the use of feature layer views to restrict access to fields and rows as appropriate.
  • pulldata("@layer") is not for populating a list: The purpose of pulldata("@layer") is to help you query a layer and get back either one record, or one value (attribute) from a record.  If you want to query a layer to populate a list, use the search appearance instead as described in this blog post by @BrettS or this other blog post on geolists.
  • If you need a bit more guidance, you can check this video with a few demos and step by step instructions.

 

More info in video

 

A one hour session covering pulldata("@layer") was recorded some time ago. More info here

51 Comments
chargeetudeti
Emerging Contributor
Hello Ismel
Thank you for all these developments. I am looking from a layer to recover not the information of a polygon but the outline of this polygon, after several searches I turn to you because I have not found anything.
Thinks
Julien

 

MaddieShields2
Emerging Contributor

@IsmaelChivite - is there any way to modify the syntax to pull polygon in polygon data or does that still need to be done with a custom JavaScript? The point in polygon feature is an excellent starting point for pulling the initial polygon data, but then I'd like to take it step further and use that data to pull select data for all polygons intersecting that polygon.

RyanBohan
Frequent Contributor

Hi Ismael & Team,

Can I use pulldata("@layer") for records that do not have geometry? 

We are working on an easy-to-use survey for our Emergency Management Team. The survey is likert questions 1-6 for the level each hazard and a text field for additional information.  No geometry is captured in the survey, as it is not needed, and we do not want to collect users home locations.

RyanBohan_1-1667423432877.png

The survey will be displayed as a pop-up using Feature Info widget in Experience builder.  Filtered to only a single recorded sorted by newest date.  In other orders last survey in wins.  To update, submit a new survey.  

RyanBohan_0-1667423330125.png

The question has come up, can users update a previous survey instead of submitting a new record.  Of course, they could edit the feature layer.  However, that is a lot more effort than submitting a new survey, and hard to do on one's phone.  Would it be possible to use the pulldata("@layer") to grab the values of the last submitted record?

I am sure this would be easier to do with a single record.  However, as it is related to Emergency Management it would be nice to keep a running record of the surveys for after action reports.  

 

IsmaelChivite
Esri Notable Contributor

@RyanBohan  I am not sure I follow completely what you want to do, but to edit records you may want to follow this: https://community.esri.com/t5/arcgis-survey123-blog/survey123-tricks-of-the-trade-editing-records-in... 

RyanBohan
Frequent Contributor

Hi @IsmaelChivite,

Sorry for the confusion.  Can I set up a survey to build off previous results? 

For example:

  • Monday a user adds a note:  "Cedar Creek fire 10% contained, please avoid area."
  • Tuesday a user adds a note:  "Cedar Creek fire 50% contained, please avoid area."
  • Wednesday a user adds a note:  "Cedar Creek fire 90% contained, please avoid area."
  • Thursday a user adds a note:  "Cedar Creek fire 100% contained."

It would be great if the survey could automatically pre-populate the note field from a previous survey (last survey sorted by date), allowing the user to quickly update the new information.

 

erica_poisson
Frequent Contributor

@IsmaelChivite  - 

Could the "@layer" function be used to locate the record with the most recent CreationDate (editor tracking field)?

I was wondering if I could build a where query to return this... I've been doing a bit of testing with building the SQL query in Pro but am not having luck there. I was thinking something along the lines of...

CreationDate = (SELECT MAX(CreationDate) FROM table)

Could you provide any insight on this?

IsmaelChivite
Esri Notable Contributor

@erica_poisson   @ryank 

Try adding the orderByFields parameter at the end of your feature layer URL:

pulldata("@layer", "getRecord","<your_featurelayer_url>?orderByFields=CreationDate DESC", "1=1")
For the above to work, you will want to make sure that:
  • Your featurelayer URL, as usual, includes the layer index at the end
  • Your feature layer has query capabilities enabled

You can use either getRecord, or getValue.

Here are some examples. This expression uses getValue to get from a US counties layer the most populated county name.

 

pulldata("@layer", "getValue", "attributes.NAME", "https://services5.arcgis.com/jMCHJcLe13FaKCFB/arcgis/rest/services/US_Counties/FeatureServer/1?orderByFields=POPULATION DESC", "1=1")

 

Below, the same thing, but we get the entire record as a JSON string, which we can later parse with pulldata("@json") 

 

pulldata("@layer", "getRecord", "https://services5.arcgis.com/jMCHJcLe13FaKCFB/arcgis/rest/services/US_Counties/FeatureServer/1?orderByFields=POPULATION DESC", "1=1")

 

Hope this helps!

erica_poisson
Frequent Contributor

@IsmaelChivite  - 

This is very helpful - thank you! 

Daniel_Hood
Emerging Contributor

@IsmaelChivite 

Thank you for all the great information about the pulldata(@"layer") updates. 

Would it be possible to use this method to bring in image attachments from other layers into a image question?

I tried briefly using the attachment URL of an image attachment from a layer (with the object's OID and attachment's Id in the URL, along with the "attachments"). No errors showed up, but the Image question remained blank. 

Is this workflow of adding an image attachment from another layer directly into an Image question on a Survey even possible with Survey123? 

Thank you!

PaulRuiter_EsriNederland
New Explorer

@IsmaelChivite thank you for this post.

I'm working on a survey where I want to set the survey location based on a adress search. First I use this: pulldata("@layer", "getRecord", "<adress service>/ArcGIS/rest/services/Map/FeatureServer/00?returnGeometry=true", <query>), afterwards I parse the response and set a record of type geopoint to the found location concat(number(${X}),' ', number(${Y})).

When I run this in Survey123 Connect it seems to run fine, the data and location is returned, when I run this in a web browser after publishing I do not get a location in the response of the pulldata request. Debugging shows that the browser uses returnGeometry=false, no matter what I configure.

Is there another way to set the survey location based on adress fields?

PeterMacKenzie2
Frequent Contributor

can this be adapted to  a near analysis instead of just an intersect?
use case example: populate a field with the the nearest train station to my location (geopoint). 

PaulRuiter_EsriNederland
New Explorer

@PeterMacKenzie2 at the bottom of this page https://doc.arcgis.com/en/survey123/desktop/create-surveys/xlsformformulas.htm it mentions that you can also use distance as query parameter. To accomplish something similar to near analysis you could search for stations within 100 meters, if there is no result, search within 500 meters etcetera. Not as clean but it will get some result. I haven't tried it but it would look something like this then pulldata("@layer", "getRecordAt", "https://<url>/FeatureServer/0?distance=100", ${location}, "")

AdriannaBarton
Occasional Contributor

Hi @IsmaelChivite , 

I am able to pull data from a feature layer properly, but when I pull in a date field I cannot format it with the format-date function like I usually do. It is pulling in the string of numbers as is normal for date fields but I keep getting a type 'mismatch error' when trying to format it. I have the same function working in this form for a date that wasn't pulled in via the pull data calculation. Please let me know if I'm missing something. 

Thanks!

SMDSAdministrador
Occasional Contributor

@AdriannaBarton 

Not sure about your workflow, but in a filled out web form and with an editable question of type date, I solved this problem by dividing the number returned by the query by "86400000"

Example: pulldata("@json", ${json_cod_ficha_atend}, "attributes.data_atendimento") div 86400000

SMDSAdministrador
Occasional Contributor

Is there any way to return the X and Y spatial attributes in a web form (and then calculate the geopoint)?

I manage to make it work in the Connect preview, however, when publishing the form, the query does not return the spatial ("geometry") part of the layer. I'm using a query like "GetRecord" and calculating a series of other fields with "@json".

Is it some configuration in the query layer that I'm missing?

Image 1: Geometry attributes returned in Connect

SMDSAdministrador_1-1674568607932.png

Image 2: Geometry Attributes DO NOT appear on the web form

SMDSAdministrador_2-1674568724807.png

RobertAnderson3
MVP Regular Contributor

I see this as a final point in your post:

  • pulldata("@layer") is not for populating a list: The purpose of pulldata("@layer") is to help you query a layer and get back either one record, or one value (attribute) from a record.  If you want to query a layer to populate a list, use the search appearance instead as described in this blog post by @BrettS 


Does this mean it is not possible to pull multiple records with this?

The workflow I'm thinking of is we are using Workforce to track assets that work is completed on during the day (in this case, garbage collection which is 50+ assets a day, too many for an individual survey at each). Then we have a Survey123 form to enter the employees information, work hours, vehicle use, etc. I was wondering if using this pulldata I could get the information from the Workforce Assignments layer to populate either a select_multiple or a text field with comma separated values. Not populating a choice list, but entering values into a question directly.

To create our work orders we need the asset information, with Workforce capturing which is done, and Survey123 capturing the resources used, if pulldata(@layer) can get that information, this would be perfect to link the data.

MiltonSolano
Frequent Contributor

Hey @IsmaelChivite ,

I checked all the files you posted here and the documentation page, but for the life of me I can't find how to implement the "Count records in a table or layer" functionality. How did you do the count? Are you using a separate table or the same survey table?

Please, help me to better understand how to accomplish this.

Thanks!

Milton

kidrauhl
New Explorer

Anyone here have the example of  "Count records in a table or layer"?

 

OlivierDemars1
Occasional Contributor

@kidrauhl and @MiltonSolano  I count the number of records related to a specific task this way:

pulldata("@layer", "getValue", "attributes.totalcount", concat(${url_query}, '?outStatistics=[{"statisticType": "count","onStatisticField": "objectId","outStatisticFieldName": "totalcount"}]'), concat("task_id ='",${task_id},"'"))

where ${url_query} is the feature layer url and ${task_id} the filter value for the task_id attribute.

It works fine

Olivier

bbaker_tngeo
Regular Contributor

Hi @IsmaelChivite ,

I think I'm overlooking something, but is there a reason the @pulldata(@layer...) function would populate in the survey, but the data would not be submitted?

I have a survey that pulls the owner and parcelID from a Location questions using getRecordAt method. The field populate when a location is selected on the map, but when the survey is submitted and I go back to look at the sent form or look at the entry in the Survey123 website, those fields are blank?

bbaker_tngeo_0-1677610463292.png

Before Submitting:

bbaker_tngeo_1-1677610518623.png

After Submitting:

bbaker_tngeo_2-1677610576468.png

 

 

***Update to this post: It appears the json response field was too short (1000 characters) which was truncating the field and causing errors. I bumped the field length up to 100000 and now those attributes are being written to the table after submitting the survey. 

 

 

JerrySneary
Regular Contributor

Hi @OlivierDemars1 and @IsmaelChivite 

I used pulldata("@layer") to return the record count but it is off by one. The first record is 0 not 1. How to you fix this?

In JavaScript I use var nextIncrement = String(r + 1)

Kind regards,

Jerry

OlivierDemars1
Occasional Contributor

Hi @JerrySneary ,

Have you done the same query on your REST endpoint? This will tell you if you have an issue in your pulldata or if this is the actual count provided by your service.

Best regards,

Olivier

JerrySneary
Regular Contributor

Hi @OlivierDemars1 ,

I was able to get it to work using the code below. In the test environment, I could get this to work with just two rows, but for it to work properly on the web app, I had to use four rows. 

pulldata("@layer", "getValue","attributes.TotalCount",${AddFieldToURL})
concat("https://services3.arcgis.com/cEsSI6IR59h5UGE4/arcgis/rest/services/service_e788f2c790284803abfe2f08c97094f0/FeatureServer/0?outStatistics=[{'statisticType':'count','onStatisticField':'objectId','outStatisticFieldName':'TotalCount'}]","")
${Applicant_Attribute} + 1
if(${Survey_Count} < 10, concat('00',number(${Survey_Count})), if(${Survey_Count} < 100, concat('0',number(${Survey_Count})), ${Survey_Count}))

 Kind regards,

Jerry

TeresaWhitney
Occasional Contributor

I need the same functionality as the Redland Parks example, where I only want the point added if within a specific polygon buffer feature service. I use the same polygon feature service to populate a Name feature in the new point feature but I can’t find a good example of the location constraint.

CarlaCuccia
New Explorer

Hello Ismael 

Thank you for all explanations about pull data. I have tried to use pull data for atributte query but it didn't work out. Although, I have applied all the tricks that you put in the blog. 

Does anybody else have the same error?

MissouriOffice_of_Geospatial_I
Occasional Explorer

Hello,

I want to use the pulldata function similar to the short gif under "Calculate values using an attribute query" to be able to link license numbers to individuals then auto populate their name, email, and other entered data. Is there somewhere that shows the syntax of how to make that calculation in S123?

 

ZachBodenner
MVP Regular Contributor

@PeterMacKenzie2 

can this be adapted to  a near analysis instead of just an intersect?
use case example: populate a field with the the nearest train station to my location (geopoint). 

Did you ever figure out if you could do this? I'm trying to do basically the same thing.

ryannorris
New Contributor

I would like to use the pulldata("@layer", "getValue" function in a survey that I am building.  At the beginning of the survey there are three question that use the autocomplete search("list function to make some selections from a feature service polygon layer.  The first is for the owners name, the second uses parameter filters to allow you to see only the tract the above owners owns, and then select the tract you want.  The third then using  parameter filters to only see stands in above tract field allows you to select the stand(individual polygon) you want.  There is an acres field in the attribute table that I want to use the pulldata to capture.  My question is that in the survey after the three questions are answered resulting in selecting the stand I want, can pull data be used to go get the value in the acres field tied to that selected stand record?

silvera
Occasional Contributor

I know pulldata("@layer") only works online, but just checking this special case:

Is there a way for it to access a layer in an offline vector basemap?

MarkWILSON_LLS
Occasional Contributor

Gday @silvera

 

I'd be interested in this also. Would the offline Vector basemap be associated with the SVY123 Survey or in FieldMaps? 

Alternately could pulldata("@layer") fetch results as an offline survey is sync'd back to the server based on the lat/long collected at the field point? 

silvera
Occasional Contributor

Hi MarkWILSON_LLS,

In my case, the basemap is associated with Survey123. But that was simply because that's the app I chose. Of course, any basemap can be associated with both Survey123 and Field Maps, including offline vector ones.

That's an idea to calculate pulldata("@layer") when back online. But not in my case, where users need to see the result while still in the field (e.g. offline).

JaredTaylor_KS
Frequent Explorer

Hi @IsmaelChivite,

Comment/praise: The pulldata function is an incredible advancement in the Survey123 application and has allowed me to simplify & automate tasks for our field crews as well as provide actionable data to our dashboards. Thank you so much for getting it to us and the great tutorials you provide us all with as well as the huge amount of interaction with us all in the comments.

Question: Is there a way to omit the “geometry” portion of the JSON response to the pulldata("@layer", "getRecordAt") function?

Background: I am pulling in four attributes from a polygon layer.  I am trying to be a “good citizen” and use getRecordAt and then parse the JSON. While this only uses the single http request, it returns a massive amount of text because of the complexities of the parcels. My worst example is the JSON character length of the attribute table is 432 characters, however with the geometry in the JSON it jumps to 283,497 characters. Since we have to name the JSON field to call it and parse it in the form, it is being submitted with the form. The text file of that JSON payload is 277 KB. That is the size of a screenshot image.  I am trying to develop in a sustainable manner and use as little computational power as possible in my form design, however at this point it seems like it may be less “expensive” to do four separate “getValueAt” http calls instead of one “getRecordAt” because of the size of the “geometry” field in the text, along with the data pulling and sending because of that field.  Can you please offer up what you would do?

JSON Example: {"attributes":{"OBJECTID":299,"BLDGID":3800,"Bldg_Name":"Example Building Name","Division":"Example Division","Division_Desc":"Example Division Description","MGRName":"Example Manager Name","MGR_Email":"MGR@example.com","Inspector":"Example Inspector","Inspector_Email":"Inspector@example.com","Inspector2":"","Inspector2_Email":null,"GlobalID":"Example Global ID","Shape__Area":69298158.71875,"Shape__Length":320926.140389049},"geometry":{"rings":[[[-155.5473912242,20.1245537142841],[-155.547158159892,20.1243830894184],[-155.546994967446,20.1243059910649],[-155.546686150906,20.1242564514348],[-155.546365653572,20.1243059497348],[-155.545998568709,20.1243004089693],[-155.545794614309,20.1242563088881],[-155.545707199249,20.1242068265984],[-155.54558486847,20.12409672054],[-155.545532430214,20.1239756779275],[-155.545433417005,20.1238711057396],[-155.545217839303,20.1237114233726],[-…

Thank you,

Jared

FrankMartin1
Regular Contributor

Hi @IsmaelChivite ,

I'm having trouble with the constraint message for the geopoint location in a point in polygon verification using multiple languages.  The constraint messages for other types are working correctly with multiple languages.

FrankMartin1_0-1697033351047.png

I'm using Survey123 Connect version 3.18.124.  My XLSForm is configured as shown below:

FrankMartin1_1-1697033520938.png

I tested just using with just using a "constraint_message" column for the geopoint and the the message appeared correctly for a constraint vilolation.  It appears that the constraint_message with a language designation is not working for the a geopoint type constraint.   Am I missing something?

Regards,

Frank

 

AmandaBeck
Regular Contributor

Hi @IsmaelChivite 

Is it possible to have the data that is pulled into my survey to be bolded and bigger? Can I add basic html to the calculation column in survey123 connect that will make this happen?

See attached screenshot of what I'm talking about. I want the "No" to be bigger and bolded text.Areyoueligible.jpgThanks in advance!

RobertAnderson3
MVP Regular Contributor

Hi @AmandaBeck 

Directly in the question itself I'm not sure, I think the HTML will only really display in a question label, so what I might suggest is calculating the yes/no in a hidden field and then in a NOTE type field (which you could set to fieldType null so it doesn't store extra data in your layer) set the label to have the HTML and then ${question} in the label. Like <b><font color="red"font size = "4">${question}</font></b>

Or you could include the HTML in the calculation so you can have different HTML for yes or no.

if(condition,"<b><font color="green"font size = "4">Yes</font></b>",<b><font color="red"font size = "4">No</font></b>)

AmandaBeck
Regular Contributor

Hi @RobertAnderson3 

Thanks for your reply! I was able to use your first suggestion!

RobertAnderson3
MVP Regular Contributor

Happy to help @AmandaBeck !

FourCornersMapping
Frequent Contributor

@IsmaelChivite  @RobertAnderson3 Is it possible to pull the geometry of a layer into the "geopoint" question in a survey? I have a point feature layer separate from a survey, and I'd like the survey to autopopulate the geopoint field (hidden) with the location of a record after the user selects a value from a "select_one" field. To clarify, the survey's feature layer is separate from the point feature layer from which it would pull data. 

Workflow something like: The user selects "Choice 1" from the select_one field. The geopoint field pulls the location of the record with the same name (Choice 1)  from the separate feature layer. The location is recorded in the geopoint field, which is hidden from the user. Upon submission of the survey, the survey point is plotted in the location of the record "Choice 1" from the feature layer.

cldnbcs08
New Contributor

Hi @IsmaelChivite @RobertAnderson3 

Is it possible to use pulldata to get the extent (XMin,YMin,XMax,YMax) of each polygon on a feature layer?

leahmaps
Frequent Contributor

Hi all! I am hoping to do something like what is shown in the 'Count records in a table or layer' sample.  

What I am interested in doing is creating a single select question with 3 options (A, B, and C), but limit the amount of times each can be picked. For example, I only want option A to be submitted to 10 times, B 15, and C unlimited. Then show a note that the option you selected is no longer available and to stop from submitting the survey.

I know this would be possible using pulldata, but I don't know how to execute it. Is there anyone who has done something similar and would be able to provide some guidance? The layer I need to reference would be the one the survey makes.

CoreyWilliamsESRIAccount
Occasional Contributor

We've been using this calculation in my organization for some time now as a way to assign sales persons (read-only, calculated & required field) based on the address.  Users are finding, in the web form, when they go to edit the survey, intermittently but often enough, the sales persons do not calculate unless they alter the address and change it back.  Has anyone else experienced this?  I haven't had luck with support.

Here is a sample of the link used to edit a survey:

https://survey123.arcgis.com/share/ItemID?mode=edit&globalId=GlobalID&hide=field:hidden_ field?autoRefresh=true&recalculate=field:SalesPerson1,field:SalePerson2&encodeUrlParams=true

dns
by
Occasional Contributor

Thank you for this resource.

I got the attribute query calculation to work. I found the concat function is required for crafting SQL queries using dynamic data from other questions to pass pulldata(@layer). It's mentioned concat function is nice to use because SQL is 'tricky', in reality it's needed because it seems the environmental variables with {} syntax don't properly parse if they are inside a string! This should be clarified and I'd recommend updating it to avoid confusing people.

NathanBush1
Occasional Contributor

I have field staff using Field Maps to navigate to an existing set of points, each point has a unique "Feature_ID". Once they arrive within the vicinity, they click on the point to open the popup window where a link takes them a more detailed Survey 123 form.

I'd like to use the pulldata() function to auto-populate a question within the form with the "Feature_ID" pulled from the point. I see the point-within-poly, but will this work for just a point? Maybe I'm overseeing a more simpler approach? 

Thanks! 

Ozman
by
Occasional Contributor

Excelente explicación y ejemplos @IsmaelChivite gracias por compartirlos, pero entiendo que en teoría aun no hay algo practico desde el usuario gis que pueda cargar una capa de polígonos tipo geocercas; de donde se limite el envió de encuestas las cuales estén fuera de estos polígonos. Vi el caso del parque en Redlands, pero esto si fuera una solo ubicación, pero que pasaría si el escenario son varios parques y necesito que cualquier punto que este fuera de esos parques (polígonos), en una misma encuesta no los tome como validos.. y todo esto desde el contexto que se estaría elaborando dichos formularios desde Survey123 Connect, es posible?

Saludos,

DJB
by
Regular Contributor

Hi @IsmaelChivite ,

Is there a way to pulldata from ImageServer service?  I would like to pull the elevation (Z value) from a lidar service but cannot get access to the field I need.  

I am able to access any of the following fields:

DJB_0-1719417267416.png

But what I need is this field: Raster.ItemPixelValue

DJB_2-1719417383867.png

DJB_3-1719417520004.png

Thank you for your assistance.

 

TKSHEP
by
Frequent Contributor

@IsmaelChivite  Is there a way to use an If statement when using the pulldata(@layer)?  The layer is polygons, and I am trying to use pulldata("@layer", "getValueAt", "attributes.area", "https://hostedfeatureserver.com", ${device_location}, "") and if device location is outside one of the layers boundaries then instead of the attributes.area use text  Outside USA.  How would I use the calculation to do this?

 

Thank you,

BNix_TPA
Emerging Contributor

Hi, I'm using this tool to pull last survey submission information for inspections that are being submitted. On the web or in the computer the person submitting the info gets the most up to date for the previous inspection information.  On the mobile device you are required to close out of the app and refresh the inbox to see the latest data submitted.  Is there an easier way to do this on mobile?

DoZ
by
Regular Contributor

Hello  OlivierDemars1,

I read your Answer and I think it is quite what i am looking for, but need a quick advice:

I have a simple feature layer (FS_LAYER_Employees) with name of employees and contract status:

ObjID

Name

Surname

Contract

1

Marco

Wight

Active

2

Lucas

Ross

Active

3

Alice

Smith

Dismissed

4

Peter

Parker

Active

5

Jane

Doe

Dismissed

 

 

Then I have a second FS Layer (FS_Layer_IllnessRate), which is my Survey123 Connect Layer that calculates the rate of ill employees. The RRHH colleagues use this form to enter the number of ill employees once every week.

To calculate the % of ill employees I need to have the exact number of employees (in this example 5), but this number has to take into account only those employees WEHERE the contact is still “Active”, in my example only 3.

I need the pulldata("@layer") function to bring me the value of 3 active employees….

I am not sure how to do this ☹

pulldata("@layer", "getValue", "attributes.totalcount", concat(${url_query}, '?outStatistics=[{"statisticType": "count","onStatisticField": "objectId","outStatisticFieldName": "totalcount"}]'), concat("Contract ='",${Contract},"'"))

 

THANK YOU!!!

OlivierDemars1
Occasional Contributor

Hi @DoZ,

I have tested 3 types of filter and it all works for me in

pulldata("@layer", "getValue", "attributes.totalcount", concat(${url_query}, '?outStatistics=[{"statisticType": "count","onStatisticField": "objectId","outStatisticFieldName": "totalcount"}]'), FILTER)

- "contract = 'Active'"
- concat("contract = 'Active'")
- concat("contract = '",${status},"'") 

Check the actual field name, the label may be Contract but the field name may be contract.
Check the choice name, the label may be Active but the choice name may be active.

Best regards,

Olivier

DoZ
by
Regular Contributor

Dear @OlivierDemars1 

first of all thanks, for your prompt response, you were very kind.

I tried your first 2 answers and unfortunally the Survey doesn’t ´pull any results. it doesn't give me any error though, but the field remains empty. 

Your third answer I am not dure what field I should put instead of your ${status}. But please let me know if I got the pulldata("@layer") function correctly: I got LAYER1 which is the database of all employees and from which I need to know the number of active ones. Then I got LAVER2, which is my survey123 Layer in which I want the count of employees to be pulled in, in order for me to calculate the illness rate…

DoZ_0-1724058444439.png

When I open the survey in the Web I got this message:

DoZ_0-1724154956434.png

 

Any ideas what am I missing out??

Thank you soo much!!