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

Hi Team,

I have been trying to add a record in one of the lookup. Upon saving I get a below error.

 

From UI, Debugged to find the below, i.e. an object is missing in the config.
But it is available in DB.

It is inferred that object is deleted in Configuration but available in DB.

Note: This error persists across the application, when I tried to save record in any section this error pop-up.

 

ViewModule.aspx

"SBLChequeBook":{

      "imageId":"026742d9-390c-4778-bc46-9fa85c42677a",

      "moduleId":"f07b0621-39c1-4269-a3e5-dd013dca1e82",

      "moduleCaption":"Cheque Book",

      "entitySchemaName":"SBLChequeBook",

      "entitySchemaUId":"f3edef5e-3b47-4fd7-89bd-34c3681a4e57",

      "sectionModule":"SectionModuleV2",

      "cardModule":"CardModuleV2",

      "hide":"true"

   },

kindly guide me to overcome this!

Best Regards,
BHoobalan P.

Like 0

Like

2 comments

Hi Bhoobalan,

 

Please delete mentioning of the deleted object from the SysModule table:

 

DELETE SysModule WHERE SysModuleEntityId = 'f07b0621-39c1-4269-a3e5-dd013dca1e82'
OR Id = 'f07b0621-39c1-4269-a3e5-dd013dca1e82'

 

and relogin to the application after that. This should completely remove all the mentions about the deleted object from the system.

 

Best regards,

Oscar

Oscar Dylan,

Thanks much!

Show all comments

Hello,

I want to add custom button to add new record of case. I added custom button to contact edit page, made onClick event handler and using this function to open add record page of case:
 

_contactObject.openCardInChain({
	"schemaName": "CasePage",
	"operation": "add",
	"defaultValues": [{
		"name": "Contact",
		"value": _contactObject.get("Id"),
		"displayValue": _contactObject.get("Name")
	}]});

It works only when I am on Contact edit page, reload page and clicked my button. or if I entered directly on Contact edit page using url.

 

But if I entered from Contact list page, this function is not working. It shows infinite loader and never stops. If I reload page while loader, it loads add record page of case, exactly what I want.

 

Unfortunately, it doesn't shows any error in console. I tried to debug this function and trace how it works, but at the and, it fires event and I can't understand why its handler not handling it.

 

We are using Bpm Online 7.14.1.935

Like 0

Like

3 comments

Dear Luka,

 

Looks like the issue is related to combined mode Please, try this approach of adding logic to the section and to the page - https://academy.creatio.com/documents/technic-sdk/7-16/how-add-button-edit-page-combined-mode.

 

Best regards,
Angela

Angela Reyes,

we had that problem, but now we added button on ContactPage, so its button and onClick handler works fine. also that function openCardInChain is executed, but there is no result. 

Resolved:

I added property in config param which is passing to openCardInChain function. param is moduleId.

Show all comments