Skip to main content
1-Visitor
April 23, 2021
Solved

inserting textfield and label values to datatable(postgres)

  • April 23, 2021
  • 1 reply
  • 5239 views

Hi everyone,

I need to insert value of numerous textfield entered by user on runtime and value of label (given at time of mashup creation) into postgres database.

I have earlier created code and was successful in transferring data from excel to postgres database, but now as data is not present at one location, I am clueless in achieving it.

Can someone suggest please. I am attaching sample mashup showing labels and textfields.

Thanks in advance.

Best answer by mnarang

Seems like you already have the service and schema in place, to take text field data into service as an input just click on the text field on the mashup design area and click on the icon displayed on the top left of the widget. It will give you an option to select the inserted text value. Drag this text to the service input in the data panel on the right side of the design area(see below screenshot). Labels do not contain any value(generally the label value will not change), so ideally Label text will be fixed, you can insert the label value directly in the service code.

 

mnarang_0-1619418189229.png

 

1 reply

5-Regular Member
April 23, 2021

You can have a sql type service on the DB thing(which connects to your required DB). create a table and schema in the DB, according to your inputs from the mashup text field. Take required inputs in the service for ex textfield1,textfield2..etc. Map each text field value to the input in the service on the mashup. On the final submit button click call this service which will basically take all the input values from text field and insert these values to DB using the SQL command service.

1-Visitor
April 23, 2021

Hi @mnarang,

Thanks for your response. I have already created dbthing, table and schema. i am able to insert data into table directly by giving input into service having sql command.

Only issue/challenge is that I don't know how to map values Map each text field value & label value to the input in the service on the mashup. Kindly suggest or share an example.

1-Visitor
April 23, 2021

This is the code i have written where I am taking datashapeforupload in input:

 

var tableLength = datashapeforupload.rows.length;

if(tableLength!=0) {

for (var x = 0; x < tableLength; x++)
{
var_sheetno = datashapeforupload.rows[x].sheetno;
var_lotno = datashapeforupload.rows[x].lotno;
var_bombtype = datashapeforupload.rows[x].bombtype;
var_bombsno = datashapeforupload.rows[x].bombsno;
var_opt = datashapeforupload.rows[x].opt;
var_date = datashapeforupload.rows[x].date;
var_description = datashapeforupload.rows[x].description;
var_instrument = datashapeforupload.rows[x].instrument;
var_tresult = datashapeforupload.rows[x].tresult;
var_remarks = datashapeforupload.rows[x].remarks;


// result: INFOTABLE dataShape: ""
var result = Things["dbgraphs"].plantconfigpush({
sheetno: var_sheetno ,
lotno: var_lotno,
bombtype: var_bombtype ,
bombsno: var_bombsno,
opt: var_opt,
date :var_date,
description:var_description,
instrument: var_instrument,
tresult:var_tresult,
remarks: var_remarks
});

 

 

plantconfigpush service in dbgraphs thing then inserts data into db.