Search code examples
viewaxaptasynchronizeddynamics-ax-2012x++

How to refresh/Synch View based on a Query with dynamic range?


I have a simple View with a Query , my custom Query has a Dynamically Range.

In class SysQueryRangeUtil I have insered a my custom public static method and copy it in my Custom Query. This range, work well. But I have a problem, when the range condition change, if I want to see the new view(with new selected record) I have to Synch, in AOT my View.

But this operation can't do a simple SystemUser.

There is a way to use a dynamic range in a View and not constantly synchronize ?

My dynamic range relates to curUserId() when change the user who open the Form/View the view has to change the record displayed. If I want to see de difference I have to synch every time, but for me it's not an usable solution.

DynamicRangeOnQuery

MyView enter image description here

Thanks all!


Solution

  • Do not use range on your query, move this logic on form level.

    In the classDeclaration method of your form declare a variable of type QueryBuildRange.

    Override init method on your form datasource:

    public void init()
    {
        ;
    
        super();
    
        queryRange = Table1_ds.query().addRange(MyView_ds.queryBuildDataSource(), AccountNum);
        queryRange.status(RangeStatus::Hidden);
    }
    

    Override executeQuery method on your form datasource:

    public void executeQuery()
    {
        ;
    
        queryRange.value(filterBycurUserId());
    
        super();
    }