Extending Survey123 smart forms with custom JS functions

60324
93
08-06-2020 06:22 PM
IsmaelChivite
Esri Notable Contributor
10 93 60.3K

[Last Update: July 6, 2023]

 

Custom JavaScript functions complement XLSForm expression syntax, giving you flexibility to build more complex calculations, data validation rules and constraints.

This blog provides guidance to get you started with custom JavaScript functions. For completeness, check the pulldata JavaScript help topic. It assumes familiarity with Survey123 Connect, XLSForm syntax and JavaScript.

 

Getting started

 

Let's start with a simple scenario. In Survey123 Connect, create a new survey and add a couple of questions as shown below. Our goal is to create a custom JavaScript function to calculate the greeting question.

IsmaelChivite_1-1688863048745.png

Using regular XLSForm syntax, we could calculate the greeting as follows:

concat("Hello ", ${myname})

This already teaches us something: custom JavaScript functions are not always the best approach. If you can solve something easily using pure XLSForm functions, do not use a custom JavaScript function. In our case, we will use this example only because it helps us focus on the basics of setting up a custom JavaScript function.

To invoke a JavaScript function from XLSForm, we use the puldata() function. For example:

pulldata("@javascript","myFunctions.js","HelloMe",${myname})

The parameters for the pulldata() function are as follows. First we pass "@javascript" to indicate that we want to execute a JS function. Then, we pass the name of the JavaScript file that contains our function, which in this example is "myFunctions.js". The next parameter is the name of the function within the file that we want to call: "HelloMe". Lastly, we pass as many parameters as the JS function takes. In our case, we will just pass the name of the survey taker, which is contained in the ${myname} question. If the JS function takes more parameters, we would add them in our pulldata() function call as more parameters separated by commas.

IsmaelChivite_3-1688863301021.png

For the pulldata() function above to work, we need to create a "myFunctions.js" file with its corresponding "HelloMe" JavaScript function. In fact, as you refresh your survey preview in Connect you will get a File not found: myFunctions.js error. That is totally expected.

Custom JavaScript files are stored in the survey directory, within a folder called scripts. In the old days, you had to create the folder manually and add your JavaScript files to it. Starting with version 3.12, you will see a Scripts tab at the bottom of Survey123 Connect that will help you with the process as shown in the next animation:

2023-07-10 Custom JS Survey123.gif

 

Next, you can add your own JavaScript function (or functions) to the file. For example:

function HelloMe(whosthere) {

    return "Hello, " + whosthere;
}

Do not forget to click the Save button on the bar in the right side!

You can test and even copy the pulldata() function to invoke your function right from the Scripts tab.

 

2023-07-10 Custom JS Survey123 v2.gif

 

Once the file is saved in the scripts folder, make sure your pulldata() function in the XLSForm is invoking the JavaScript function correctly, and give it a try.

Naturally, you will find a few bumps before you get your JavaScript functions working. Here are some of the most common errors that you will encounter:

File not found: myFunctions.jsYour pulldata() function is trying to load a JavaScript file that cannot be found in the scripts folder
Error in myFunctions.js : 6:16 Expected token `;'Syntax error in line 6 of your function.
@javascript error:TypeError: Property 'HelloMe' of object [object Object] is not a function in myFunctions.js:HelloMeYour pulldata() function is trying to invoke a function that cannot be found in the JS file you specified.

 

When writing your own custom JavaScript functions for execution within your Survey123 form, remember that your code will not run within the context of a web browser; you are limited to JavaScript ES6. You can't use DOM objects, or frameworks like JQuery, Ember, Angular etc. You can't access local files or make asynchronous calls either. Despite all these limitations, there is still quite a bit you can do!

 

Once you have your JavaScript function working, you can publish your survey. Custom JS functions are supported in online surveys as well as in the Survey123 field app. However, keep in mind that JS functions will not execute unless a user is signed in to the Survey123 field app or web app.

 

Parsing complex data structures

 

A common use for custom JavaScript functions is to parse complex structures, so you can extract key information from them to calculate questions in your form. From an XLSForm perspective, the syntax in your Survey123 form is really not much different from what you already learned in the Getting started section. The real complexity is handled inside the JavaScript function itself.

As an example, let's take the contents of an AAMVA PDF417 barcode. This type of barcode is used in driver licenses and encodes information such as name, birthday and many other things. Since the Survey123 field app has built-in barcode capabilities, you can scan such a barcode. The contents would look something like this:

AAMVA

This JavaScript function formats the AAMVA string from a driver's license into a JSON object, which can then easily be used within XLSForm to extract the specific information you are looking for:

 

function DL2JSON (data) {
    var m = data.match(/^@\n\u001e\r(A....)(\d{6})(\d{2})(\d{2})(\d{2})/);
    if (!m) {
        return null;
    }

 

    var obj = {
        header: {
            IIN: m[2],
            AAMVAVersion: parseInt(m[3]),
            jurisdictionVersion: parseInt(m[4]),
            numberOfEntries: parseInt(m[5])
        }
    };

 

    for (var i = 0; i < obj.header.numberOfEntries; i++) {
        var offset = 21 + i * 10;
        m = data.substring(offset, offset + 10).match(/(.{2})(\d{4})(\d{4})/);
        var subfileType = m[1];
        var offset = parseInt(m[2]);
        var length = parseInt(m[3]);
        if (i === 0) {
          obj.files = [ subfileType ];
        } else {
          obj.files.push(subfileType);
        }
        obj[subfileType] = data.substring(offset + 2, offset + length - 1).split("\n").reduce(function (p, c) {
            p[c.substring(0,3)] = c.substring(3);
            return p;
        }, { } );
    }

 

    if (obj.DL) {
        ["DBA", "DBB", "DBD", "DDB", "DDC", "DDH", "DDI", "DDJ"].forEach(function (k) {
            if (!obj.DL) return;
            m = obj.DL.match(/(\d{2})(\d{2})(\d{4})/);
            if (!m) return;
            obj.DL = (new Date(m[3] + "-" + m[1] + "-" + m[2])).getTime();
        } );
    }

 

    return JSON.stringify(obj);
}

This is what the actual XLSForm would look like. Note that the myjson question uses pulldata("@javascript") to first convert the output from the barcode question into a JSON string. Then the pulldata("@json") function is used to extract specific attributes from the string.

IsmaelChivite_5-1688864012394.png

Tip: Set the value of bind::esri:fieldType to null in the myjson question if you do not want to store the aamva raw string in your feature layer, but still be able to process it within your form logic.

Working with repeats

 

Custom JavaScript functions are ideal for processing data in repeats. As of version 3.18, using repeats with custom JavaScript functions is limited to the Survey123 field app. You can retrieve all values for a question within a repeat, or retrieve all records within a repeat.

 

Passing a question within a repeat to pulldata("@javascript")

 

When you pass a question within a repeat to pulldata("@javascript"), the JavaScript function receives an array of values for the specified question. For example, lets say we want to display a warning message if the user has introduced duplicate values in a question within a repeat. In this case, we want to create a JavaScript function that takes an array and returns true if duplicate values are found. Something like this:

function HasDups (myArray)
{
 return new Set(myArray).size !== myArray.length;
}

Now all we need to do is to call the function and pass the question within the repeat to it:

IsmaelChivite_7-1688865800185.png

 

When passing a question within a repeat to pulldata("@javascript"), it is important to keep the pulldata("@javascript") outside the repeat. In the example above, note that I first keep the result of the duplicates check outside the repeat, and then I use that value in the constraint expression for the fruit question.

 

Passing a repeat to pulldata("@javascript")

 

You can also pass an entire repeat to pulldata("@javascript"). In this case, your JavaScript function will receive all records within the repeat as an array. Each item in the array is in turn another array representing the values for that record.

In our fruits example above, let's pretend we want to calculate how many bananas have been entered. If we pass the entire fruits repeat, we can use a JavaScript function to loop through every record. If the fruit in the record is banana, then we get the quantity value and add it to our total.

function TotalBananas (fruitsrepeat)
{
 var totalBananas = 0;
 var i;
 for (i = 0; i < fruitsrepeat.length; i++) {
  if (fruitsrepeat[i].fruit=='banana') {
     totalBananas = totalBananas + fruitsrepeat[i].quantity;
  } }
 return totalBananas;
}

Here is the XLSForm:

IsmaelChivite_8-1688866356162.png

 

Working with web services

 

Using a custom JavaScript function, you can invoke a web service. Here is an example that takes a VIN number and returns information for that vehicle.

 

// Query the NHTSA to return information about a vehicle based on it's VIN

// Refer to https://vpic.nhtsa.dot.gov/api/ for more information

function decodeVIN (VIN){

  // Output value. Initially set to an empty string (XLSForm null)

  let outValue = "";

  // Check the length to make sure a full VIN is provided

  if (VIN.length<11){

    return outValue;

  }

  // Add the VIN to the decode VIN API request

  let url = `https://vpic.nhtsa.dot.gov/api/vehicles/decodevinvalues/${VIN}?format=json`;

  // 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();

  if (xhr.status !== 200) {

    } else {

    outValue = xhr.responseText;

  }

return outValue;

}

More Samples

 

Survey123 Connect includes a new XLSForm sample illustrating how to use custom JavaScript functions in multiple scenarios. As you get hands-on, this is a sample worth checking.

 

IsmaelChivite_9-1688867009779.png

 

Limitations

 

  • Document Object Model (DOM) is not supported.
  • Frameworks such as JQuery, Ember, and Angular are not supported.
  • You cannot access local files.
  • Asynchronous calls are not supported.
  • JavaScript functions are only supported in forms completed by users in the same organization as the form author.
  • JavaScript functions are not supported for public surveys.
  • A pulldata("@javascript") function cannot be called inside a pulldata("@json") function on the Survey123 web app.
  • Passing repeats or questions within a repeat to a JS function only works in Connect and the mobile app
93 Comments
MichaelRubley
New Contributor

Custom JavaScript functions are not supported in public surveys. A user must be signed in before the JS function executes.

Are there any plans to allow this functionality in the future? It is great that this can be used with a login, but we have several public facing applications that need this to work.

CollinHorace
New Contributor II

Is there a way to get intersection information using geotrace for a polygon similar to what you accomplished in the Working with Web Service section with the geopoint?

JamesTedrick
Esri Esteemed Contributor

Hi Collin, 

Can you add a couple of details to the scenario you are describing?  The user is collecting the geotrace, correct?  Where is/are the polygon(s) that would need to be spatially compared?  If a feature service, you can use the same type of spatial intersection queries as you wold with a feature service.

AleksandraZietara
New Contributor III

Hello,

The same question as Michael had - are there any plans to implement support for public surveys? We have a scenario where customer wants to use public survey on the website and based on input from user, he wants to populate couple of other fields from web service. Pulldata() witch csv file is not an option as database is updated dynamically. Is there any another approach we could use?

Fco_JavierRomero
New Contributor III

Hello, we need to include a QR code in a survey. Would it be possible to generate a QR code with js and include it as an attachment in an image type question?

Thanks

NeilTimmerman1
New Contributor

Is there any way to query the previously submitted survey records? 

IsmaelChivite
Esri Notable Contributor

Hi Neil. The Working with web services section in the blog above describes how you can query an existing feature layer. The JavaScript XLSForm sample (see below) also contains a Working with a Feature Service section showing how you can query existing features. Both examples show the basic pattern. To learn more about the Feature Service API, check: Feature Service—ArcGIS REST API | ArcGIS for Developers 

NeilTimmerman1
New Contributor

The scenario we are trying to resolve is, an inspector is walking through a field in a remote area without cell service. They collected several samples, entering each one as a new survey record into Survey123. We want to write some custom logic that uses the past few records. We cannot make a web service call because the inspector does not have cellular service and also because the inspection records have not yet been synchronized to the server. Is there any API for getting at the data that was collected on the device in order to build some custom validation logic with JavaScript? 

IsmaelChivite
Esri Notable Contributor

Hi Neil. Not currently possible. That is, a custom JS Function can only access data from the current survey record. It is not possible for a JS Function to work with other records in your device.

juan_luisGarcia_González
New Contributor II

Hi, I've a similar question I think. Can I generate a Qr code with JavaScript and insert it into the report?

juan_luisGarcia_González
New Contributor II

Hi, Ismael Chivitewhat do you think about what  Fco Javier Romero proposes? Is it possible to include as an attachment a QR code generated with Javascript in survey123? . 

I have tried two options, write all the code necessary to generate the QR code in the js script, and use the Google Charts API with de url : "https://chart.googleapis.com/chart?" . 

In both cases the JS code does not give me an error, but I do not know if it is possible to use an image question to incorporate it as an attachment:

Thanks

IsmaelChivite
Esri Notable Contributor

Hi Juan Luis García González‌  Fco Javier Romero‌  I would not know how to dynamically generate and display a QR code within a survey.  You could definitively use a webhook to generate the QR code and email it or SMS it to the respondent, but including the QR code itself within the survey as it gets completed is not something I would know how to do. If you are using online surveys, another approach is to use the https://community.esri.com/groups/survey123/blog/2020/03/05/introducing-the-survey123-web-app-javasc... . With this API, you can build a custom web app that listens to an emebedded web form, and use data from the webform to create and display the QR code within the web app. 

juan_luisGarcia_González
New Contributor II

Thanks Ismael,  I will keep looking for other options for my workflow.

Regards

AndrewTuleya3
New Contributor

Hello, I am trying to accomplish the following using AGOL. Please let me know if anyone has any advice. 

 

We have a public form for residents to schedule inspections conducted by our municipality. We want public users to be able to self schedule. 

 

Workflow:    

   Person A: Opens public form, selects Monday August 28th at 8:00 AM, Submits form

   Person B: Opens public form, (Cannot Select same day as person A), Selects available date, Submits form.

CristhieDiaz
New Contributor II

Hi! I have a requirement to integrate to an ERP,
and to be able to discount inventory,
in survey123 I have a list of products and when
I select a product it automatically connects to
the erp through the API and shows me how much
inventory there is of the product,
with this functionality it is this possible?

by Anonymous User
Not applicable

Hi Andrew,

I don't think JavaScript functions will be applicable here for a public survey

Custom JavaScript functions are not supported in public surveys. A user must be signed in before the JS function executes.

Cheers,

Chris

yaserkhouja
New Contributor II

I tired the JS with License ID Barcode, but the calculated value is not working. Also, is there a way to store the scan record with more than 256 characters (It shows an error if I increase the length)?

JamesTedrick
Esri Esteemed Contributor

Hi Yaser,

Could you provide details about the barcode you are attempting to read?  What format is it?  

With regard to increasing the number of characters, yes you should do that - you can set it with the bind::esri:fieldLength column

ElliottPlack__SHA_
New Contributor III

Ismael Chivite‌ very cool to see this advanced functionality in S123. One use case I am evaluating it for is preventing duplicate submittals based on a unique key in a parameter URL. This use case would mimic how, say, a Survey Monkey form can only be taken one time. I'd have to pull the previous data and check if a key exists already, then use some kind of constraint to prevent another submittal. Kind of out of box thinking here, but maybe it would work.

Please tell me if you think this is possible:

Background

  • Public-facing web Survey123 form

Typical Survey123 steps

  • User clicks a Survey123 URL with parameters in an email that prepopulates a read-only text field in the form (effectively a foreign key)
  • User fills out the web form. Prepopulated key resides in collapsed group.
  • Submit, done.

Duplication check steps

  • User clicks the URL in the email again.
  • Survey123 pulldata checks submittal FS to see if the prepopulated key is already in the service
  • If the key is there, it prevents submitting the form my making an impossible constraint on a read only field in the survey, or perhaps hiding some group that contains the responses.
AdministradorData_Gis
New Contributor II

Hi everyone,
Ismael Chivite Very excited about this update.


I have a scenario where in each entered record, a customer name is selected from a list, and in this way, through a pulldata, other hidden fields such as email, address, telephone number and others are completed.
However, when there is a new customer, which is common, it is necessary for the IT department to update the survey options and the pulldata list, and that is not always immediate. So my question is, Is it possible through javascript, that a function consults a feature service in arcgis that is kept updated with the client data? It would be great, since then, I could extract the name from there and all the other customer data.

Thanks,

Jeffry J.

IsmaelChivite
Esri Notable Contributor

Hi Administrador Data Gis‌ 

The "working with web services" section in the blog above describes how you can query a feature service to populate questions in your form. This should help replace your pulldata lookups against the local CSV file.

Now, the larger problem in your case, if I understand correctly, is that you want to dynamically populate a list with the output of a feature layer query. This is something that it is still in our backlog. Please open a Tech Support case so your customer number is attached to ENH-000119959 Add capability to populate a survey's choice list from a dynamic location, such as another feature layer or a database table   I cannot anticipate a date for resolution of this ENH but it is definitively something we would love to have our hands on soon.

IsmaelChivite
Esri Notable Contributor

Hi Elliott Plack (SHA)‌   The logic you describe above makes sense, but JS functions can only be used with private surveys (they do not run on public surveys). 

yaserkhouja
New Contributor II

I am trying to read the driver's license barcode, PDF417 code.

DanielStoelb
Occasional Contributor III

I just created an idea for public surveys to have this functionality. You can check it out here: https://community.esri.com/ideas/19272 

ScottLehto3
Occasional Contributor

I like what i see. I am going to take review.

 

Quick question: I am writing apps and sharing them with many organizations. Can i publish the customized Survey123 program to my organization and share it with ArcGIS Online Groups? Will they be able to access the javascript from pulldata() method? 

      If its not possible, how would you recommend doing it?

KatieHansen_NIFCAdmin
New Contributor III

Hi @JamesTedrick ,

This is in addition to a question a user had above, back in September.

I am looking to alter the sample Working with a Feature Service JavaScript function but am stuck. I would like to use a geoshape in my survey (rather than the geopoint that is in the sample) to populate a field based on its intersection with a hosted feature service (polygon). 
 
This process is the same as the example but using a geoshape does not work with the current JS script. Has anyone updated the JS code and been successful at this?
 
Thank you very much for any insight you can offer.
ScottLehto3
Occasional Contributor

In all the examples, i see one value being returned or altered when another value is altered

How would i change multiple values based on one value being altered? 

Is this outside the scope of Survey123?

DataOfficer
Occasional Contributor III

As I understand it custom javascript functions are limited to users within your organisation. How does this work across ArcGIS community users, as we have our organisational users in addition to community users (which are treated as a separate organisation?)? Will community users not be able to use these functions in the form?

Thanks.

ScottLehto1
New Contributor II

Data Officer, my thoughts exactly.

 

I write code for lots of orgs. I can’t customize much for them.

Ming
by
Occasional Contributor

Thank you @IsmaelChivite for the post, we have used JavaScript to query and update online feature services with user input data in Survey123 form.

For offline case, is it possible to use JavaScript to query and update the layer in the downloaded offline map, then can sync back to server when it's online?

Known that JavaScript has limitation "You cannot access local files." listed at https://doc.arcgis.com/en/survey123/desktop/create-surveys/pulldatajavascript.htm

But still want to double confirm from you most well known guru.

wOwen
by
New Contributor II

Hello @IsmaelChivite ,

UPDATE: 

Is the Total Bananas example presented in the original post working for others?

Is this blog spot being monitored anymore by @IsmaelChivite ?

 

BEGIN ORIGINAL COMMENT:

I am having trouble implementing the arrayname.fieldname syntax shown above. Finally, I copied both the xlsx and js code directly from the totalBananas example above and it does not run successfully: totalBananas remains 0. Is this a limitation of Connect v3.11.123?

I added a text flag to ensure that the script is actually running. After I enter one record into the repeat, e.g. 'Banana' and quantity 3, my flag changes to True but the totalBananas remains 0. I've copied and pasted the value "banana" from my script to my choice list value to ensure no typos. Here's the (unformatted) code:

function getRepeats (fruits)
{
var totalBananas = 0;
var i;
var txt = 'False';
if (Array.isArray(fruits) && fruits.length>1){
txt = "True";
}
for (i = 0; i < fruits.length; i++) {
if (fruits.fruit=='banana') {
totalBananas = totalBananas + fruits.quantity;
}
}
txt = txt + ", " + totalBananas.toString();
return txt;
}

Example Result: True, 0

 

Thank you!

 

RobertAnderson3
MVP Regular Contributor

Now here's a silly question, definitely coming from me being a novice with JavaScript.

If you accidentally get it stuck in an infinite loop while trying to test your script in the in Survey123 editor, how do you escape it? Is there a way to do this other than just having to completely exit Survey123 Connect?

KimberlyMcCallum
New Contributor III

@IsmaelChivite Great post and I love this functionality but was wondering if you could comment on whether the web app is yet able to support this for working with repeats now that we are at version 3.13? I have run into a bug where calculations don't work correctly in repeats when a survey is opened in edit mode... I was hoping to find a workaround by writing some custom JS functions but am sad to learn that at version 3.10, this wasn't supported for repeats. Any news? 

EricFord3
New Contributor

I am running into the same issue with the Total Bananas example as noted above by @wOwen using version 3.12.232.  Wondering if @IsmaelChivite has any updates or suggestions to get it to work?  

DataOfficer
Occasional Contributor III

@EricFord3 @wOwen it doesn't work for me either.

SHorman_
New Contributor II

@IsmaelChivite just an FYI the label PLACENAME under zip codes has the M and N reversed showing PLACEMANE

IsmaelChivite
Esri Notable Contributor

Sorry for the belated response:

@SHorman_  Good catch. Fixed PLACENAME. thanks!

@DataOfficer  @EricFord3  @wOwen : I went bananas with the bananas example. It is fixed now. When you create your fruits list, make sure the values in the name column are lowercase.

@Ming If your JS function makes calls to an external web service, it will not work while offline. Not much we can do about that.

@DataOfficer  and Scott: Due to security considerations, custom JS functions are disabled on public surveys and whenever the logged-in user is from another org. This also affects community users

DataOfficer
Occasional Contributor III

Hi @IsmaelChivite ,
I've just tested your updated bananas script but it's still not working for me.

My setup is as follows:

Script (myFunctions.js)

 

function totalBananas (fruitsrepeat)
{
 var totalBananas = 0;
 var i;
 for (i = 0; i < fruitsrepeat[i].length; i++) {
  if (fruitsrepeat[i].fruit=='banana') {
     totalBananas = totalBananas + fruitsrepeat[i].quantity;
  } }
 return totalBananas;
}

 


XLSForm - survey

typenamelabelcalculation
begin repeatfruitsFruits 
select_one fruitnamefruitFruit 
integerquantityQuantity 
end repeat   
integerTotalBananasTotal Bananaspulldata("@javascript","myFunctions.js","totalBananas",${fruits})

 

XLSForm - choices

list_namenamelabel
fruitnamebananabanana
fruitnameappleapple

 

I have also tried renaming the repeat 'fruits' to 'fruitsrepeat' but the number of bananas is still not calculated.

IsmaelChivite
Esri Notable Contributor

@DataOfficerRemove  [i] from line 5 so it looks like this

for (i = 0; i < fruitsrepeat.length; i++) {

 

DataOfficer
Occasional Contributor III

Thanks @IsmaelChivite. That works

ChrisRoberts2
Occasional Contributor III

Is it possible to create a js function to calculate the centroid (X,Y)of the polygon captured from a geoshape question.

Thanks

Chris

Amanda__Huber
MVP Regular Contributor

@IsmaelChivite , 

Are JS functions supported for Select_One question types (where the JS function is pulling a list from an API)?

Thanks!

SeanRedar
New Contributor III

Hi All, 

I created a form in Connect with some simple JavaScript functions.  Users select a project and the project's location (point) is calculated from JavaScript functions.  Everything works fine on the Windows Survey123 app but on the web form it appears the point calculation fails as each point ends up a 0,0.  The other JavaScript functions that control question relevancy seem to work fine on the web form.  Is there something I am missing here?

This is location calculation (yeah, I could do one js function for both x and y but meh)

pulldata("@javascript","functions.js","project_y",${project}) + " " + pulldata("@javascript","functions.js","project_x",${project}) 

 

Ming
by
Occasional Contributor

For online scenario, with Survey123 web app and Node.js on server, no feature service, no web service, no webhook, is it possible to run following custom JS function and insert Survey result directly into database like MySQL?

var mysql = require('mysql');

var con = mysql.createConnection({
  host: "localhost",
  user: "yourusername",
  password: "yourpassword",
  database: "mydb"
});

con.connect(function(err) {
  if (err) throw err;
  console.log("Connected!");
  var sql = "INSERT INTO customers (name, address) VALUES ('Company Inc', 'Highway 37')";
  con.query(sql, function (err, result) {
    if (err) throw err;
    console.log("1 record inserted");
  });
});

SébastienFancelli
New Contributor

hello @IsmaelChivite ,

I want to use the javascript extension to send an image to an external API for analysis. when I try to send the image as a parameter with the pulldata (ex: pulldata ("@ javascript", "myFunctions.js" ", $ {image}), I get the name of the image on the javascript side.

Do you have a solution for me to transmit the complete image on the javascript side?

Thank you

ATTEC_SLUConsultores
New Contributor II

Buenas tardes @IsmaelChivite , he asistido a tu curso sobre Survey123 celebrado hace unos 6 meses. Felicitaciones por el curso. He aprendido mucho.

Estoy creando un formulario inteligente con histórico de inspecciones de activos. He practicado con tus ejercicios y funcionaban. Posteriormente adapté el ejercicio a mis necesidades y funcionaba. Pero finalmente, he necesitado hacer otro histórico de activos  usando el esquema del ejercicio, pero esta vez no ha funcionado. Me aparece "Las funciones de JavaScript están deshabilitadas":

ATTEC_SLUConsultores_0-1635426423175.png

 

He vuelto a probar con tu ejercicio y ya no no funcionaba. 

¿Serías tan amable tú, o alguna persona de la comunidad, de indicarme donde está el fallo?

Muchas gracias.

juan_luisGarcia_González
New Contributor II

Hola!

Has probado con otro dispositivo? Tuvimos el mismo problema y pienso que se trata de un tema de configuración del dispositivo móvil.

Saludos.

ATTEC_SLUConsultores
New Contributor II

Precisamente eso voy a hacer esta mañana. Se me ha ocurrido en una idea feliz esta noche. Esta es la aplicación survey123 para PC, e hice un cambio de versión de excel hace algunos días. Así que lo voy a instalar en otro PC de la oficina para ver si funciona.

Muchas gracias por el aporte.

ATTEC_SLUConsultores
New Contributor II

Parece que es un tema de permisos. Cuando me logueo como miembro de la organización propietaria del formulario, sí aparece el scripts. Sin embargo, cuando me logueo como miembro de otra organización perteneciente al grupo donde se comparte ese formulario, es cuando falla.

juan_luisGarcia_González
New Contributor II

Hola.

Efectivamente, es una limitación conocida. Para que funcione, el miembro debe pertenecer a tu organización.

Las funciones JavaScript solo son compatibles en los formularios completados por usuarios de la misma organización que el autor del formulario.

Saludos.