Pb with redundancy

Hi, I have created a view. My view is: CustTable–>SalesId–>DossierLoc I would like to display some informations of the view in a grid (only the name, the acount number and some informations coming from DossierLoc). As one Client can have a lot of sales, a line can appear several times in my grid. How can I do to remove this redundancy? Thanks. Vince

Hi Vince, I am not sure what you want to do, but you can create CustTable dataSource for form. You can get customer name and account number from this datasource and you can create “display” method for retrieving DossierLoc information. I am not sure why you have “redudant” lines, but I guess you have not used proper relationships for joining tables.

It’s not exactly redundancy. In my view I have for example: AccountNum | Name | SalesId | DocNum AN12 | Peter | si02 | dc2 AN12 | Peter | si03 | dc2 AN13 | John | si04 | dc3 When I want to display the AccountNum, the Name and the DocNum (NOT the SalesId) in a grid, I obtain: AN12 | Peter | dc2 AN12 | Peter | dc2 AN13 | John | dc3 The 2 first line are equals. I would loke that: AN12 | Peter | si02 | dc2 AN13 | John | si04 | dc4 Thanks. Vince

Vince, please send me XPO of your project and I will try to help. Contact me using PM.

Hi Vince, Just to make sure that I get your requirement straight - From which table this data is coming from? Particularly the first 3 columns?

quote:

| AN12 | Peter | si02 | dc2 AN12 | Peter | si03 | dc2 AN13 | John | si04 | dc3 |
| - |

Cheers, Harish Mohanbabu

All this data are coming from the same table, each line is unique but I want to display only the first and the second column. But I don’t want to have two times the line with Peter. With SQL it’s easy because I just have to use the “distinct” command but with Axapta I don’t kinow. AN12 | Peter | si02 | dc2 AN12 | Peter | si03 | dc2 AN13 | John | si04 | dc3 Vince

Hi Vince, In that case - perhaps you can try to apply a filter on the datasource using firstonly() property of QueryBuildDataSource class. You should be able to write this filter on the init() method on the datasource after a call to super(). For more info on QueryBuildDataSource, do please refer Developer’s guide and Axapta help. Hope this helps. Regards, Harish Mohanbabu

Thanks for the advise, but I don’t know I can do to put “firstonly” in a “QueryBuildDataSource” , because with addRange.value(xxx) I can’t put “firstonly”… and I don’t how I can make a request in a QueryBuildDataSource … Vince

Hi Vince, Quickly - I guess your code would go something like this - ************************************ <TABLE NAME>_ds.autoQuery(false); QueryBuildDataSource qbds; QueryBuildRange qbr; Query query = new Query(); qbds = Query.addDataSource(tablenum(<TABLE NAME>)); //First Only qbds.firstOnly(true); //If you want to sort qbds.orderMode(Ordermode::ORDERBY); qbds.addSortField(FieldNum(<TABLE NAME>,<FIELD NAME>)); //Build range qbr = qbds.addRange(Fieldnum(<TABLE NAME>,<FIELD NAME>)); <TABLE NAME>_ds.Query(Query); ************************************ Do please try this and let me know how it goes ! Regards, Harish Mohanbabu

Thanks for your script, But now, I just have one line in my grid (the first one) AN12 | Peter | si02 | dc2 AN12 | Peter | si03 | dc2 AN13 | John | si04 | dc3 AN14 | Will | si05 | dc4 I would like to have in my grid: AN12 | Peter |dc2 AN13 | John |dc3 AN14 | Will |dc4 Vince

Hi Vince, Would you mind posting your code please. Ideally could you do a comlpete export incl table, form etc. Regards, Harish Mohanbabu

My code is: public void init() { QueryBuildDataSource qbds; QueryBuildRange qbr; Query query = new Query(); Vue_Clients_ds.autoQuery(false); qbds = Query.addDataSource(tablenum(Vue_Clients)); //First Only qbds.firstOnly(true); //If you want to sort qbds.orderMode(Ordermode::ORDERBY); qbds.addSortField(FieldNum(Vue_Clients,AccountNum)); //Build range //qbr = qbds.addRange(Fieldnum(Vue_Clients,AccountNum)); Vue_Clients_ds.Query(Query); super(); } I have used your script. I think, maybe I have to use the getNext() method. I chek that the next record has not the same first field, if the next one has the same I select the first with firstonly. But I don’t know how to use getNext(). Vince