Desktop version

Main > Forum > 1C:Enterprise Platform > 1C:Enterprise – Business applications platform > Filter a report by coding

Forum

Search UsersRules
Filter a report by coding
#1
Active user
Points:: 0
Joined:: Jun 4, 2013

Hi ... how are you guys. :)

I'm trying to filter a report, I'm able to do it from the sittings, but I want the user to change the right value of the filter from a field in the report form, and i can't find any function related to this task.

can you give me a hint please ?

and thanks in advance

Profile
#2
Guest
Points::
Joined::

Hello, Mohammad,

You can set up quick access for your filter items, see screenshots below:

Profile
#3
Active user
Points:: 0
Joined:: Jun 4, 2013

I did exactly as you descriped ... but I'm not allowed to put the right value in a filed in the form .. hope you will understand what i mean, can you show me the right value data path please ?

Profile
#4
Guest
Points::
Joined::

This value is for user input. If you want to set filter in script, you will have to create a report form, and set it during form is created.

When you do so you will have an access to settings composer. There will be 3 groups of settings: Settings, UserSettings and FixedSettings.

You should set default values in Settings (if you can't set right value in Designer mode, of course).
Some settings that are marked as allowed for user edit will appear in UserSettings and if a user will change it, values will be changed in this collection and applied from it to the report.
You can also use FixedSettings to protect them from being changed by a user, but it is not very convenient as you will have to monitor if a user added same filter to UserSettings.

Here is an example:

Code
&AtServer
Procedure OnLoadUserSettingsAtServer(Settings)
   
   Value = 12;
   FilterField = New DataCompositionField("Price");
   
   For Each FilterItem In Report.SettingsComposer.Settings.Filter.Items Do
      
      If TypeOf(FilterItem) = Type("DataCompositionFilterItem") 
         And FilterItem.Use 
         And FilterItem.ComparisonType = DataCompositionComparisonType.GreaterOrEqual 
         And FilterItem.LeftValue = FilterField Then
         
         FilterItem.RightValue = Value;
         
         UserSettingID = FilterItem.UserSettingID;
         
         For Each UserSetting In Report.SettingsComposer.UserSettings.Items Do
            If UserSetting.UserSettingID = UserSettingID Then
               
               UserSetting.RightValue = Value;
               
               Break;
               
            EndIf;
         EndDo;
         
         Break;
         
      EndIf;
      
   EndDo;
   

EndProcedure

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.