Hello,

 

I need to make a button visible based on a few conditions

1. If current user contact record has a lookup value of "Approver"

and

2. If account record of the current user contact has lookup value "Enterprise"

 

Since there are 2 tables to be queried, I understand I need to use callbacks and chaining. This does not seem to work well for me. I have also tried passing a callback function within a callback function, but still its not working well. Can someone please give an example of multiple callbacks?

 

Thanks

Like 1

Like

2 comments

There's no need for the multiple callbacks since this can be done in a single ESQ query. For example, the ESQ below retrieves both the current user's Type value as well as the current user's account Type value in the same call.

var esq = Ext.create("Terrasoft.EntitySchemaQuery", {
    rootSchemaName: "Contact"
});
 
esq.addColumn("Type");
esq.addColumn("Account.Type", "AccountType");
 
esq.getEntity(Terrasoft.SysValue.CURRENT_USER_CONTACT.value, function (result) {
    if (result.success) {
        var conType = result.entity.values.Type,
            accType = result.entity.values.AccountType;
 
        if ((conType && conType.displayValue == "Approver")
            && (accType && accType.displayValue == "Enterprise")) {
            // do something
        }
    }
}, this);

However, to nest a ESQ in a callback of another ESQ it would look like this: 

var esq = Ext.create("Terrasoft.EntitySchemaQuery", {
	rootSchemaName: "Contact"
});
 
esq.addColumn("Type");
esq.addColumn("Account");
 
esq.getEntity(Terrasoft.SysValue.CURRENT_USER_CONTACT.value, function (result) {
    if (result.success) {
        var conType = result.entity.values.Type,
            account = result.entity.values.Account;
        if (conType && conType.displayValue == "Approver") {
            var esq = Ext.create("Terrasoft.EntitySchemaQuery", {
                rootSchemaName: "Account"
            });
 
            esq.addColumn("Type");
 
            esq.getEntity(account.value, function (result) {
                if (result.success) {
                    var accType = result.entity.values.Type;
                    if (accType && accType.displayValue == "Enterprise") {
                        // do something
                    }
                }
            }, this);
        }
    }
}, this);

Ryan

Show all comments

Hi ,

 

I have this showInformation dialog box and using the response, triggering another set of validation and the whole logic is written inside the addCallBack() method used in multipleselect lookup in a detail.

 

What is observed is the response of this is thrown out of scope and the page goes in a neverending loop. While inspecting, found that the return statement is undefined as everything has been tried to exit soon after the condition, setting some boolean value as well as given the whole entity reload but it doesn't fix the issue and with the time out error the window is freezed after some time. 

 

What could be the reason for the page to navigate to evtMgr.Idelevent.listener?

Appreciate your valuable suggestion.

Like 0

Like

3 comments

Hi Anupama,

 

Please share the code of your showInformation dialog box and the description of the logic you want to achieve.

 

Best regards,

Oscar

Oscar Dylan,

 

Here is the link to the code and the affected areas are at the line#171 -  the return statement for the if at line #51 - 

if(remainningAccounts.length>0)

The else condition of this is not returning the expected outcome and it seems the scope is lost.

 

The functional expectation is to execute a set of sequential validations done on the selected accounts from a detail. The detail support multi-select lookup and the root entity schema is Account.

 

What is expected is: whenever any end user select multiple accounts - it has to go thru set of validations - once the first validation is complete - throw the validation message and continue with next validation and so on.

 

Say we select 10 accounts from the lookup config, 8 accounts satisfy the first validation and remainnning 2 is skipped from adding to detail object and the system should continue the same to remainning 8 validation. 

 

Issue is occurring when there are 0 accounts available for the another set of validation - it goes in a endless loop.

Anupama,

We recommend calling the reloadGridData () function after the modal box has finished, when all the logic of the modal box has already worked.

Block "else" in 160 line can be left uncommented.

Show all comments

Hello Community!

I am developing a functionality such as, a data grid within a detail, is populated when I Click a button. In the same time when I click the button I want to reload the grid data. Which is the proper syntax for the callback function in Creatio, because i havent seen many examples in the Community.

 
			onGenerateButtonClick: function(callback,scope)
			{
				var currentRecordId = this.get("MasterRecordId");
				var args = {
                    sysProcessName: "FZProcess_dc5a9de",
                    parameters: {
                        RecordId: currentRecordId,
						Amount: FZAmount,
						Interes: FZInteres,
						StartPaymentDate: FZStartPaymentDate,
						Tenor: FZTenor		
                    } 		
                }                
				this.reloadGridData();
                ProcessModuleUtilities.executeProcess(args);  
 
			}

I want to use this.reloadGridData(); inside a callback, after the   ProcessModuleUtilities.executeProcess(args) is finished , which is the proper way to do this ? 

Like 0

Like

7 comments
Best reply

Petrika,

In your case the button appears to be a part of the page schema, not a part of the detail schema. For you to refresh the detail you'd need to use:

this.updateDetail({ detail: "NameOfDetail" });

You can find the "NameOfDetail" value to use by looking at the details section of the page code for your detail (it's not the name of the detail schema, but the name or Id it gave it when it added it to the page). The reloadGridData function only works from within the detail schema code itself. 

Hello Petrika,

Calling this.reloadGridData() is the proper function to use to refresh the detail grid from within the detail schema itself. However, you do need to call after the process completes. 

I have an article here that shows how to use a callback when executing a process: https://customerfx.com/article/programmatically-starting-a-process-from…

If you put the call to reloadGridData inside the callback then it will refresh  when the process has completed.

Ryan

Ryan Farley,

Hello Ryan,

Firstly thanks for the quick reply, your posts are very useful, each time i have a developing problem in creatio.

In this case i saw the post before. I have try it. When I use the callback like the article the page only reloads and never stops, thats why i thought of another callback syntax.

Ryan Farley,

To be more specific

I have created this button Generate on the Main Page(parent). When this button is clicked , it calls a bussines Process, which on the other hand executes a Stored Procedure(populates dhe datagrid of the details).

onGeneratePrecalButtonClick: function()
			{
var currentRecordId = this.get("Id");
		var args = {                                                                  
		sysProcessName: "FZProcess_dc5a9de",
			parameters: {
				RecordId: currentRecordId,
				Amount: this.$FZAmount,
				Interes: this.$FZInteres,
				StartPaymentDate: this.$FZStartPaymentDate,
				Tenor: this.$FZTenor		
					}
				};
              ProcessModuleUtilities.executeProcess(args);  
}

When the Business Process finishes, i want to reload the grid data of the Details, so that I dont have to press the green Button below

How can this be done ?

 

Petrika,

 

Hello,

 

There are two possible ways:

 

1) Call this method after the executeProcess method call:

this.updateDetail({
 
                        detail: "DetailNameHere"
 
                    });

2) At the end of your business process execution you need to send some message using MsgChannelUtilities class and PostMessageToAll method, create a replacing ClientMessageBridge, add your message there, add the message to the page where the detail is located, subscribe to the message and specify a handler for the received message (a simple example is here). Once the message is received the handler should call the same updateDetail method as above.

 

Best regards.

Oscar

Petrika,

In your case the button appears to be a part of the page schema, not a part of the detail schema. For you to refresh the detail you'd need to use:

this.updateDetail({ detail: "NameOfDetail" });

You can find the "NameOfDetail" value to use by looking at the details section of the page code for your detail (it's not the name of the detail schema, but the name or Id it gave it when it added it to the page). The reloadGridData function only works from within the detail schema code itself. 

Thanks very much Oscar and Ryan ! Your help was great.

Hi

Have 
"operation": "insert",
                "name": "DataGrid_md3ruqw",


in handler section of a button trying to reload using 
this.updateDetail({ detail: "DataGrid_md3ruqw" });
 

and tried 

 this.reloadGridData('DataGrid_md3ruqw');


both dont work any help will be highly appreciated 
 

Show all comments

Hi Community,

I want to call a process on the 
client side and when it ends, for example, update certain values ​​of the page. 
Is it possible using the callback? 
The callback works but the page with the caption of loading remains. I Have this example:

var someFunction = function (a) { 

                                    

                                    this.loadSchemaCaptionByName("UsrApproveBSRankedCompare", function(caption) {

                                                this._showSuccessfullyRunProcessPopup("The process has been completed");

                                            }, this);

                                    

                                };

                                this.executeProcess(args , someFunction)

 

executeProcess: function(sysProcessName, callback) {

                ProcessModuleUtilities.responseCallback = callback;

                ProcessModuleUtilities.executeProcess(sysProcessName)

            }    

 

 

Thank you!

regards

Like 0

Like

2 comments

Dear Uriel,

In order to complete your task you need to split it into two parts:

1. Launch the business process call from client side. Please see the following article and link for more details:

https://community.bpmonline.com/questions/trigger-business-process-clie…

https://academy.bpmonline.com/documents/technic-sdk/7-13/process-launch…

2. After the process executes, it needs to send the signal to the client side to proceed further with the logic. The example of such logic you can find in the following thread of our Community:

https://community.bpmonline.com/questions/refresh-page-fields-after-pro…

Regards,

Anastasia

 

Show all comments