Action not appearing if field is not on section List page

Hi Community,

 

For one of the system user, we have one custom action which is visible and editable only when certain conditions meet.

Code

 

When everything is working user can see the highlighted action and fields on which the condition is applied  : 

 

Issue : When we remove any one of the field let's say OrderType(lookup) from Section List view Action is not visible even when the conditions meet.

 

Please see the below image when Order Type is removed from section list view.

 

Error : 

In statusordertype = selectOrder.get("UsrOrderType"); It is taking statusordertype as undefined.

But UsrOrderType is filled.

 

So Complete scenario is this that when the field on which the condition are applied are visible on the section List view Custom Action is Visible but the moment we removed the field from section list view It is throwing error even when the field is filled in.

 

This is not the case with Admin.

 

Please help me to understand the root cause of this issue ?

Like 0

Like

6 comments
Best reply

Akshit,

Your issue is likely this line: 

if (!esq.columns.contains("UsrField1", "UsrField2", "UsrField3", "etc") 

The contains function on esq.columns accepts only a single field name to check for (so it is only checking for the first one, all the other parameters are ignored). See implementation here.

Change your code so you are doing it like this: 

if (!esq.columns.contains("UsrField1") {
    esq.addColumn("UsrField1");
}
if (!esq.columns.contains("UsrField2") {
    esq.addColumn("UsrField2");
}
// etc

Or something like this:

var fields = ["UsrField1", "UsrField2", "UsrField3"];
for (var i=0; i<fields.length; i++) {
    if (!esq.columns.contains(fields[i]) {
        esq.addColumn(fields[i]);
    }
}

Hope this helps.

Ryan

Hi Akshit,

 

This is correct since the data is received from the grid itself (meaning only from columns in the grid), but not from the record. So in case some column is not present in the grid data from it won't be fetched by the client logic. I believe there was a community post previously with an explanation on how to overcome it, I will try to find it and share the link with you.

 

Best regards,

Oscar

Here is the link to the related topic where Ryan shared an idea on how to add missing columns to the ESQ - https://community.creatio.com/questions/unable-get-data-active-record-s….

 

Best regards,

Oscar

Hi Oscar Dylan,

 

We had already added the columns in esq, According to what Ryan has said in reply.

 

 

But it's not working.

 

There is one more Information I would like to share once the record is  approved the user only have read permissions.

 

For Admin it is working even when the fields are not on the section list view.

 

Any Idea what could be the issue ?

 

 

 

Akshit,

Hello,

 

Then if the columns esq working for Admin, but not for a regular user then maybe the problem is with column permissions? Also have you tried another approach with managing access rights to records via a business process (using the "Change access rights" element)?

 

Best regards,

Oscar

Akshit,

Your issue is likely this line: 

if (!esq.columns.contains("UsrField1", "UsrField2", "UsrField3", "etc") 

The contains function on esq.columns accepts only a single field name to check for (so it is only checking for the first one, all the other parameters are ignored). See implementation here.

Change your code so you are doing it like this: 

if (!esq.columns.contains("UsrField1") {
    esq.addColumn("UsrField1");
}
if (!esq.columns.contains("UsrField2") {
    esq.addColumn("UsrField2");
}
// etc

Or something like this:

var fields = ["UsrField1", "UsrField2", "UsrField3"];
for (var i=0; i<fields.length; i++) {
    if (!esq.columns.contains(fields[i]) {
        esq.addColumn(fields[i]);
    }
}

Hope this helps.

Ryan

Ryan Farley,

 

Thanks, Ryan. It works!

Show all comments