How can I change UserSettings by script in Report

Common questions about 1C:Query language, Query builder tool and Data composition schema

#1
People who like this:0Yes/0No
Interested
Rating: 27
Joined: Apr 5, 2012
Company: 1TÇ Şirketi - Merv Bilgi İşlem Otomasyonu Yazılım Ltd. Şti.

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.

 
#2
People who like this:1Yes/0No
Active user
Rating: 7
Joined: Sep 26, 2012
Company: individual

> 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;

 
#3
People who like this:0Yes/0No
Interested
Rating: 27
Joined: Apr 5, 2012
Company: 1TÇ Şirketi - Merv Bilgi İşlem Otomasyonu Yazılım Ltd. Şti.

thanks ivan will try it.

 
#4
People who like this:0Yes/0No
Interested
Rating: 27
Joined: Apr 5, 2012
Company: 1TÇ Şirketi - Merv Bilgi İşlem Otomasyonu Yazılım Ltd. Şti.

ivan here is a new question:

If in settings we do not have such filter item?

 
#5
People who like this:0Yes/0No
Active user
Rating: 7
Joined: Sep 26, 2012
Company: individual

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

Edited: ivan avdonin - Sep 16, 2014 01:45 AM
 
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.