Data privacy notice

 

When this content is loaded, usage information is transmitted to Vimeo and may be processed there.

 

             

Read data from CSV data source in form with JavaScript

Modified on Tue, 2 Apr at 1:12 PM

There are various ways to read data from a data source into the form. In addition to implementation via a calculation field, it is also possible to read in the data sources via Java Script.


We use the following data source as the basis for both examples:


Read data source via JavaScript

For this solution, a parameter with the URL is passed. A value (in the example, the ID of the person) is passed in this parameter and the corresponding line is returned.


Create the required elements in which the values of the data source will later be displayed. In this example, this is:

  • selAnrede
  • tfVorname
  • tfNachname
  • tfPLZ
  • tfOrt
  • personID (hidden)



The Script:

$.getJSON({
  url:XFC_METADATA.urls.datasource_csv,
  data:{
    name:"Personen",
    frid: XFC_METADATA.currentSessionFRID,
        jsonPath:"$.returnValue[ID == '"+$('[data-name="personID"]').val()+"']"
  },
  success:function(data){
        $('[data-name="selAnrede"]').val(data[0].Anrede);
        $('[data-name="tfNachname"]').val(data[0].Nachname);
        $('[data-name="tfVorname"]').val(data[0].Vorname);
        $('[data-name="tfPLZ"]').val(data[0].PLZ);
        $('[data-name="tfOrt"]').val(data[0].Ort);
  }
})


Replace "persons" with the name of your data source, "personID" with the name of its transfer parameter and the values in the "success:function ..." area with the names of their elements (e.g. $('[data-name="selAnrede"]')) and column headings of the data source (e.g. data[0]. Anrede).



If you now open the form and pass the transfer parameter "personID" with a corresponding value in the URL, the form is opened pre-filled.


https://formexchange.formcycle.eu/formcycle/demo/designer/2829?personID=5


(the 5 stands for the entry of the data source with the ID 5 (Max Mustermann))



Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article