How to query an AccountFolder and get the results of the filter

I have few folders created on the Account section. I want to create a detail in a different section page. On that that detail I want to be able to insert the account records which are read from the AccountFolder. 

So ideally, I like to have a pop up which shows me all the folders on AccountFolder and when I select a folder, I want to be able to add all of the accounts on that folder to that detail. 

Thank you in advance

Like 0

Like

5 comments

Dear Kumar,

In this case you need to create a simple detail using detail wizard and use "Account folder" object. After that you need to go to the schema of the detail and find the method that is called when clicking on "+" button that adds new record standardly. You need to replace the methos that is called there (that creates a record) and put the method which generates a pop-up that displays account folders and after that you need to add a method that calls accounts that are present in the selected folder. Here is the link to technical documentation on development https://academy.bpmonline.com/documents/technic-sdkmob/7-12/bpmonline-d….

Best regards,

Oscar

Oscar Dylan,

How can I generate a pop-up window that display account folders? Is there a place where I can get the example method code I can take a look at? 

AccountFolder.SearchData is binary type field. Will you guide me on how to get the accounts that are present in the selected folder? 

Thank you

Puneel

Dear Kumar,

Please take a look at openLookupPage function of the BaseSchemaViewModel schema. This method is triggered when clicking on the lookup and opens the module page. You can pass it the needed arguments so to open account folders. 

As for the folders, the filtration for folders are preset by user. The idea is to apply the same filters for each folder using ESQ functions. In other words, when clicking on particular folder an ESQ function is triggered to Account object with the filters, which are used for the folder.

Hope you will find it helpful.

Regards,

Anastasia

Anastasia Botezat,

contactInputBoxHandler: function(returnCode, controlData) {

                if (Terrasoft.MessageBoxButtons.OK.returnCode === returnCode) {

                    var rocId = this.get("MasterRecordId");               

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

                        rootSchemaName: "AccountFolder",

                    });

                    esq.addColumn("Name");

                    esq.addColumn("SearchData");

                    var esqFilter = Terrasoft.createColumnFilterWithParameter(                       this.Terrasoft.ComparisonType.EQUAL,"Name",controlData.UsrAccountFolder.value.displayValue);

                    esq.filters.add(esqFilter);

                    esq.getEntityCollection(function(result){

                         result.collection.each(function (item) {

                             var searchData = item.get("SearchData");                            

                             var esqAccounts =                     Ext.create("Terrasoft.EntitySchemaQuery",{

                                 rootSchemaName: "Account",

                             });

                             esqAccounts.addColumn("Name");

                             esqAccounts.filters.add("searchData",searchData);

                             esqAccounts.getEntityCollection(function(accounts){

                                 accounts.collection.each(function(act){

                                     console.log(act.get("Name"));

                                 });

                             });

                         });

                    });                    

                }

            },



            The error is thrown when I add this filter. esqAccounts.filters.add("searchData",searchData);

the searchData is as follows

{"className":"Terrasoft.FilterGroup","items":{"1a34c133-7cb5-49e1-a235-2065b90d2e3f":{"className":"Terrasoft.CompareFilter","filterType":1,"comparisonType":3,"isEnabled":true,"trimDateTimeParameterToDate":false,"leftExpression":{"className":"Terrasoft.ColumnExpression","expressionType":0,"columnPath":"Name"},"isAggregative":false,"key":"1a34c133-7cb5-49e1-a235-2065b90d2e3f","dataValueType":1,"leftExpressionCaption":"Organization Name","rightExpression":{"className":"Terrasoft.ParameterExpression","expressionType":2,"parameter":{"className":"Terrasoft.Parameter","dataValueType":1,"value":"Arkansas Surgical Hospital"}}}},"logicalOperation":0,"isEnabled":true,"filterType":6,"rootSchemaName":"Account","key":"FolderFilters"}

 

Am I using this AccountFolder.SearchaData field as a filter on Account object incorrectly? I keep getting this error 

Uncaught TypeError: e.on is not a function

kumar,

You are applying filter to the binary column, which would not work. Your task is, however, to recreate a filter to Account object same as the folder is working under. This means that for example if account folder "Show accounts from England" has a filter by country, you need to add such filter to the ESQ.



Regards, 

Anastasia

Show all comments