Hello I would like to know how to insert data into a database, my database is called "oapedidos",
I have a constant created to perform the queries,
and a CDT.
I have an interface
in which I simply write the name of an order and its status, and a button to register that data "ALTA". I do not know how it should be done, I have seen in the forum that it is with a! WriteToDataStoreEntity (dataStoreEntity: cons! DATA_STORE_ENTITY,valueToStore: ri! rule_input) but I don't know how it works,
Do I have to create a rule input in the interface whose type is CDT??
the code of my interface is:
{ a!sectionLayout( label: "Alta pedido", contents: { a!columnsLayout( columns: { a!columnLayout( contents: { a!textField( label: "Referencia del pedido", labelPosition: "ABOVE", saveInto: ri!oapedidos.nombrepedido, refreshAfter: "UNFOCUS", validations: {} ) } ), a!columnLayout( contents: { a!textField( label: "Estado del pedido", labelPosition: "ABOVE", saveInto: ri!oapedidos.estadopedido, refreshAfter: "UNFOCUS", validations: {} ) } ) } ) } ), a!buttonArrayLayout( buttons: { a!buttonWidget( label: "Alta", saveInto: a!writeToDataStoreEntity( dataStoreEntity: cons!GP_Pedido_Entity, valueToStore: ri!oapedidos), style: "NORMAL" ) }, align: "START" ) }
By the way how can I make refreshAfter: "UNFOCUS" be when I press the "ALTA" button?
forgive my ignorance I'm still learning,
greetings and thanks
Discussion posts and replies are publicly visible
Your code looks pretty close to correct currently - what happens when you press "Alta"?
Secondarily: i'm not sure what you're asking about "UNFOCUS" - can you describe with a bit more detail the behavior you're hoping to achieve?
Thanks for responding, now I see that the program works, I have been able to upload the data to the database but the problem is that when I write for example "A1021" in "Referencia del pedido" and "pending", the status of the order, the text that I have written is deleted, What I want is that the text remains until I press the "ALTA" button, then the text of those text boxes is deleted and the insertion is made to the database.
Apart from that I cannot save this interface as a report because it says this."This interface may not be saved as a report because it has one or more inputs".
There appears on the right the inserted data that will be inserted into the database without having pressed the button. I would like them not to be erased before pressing the button
In your interface, no database write would happen until you press the "ALTA" button. I'm a little confused about what you seem to be experiencing instead.
The error message is correct - only interfaces with no Rule Inputs can be saved as a Report. Interfaces with Rule Inputs need to be called from User Input Tasks within a process, and/or as sub interfaces from a parent interface.
Yes, until I press the "ALTA" button, the data is not entered. The point is that when they lose focus while I am writing the data they are erased in the interface although if they are registered in rule inputs, it was to make it more logical that the data would remain and after clicking leave the text boxes empty, not before. Sorry if I don't explain myself correctly
Gonzalo Fernandez said:they are erased in the interface
Oh - this is just because the text fields don't have a "value" parameter. The value parameter is the only thing that will enable the field to show the information you just typed in - without it, the information you type will correctly get stored in the rule input or local variable referenced by "saveInto", but the value on the field itself will (seemingly) "erase" after entry. Nothing's really getting "erased" though, it's just that the field doesn't think it has any value to show.
Ahhh OK thank you very much!Your answer helped me a lot.