Hi Team,

 

I have added a custom lookup object to the order section and i added few lookup values. But in the record when i clicked on lookup field i want to display the available unique/distinct values.

 

Please find the attachments for reference.

 

Thanks in  advance!

 

Regards,

Bhoobalan P.

 

 

Expected Values:

Note:

I have used the below code but it doesnt work.

Like 0

Like

5 comments
Best reply

Hello Bhoobalan,

 

1. The best approach is to add a new column “Inactive” in the object, you can do this when you open the object in configuration, and in the behavior, section click in the checkbox “Allow records deactivation”

After that publish your object and go to the lookup section. Here in your lookup, you will see one additional column, called “Inactive”, for records you do not want to see, please fill in this checkbox.

After you will see only records in your dropdown that are not inactive.

 

2. Another approach that is not recommended is to implement filtering after you receive the collection of values. You should do this after receiving because you cannot apply isDistinct property for you select, because the Id for each record is different, so it will always return you all records. In your page (OrderPage) add one more method:

 

onLookupDataLoaded: function(config) {
    this.callParent(arguments);
    if (config.columnName === "YourColumnName") {
        var displayValues = [];
        Terrasoft.each(config.objects, function(item) {
            if (Ext.Array.contains(displayValues, item.displayValue)) {
                delete config.objects[item.value];
            } else {
                displayValues.push(item.displayValue);
            }
        }, this);
    }
}

Where YourColumnName is the column name in the object.

 

Best regards,

Bogdan S.

You can make this a popup selection, where you can display some other fields in the lookup which will help you to distinguish or filter proper value. For e.g. Order number +Account Name + City

KrishnaPrasad,

Thanks for the response.



This is a simple lookup field which has duplicate values. In a record if i click this i want to display the unique values of the lookup object.

 

Step 1 : I have created a lookup object

Step 2 : I haved added values for that lookup object (with duplicate entries)

Step 3 : but when i use that field in a section record i.e if i clicked that lookup field it is populating all the values of the lookup (including duplicate entries). Here i want the distinct vales to be shown.

 

Please find the attachment for reference!



Hello Bhoobalan,

 

1. The best approach is to add a new column “Inactive” in the object, you can do this when you open the object in configuration, and in the behavior, section click in the checkbox “Allow records deactivation”

After that publish your object and go to the lookup section. Here in your lookup, you will see one additional column, called “Inactive”, for records you do not want to see, please fill in this checkbox.

After you will see only records in your dropdown that are not inactive.

 

2. Another approach that is not recommended is to implement filtering after you receive the collection of values. You should do this after receiving because you cannot apply isDistinct property for you select, because the Id for each record is different, so it will always return you all records. In your page (OrderPage) add one more method:

 

onLookupDataLoaded: function(config) {
    this.callParent(arguments);
    if (config.columnName === "YourColumnName") {
        var displayValues = [];
        Terrasoft.each(config.objects, function(item) {
            if (Ext.Array.contains(displayValues, item.displayValue)) {
                delete config.objects[item.value];
            } else {
                displayValues.push(item.displayValue);
            }
        }, this);
    }
}

Where YourColumnName is the column name in the object.

 

Best regards,

Bogdan S.

Bogdan Spasibov,

Thanks much for the response!

onLookupDataLoaded: function(config) worked well.
I have similiar need in this below question too.

how to display distinct/unique values in multiselect lookup?

 

https://community.creatio.com/questions/display-column-distinct-values-…

 

Thanks in advance.

 

 

Regards,

Bhoobalan P.

Bhoobalan Palanivelu,

 

Please try the following code as an example: 

 

var esq = this.Ext.create(Terrasoft.EntitySchemaQuery, {
    rootSchemaName: "Activity"
});
esq.addAggregationSchemaColumn("DurationInMinutes",
Terrasoft.AggregationType.COUNT,
"UniqueActivitiesCount",
Terrasoft.AggregationEvalType.DISTINCT);

 

Terrasoft.AggregationEvalType.DISTINCT is the key part for your task that will allow filtering only distinct values. 

 

Regards,

Anastasiia

Show all comments