Question

facing issue with availability of action in combined mode

Dear Community,

 

I have added an action in a contact page.  The Enabled function is working fine in edit mode. But I am facing issues in combined mode, I have to use Entity schema query in the enabled function. while debugging the method is working fine but the action is always in disabled mode. Below is the code from the contactsectionV2. Please help me resolve this issue.

                AddIssuesEnabled: function(){

                    

                 var activeRowId = this.get("ActiveRow");

                if (!activeRowId) {

                    return false;

                }

                      var selectedcontact = this.get("GridData").get(activeRowId);

                    

        var esq = this.Ext.create("Terrasoft.EntitySchemaQuery", {

    rootSchemaName: "Contact"

});

    esq.addColumn("idlcContactCIF");

    var contactId = selectedcontact.get("Id");

    

    esq.getEntity(contactId, function(result) {

    if (!result.success) {

        // error processing/logging, for example

        this.showInformationDialog("Data query error");

        return;

    }

   if(!result.entity.get("idlcContactCIF")){

     return true;

   }

      return false;

}, this);

                    

                    

                }

            

            

            

        

Like 0

Like

5 comments

Hello,

 

Can you please describe what result is desired so we could check the ESQ?  Also please provide us with the complete code of the ContactSectionV2 since it is not clear how the AddIssuesEnabled method is triggered.

 

Thank you!

 

Best regards,

Oscar

Oscar Dylan,

hi Oscar,

 

 

this is full code

 

ContactPageV2 Code

-----------------------------



            //hide button

            AddIssuesEnabled: function(){

                if(this.get("idlcContactCIF")){

                    return false;

                }

                return true;

            },

            

            //space bar for section

            

            getActions: function() {

                // Parent method implementation is called to receive

                // the collection of initialized actions of the base page.

                var actionMenuItems = this.callParent(arguments);

                // Adding a separator line.

                actionMenuItems.addItem(this.getActionsMenuItem({

                    Type: "Terrasoft.MenuSeparator",

                    Caption: ""

                }));            

            

             // Adding the [Conducting a meeting] menu option to the edit page action list.

                actionMenuItems.addItem(this.getActionsMenuItem({

                    // Binding the caption of the menu option to localizable string of the schema.

                    "Caption": { bindTo: "Resources.Strings.createCIFRequest" },

                    // Binding the action handler method.

                    "Tag": "createCIF",

                    // Binding the visibility property of the menu option to the value, which returns the

                    //isAccountPrimaryContactSet() method.

                    "Enabled": { bindTo: "AddIssuesEnabled" }

                }));

                return actionMenuItems;

            },

            

            createCIF: function()

            {

                

             var contactParameter = this.get("Id");

                // The object that will be transferred to the executeProcess() method as an argument.

                var args = {

                    // The name of the process that needs to be launched.

                    sysProcessName: "CIF Request",

                    // The object with the ContactParameter incoming parameter value for the Cust

                    parameters: {

                        ProcessSchemaContactParameter: contactParameter

                    }

                };

                // Launch of the custom business process.

                ProcessModuleUtilities.executeProcess(args);    

                

            }

            

            

            

 

this are the ContatSectionV2 full code

---------------------------------------------------

 

define("ContactSectionV2", [], function() {

    return {

        entitySchemaName: "Contact",

        details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/,

        diff: /**SCHEMA_DIFF*/[]/**SCHEMA_DIFF*/,

        methods: {

            

                AddIssuesEnabled: function(){

                    

                 var activeRowId = this.get("ActiveRow");

                if (!activeRowId) {

                    return false;

                }

                      var selectedcontact = this.get("GridData").get(activeRowId);

                    

        var esq = this.Ext.create("Terrasoft.EntitySchemaQuery", {

    rootSchemaName: "Contact"

});

    esq.addColumn("idlcContactCIF");

    var contactId = selectedcontact.get("Id");

    

    esq.getEntity(contactId, function(result) {

    if (!result.success) {

        // error processing/logging, for example

        this.showInformationDialog("Data query error");

        return;

    }

   if(!result.entity.get("idlcContactCIF")){

     return true;

   }

      return false;

},

this);

            

                }



          }

    };

});

Nageswara Rao,

Your issue is that in the Section you're using an ESQ in the function that returns true/false for the action to be enabled/disabled (AddIssuesEnabled). The problem with this is that the ESQ is asynchronous, so the function returns a value prior to the ESQ having returned the results. 

 

I assume you're only using the ESQ since the idlcContactCIF column is unavailable when in combined mode. This is because when in combined mode and you get the activeRow in the list, it only includes the columns in the list layout. You can avoid the ESQ altogether and make sure it is available by adding it to the ESQ for the list, regardless of whether it is in the list layout or not. You can do this by overriding the initQueryColumns in the section schema. In this function you can add the column to the list query and then you can read it normally.

initQueryColumns: function(esq) {
    this.callParent(arguments);
 
    if (!esq.columns.contains("idlcContactCIF")) {
        esq.addColumn("idlcContactCIF");
    }
}

Now, you can change the AddIssuesEnabled to this:

AddIssuesEnabled: function(){                
    var activeRow = this.get("ActiveRow");
    if (!activeRowId) {
        return false;
    }
    return Ext.isEmpty(this.get("GridData").get(activeRow).get("idlcContactCIF"));
}

Hope this helps.

Ryan

 

Ryan Farley,

 

hi ryan

thanks for your help, its working fine but facing small issue on ContatSectionV2 when it save and refresh only it work, in ContactPageV2 page it its working fine

Nageswara Rao,

 

Hello,

 

Can you please share the code once more and provide steps to reproduce the problem?

 

Thank you!

 

Best regards,

Oscar

Show all comments