How can I add records in javascript?

Hi Community!

 

I can't find documentation related to the creation of records via javascript. I know I can use ESQ to query records, but is there also an API for create, update and delete?

 

Many thanks,

Robert

Like 0

Like

4 comments
Best reply

Hello Robert,

For inserting data in Javascript (InsertQuery):

https://customerfx.com/article/inserting-a-record-from-client-side-code…

For updating data in Javascript (UpdateQuery):

https://customerfx.com/article/updating-a-record-from-client-side-code-…

For deleting data in Javascript (DeleteQuery):

https://customerfx.com/article/deleting-records-from-client-side-code-u…

Ryan

Hi Robert,

 

The second possible way, if ESQ for some reasons doesn't work in your case, is to send XHR requests from the client code. An example of such request send from the client side can be found here, in your case the endpoint URL should be OData endpoint and the method to add the record to some section is similar to standard OData call from Postman.

 

Best regards,

Oscar

Hello Robert,

For inserting data in Javascript (InsertQuery):

https://customerfx.com/article/inserting-a-record-from-client-side-code…

For updating data in Javascript (UpdateQuery):

https://customerfx.com/article/updating-a-record-from-client-side-code-…

For deleting data in Javascript (DeleteQuery):

https://customerfx.com/article/deleting-records-from-client-side-code-u…

Ryan

Ryan Farley,

thanks for the links, very helpful!

 

However, I wonder if I (mis)understood the base concept here.

Dylan pointed out, that ESQ could be used for this...so is your solution what Dylan was referring to? I ask, because I thought "ESQ", which stands for EntitySchemaQuery, was only used for reading data?

In your linked code, the class used is called "Terrasoft.InsertQuery". So is this whole part of the SDK called ESQ?

 

Another question is if the permissions will be respected or not. In c#, there is the possibility to use either the Insert-class or the InsertToDB() method of the entity. AFAIK, the Insert-class will not take permissions into account or start business processes and will be executed directly against the DB. Is this what the "Terrasoft.InsertQuery"-class will execute on the server, or is it the InsertToDB() method from the entity?

 

Many thanks,

Robert

Hello Robert,

EntitySchemaQuery is only for queries/reading (technically, ESQ server side does return entity objects which can be used for updating as well). 

InsertQuery/UpdateQuery/DeleteQuery isn't technically part of EntitySchemaQuery, but are similar in purpose as they wrap calls to DataService and provide a simpler objects to use from client-side code. 

Since all of these are basically wrapper objects for using DataService, it does respect permissions. In fact, if you look at the network traffic when using Creatio, you'll find that when adding, editing, or deleting records in the Creatio client (for example, when you add an activity, edit an account, or delete something) it is issuing these same InsertQuery/UpdateQuery/DeleteQuery requests. When a bound edit page is saved, an InsertQuery or UpdateQuery is issued for the bound data on that page.

Ryan

Show all comments