Add await in Client Module function, To read Object Data and Load Page

Hello All, 

 

I have created code to load Custom Page. How i can add the await in Creatio Client Module function to read Object Data

 

Code Sample : 

define("UsrCustomFunction", [], async functio(){
                
       // API call Terrasoft.EntitySchemaQuery, to read the creatio table.
       var getProcessData = function(){

              var esq = Ext.create("Terrasoft.EntitySchemaQuery", {
                      rootSchemaName: "UsrGUMUProcessList"
              });

              esq.addColumn("Id");
              esq.addColumn("UsrName");


              return new Promise(function(resolve, reject) {
                     esq.getEntityCollection(function(response) {
                     if (response.success) {
                             resolve(response.collection);
                      } else {
                             reject(new Error("Failed to retrieve data: " + response.errorInfo.message));
                      }
               }, this);
             });

           }

 

             // [ Is it possible to add await or any other solution available for this? ]
             var processData = await getProcessData(); 
            
             //Process and return the Config based on the processData.
             return {
                 viewConfigDiff: /**SCHEMA_VIEW_CONFIG_DIFF*/
             };

});

 

 

Is this good solution to Create Custom Page in Creatio or any other solutions are available, then please assist me.

 

Regards,

Ajay K

 

Like 0

Like

1 comments

Hello Ajay,

Thank you for your question.

I suggest you to change your approach. You can override a default crt.HandleViewModelInitRequest  handler that is called before a page is fully rendered. There you might want to put your API call and depending on the result open a specific page. 

Here is a code snippet on how this might lookcode
In this case you also need to add @creatio-devkit/common dependency to schema dependenciescode

It is not recommended to dynamically modify entire schema configuration. Thus a better solution in your case could be binding your API call response to page element properties such as "visible" or "enabled".

Some helpful articles on the Academy: 
1. Generic handlers.
2. Open a Freedom UI page from a handler

Hope this helps and let me know if you have any questions left!
 

Show all comments