Desktop version

Main > Forum > 1C:Enterprise Platform > 1C:Query language and DCS > How can I change UserSettings by script in Report

Forum

Search UsersRules
How can I change UserSettings by script in Report
#1
Interested
Points:: 0
Joined:: Apr 5, 2012

Hi,

I have standard report that is working on DCS.

How can understand the working logic of such reports: platform reproduce report result accourding to user settings in base of report variant.

So for the items of user settings in syntax there is a definition that items can not be changed.

Quote
DataCompositionUserSettings
Items
Usage:

Read only.
Description:

Type: DataCompositionUserSettingsItemCollection.
Collection of user settings items.

Availability:

Thin client, web-client, server, thick client, external connection.

So how can I change the user setting only by script? For example I need to set a Filter.

Profile
#2
Active user
Points:: 0
Joined:: Sep 26, 2012

> Read only.

Its mean that you cant change property Items, but you can change any Item of this collection

Quote
DataCompositionUserSettingsItemCollection

Iteration through collection using For each ... In ... Do operator is available to object. Conditional appearance items are retrieved during iteration.
Access to conditional appearance items is possible using [...] operator. Index (starting from 0) is passed as an argument.

Methods:

Add
Clear
Count
Delete
...

Description:

Collection of user settings.

Like so, for example
Code
   findLeftValue = New DataCompositionField("Document");
   UserSettingID = "";
   For Each item In Report.SettingsComposer.Settings.Filter.Items do
      if item.LeftValue = findLeftValue then
         UserSettingID = item.UserSettingID;
      endif;
   enddo;
   
   For Each item In Report.SettingsComposer.UserSettings.Items do
      if item.UserSettingID = UserSettingID then
         item.RightValue = Attribute1;
      endif;
   enddo;

Profile
#3
Interested
Points:: 0
Joined:: Apr 5, 2012

thanks ivan will try it.

Profile
#4
Interested
Points:: 0
Joined:: Apr 5, 2012

ivan here is a new question:

If in settings we do not have such filter item?

Profile
#5
Active user
Points:: 0
Joined:: Sep 26, 2012

You can do many different things at event handler OnComposeResult in object module of the report

Quote
You can intercept the report creation and get parameters from Settings, FixedSettings, and UserSettings properties of SettingsComposer object in OnComposeResult of the report object module.

Some details in The parameter list in the report topic

And example in Filter a report by coding topic

My example:
Code
Procedure OnComposeResult(ResultDocument, DetailsData, StandardProcessing)
   
   StandardProcessing = False;
   
   Settings = SettingsComposer.Settings;

   new_Filter = Settings.Filter.Items.Add(Type("DataCompositionFilterItem"));
   new_Filter.LeftValue = New DataCompositionField("Document");
   new_Filter.ComparisonType = DataCompositionComparisonType.Equal;
   new_Filter.RightValue = Some_Value;

   TemplateComposer = New DataCompositionTemplateComposer;
   CompositionTemplate = TemplateComposer.Execute(DataCompositionSchema, SettingsComposer.GetSettings(), DetailsData);
   
   CompositionProcessor = New DataCompositionProcessor;
   CompositionProcessor.Initialize(CompositionTemplate, , DetailsData);
   
   ResultDocument.Clear();
   
   OutputProcessor = New DataCompositionResultSpreadsheetDocumentOutputProcessor;
   OutputProcessor.SetDocument(ResultDocument);
   OutputProcessor.Output(CompositionProcessor);
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.