Filter a report by coding

The 1C:Enterprise developers forum

#1
People who like this:0Yes/0No
Active user
Rating: 5
Joined: Jun 4, 2013
Company:

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

 
#2
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

Hello, Mohammad,

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

 
#3
People who like this:0Yes/0No
Active user
Rating: 5
Joined: Jun 4, 2013
Company:

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 ?

 
#4
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

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

 
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.