Desktop version

Main > Forum > 1C:Enterprise Platform > 1C:Enterprise – Business applications platform > How to edit parameters in Document Templates?

Forum

Search UsersRules
How to edit parameters in Document Templates?
#1
Just came
Points:: 0
Joined:: Aug 19, 2019

Hello,

I need to update an existing Document Template. For the sake of simplicity, I will show my issue on basic simple Document Template as shown below. Document has only two attributes "Number" and "Date". (Please see below)



When I run this report, I need to add some string prefix to "Number" parameter in a way that some string and current year should be added (eg: "PREFIX" + YEAR() + <Number>)



Any support appreceated.

Regards
Savas

Profile
#2
Just came
Points:: 0
Joined:: Sep 7, 2019

Use the 'Template' FillType.

Code to fill the template parameters looks like this:

Code
Section.Parameters.Year = Year(CurrentDate());
Section.Parameters.Number = "66613";


My Webpage

Profile
#3
Just came
Points:: 0
Joined:: Sep 7, 2019

Profile
#4
Just came
Points:: 0
Joined:: Aug 19, 2019

Dear Leo Sadovsky,

Thank you for response. The link you sent is somehow broken. Can you please send me in different way, may be via email "savas.erzin@gmail.com"

As you advised in your reply, which module are you writing these codes and what "Section" is stand for there? My words are very demanding but I cannot get any clue in my documentations so far. Any further help appreceated.

Regards
Savas

Profile
#5
Just came
Points:: 0
Joined:: Sep 7, 2019

Quote
link you sent is somehow broken
The link is to the image I've posted a second later at Sep 28, 2019 04:32 AM. I've just missused the bottons - used 'Hyperlink' instead of 'Image attachment'

Quote
which module are you writing
that code should be placed to the method, where you fill your spreadsheet document

Quote
what "Section" is
is the section of your template, which you create with the SpreadsheetDocument::GetArea() method

This example creates the spreadsheet document, gets the template similar to the screenshot above, fills the section parameters and then puts the section into the spreadsheet document:
Code
SpDoc = New SpreadsheetDocument;

Template = GetTemplate("Template1");

Section = Template.GetArea("Section"); 
Section.Parameters.Year = Year(CurrentDate());
Section.Parameters.Number = "66613";

SpDoc.Put(Secion);

Profile
#6
Just came
Points:: 0
Joined:: Aug 19, 2019

Dear Leo Sadovsky,

Thank you for your response again but I cannot go to solution yet.

Let me ask my question this way.

This is my Spreadsheet template on PersonelDoc. As you can see, I have created a "Test" parameter where Fill Type is "parameter".



I click Object Module on Document properties window as shown below.



Then it takes me to code window where Print template is generated. This code is generated automatically by system. (please see below)



Fr om this point, I think I can go to somewhere where I can use "Test" parameter to assign "PREFIX-2019-Number".

1) As we can see in generated code, SQL statement seems very promising where I can add traditionally any number of column I wish. Lets say, wouldnt be perfect if I would add such "Test" field then I can capture in code as parameter. But it seems that this is not working in 1C approach

Code
   "SEL ECT
   |   PersonelDoc.Date,
   |   PersonelDoc.Number,
   |   N'PREFIX-'  + CONVERT(nVarChar(4),YEAR(GETDATE())) + N'-' + PersonelDoc.Number AS Test
   |FROM


2) As a second option, I can add a code as shown below wh ere I can assing "Number" into "Test" parameter but it is also not working because "Test" parameter is Empty String in report.

Code
   Header.Parameters.Test = "PREFIX" + TakeCurrentYearSomeHow().ToString() +  Header.Parameters.Number;


Can you please advise how can I assing value into "Test" parameter fr om "Number"?

Any support appreceated

Profile
#7
Just came
Points:: 0
Joined:: Sep 7, 2019



There is an example of the correc use of the 'template' FillType

https://1drv.ms/u/s!AlzlxyjYDx-juQtPSAPcDCR8gkoN

Profile
#8
Just came
Points:: 0
Joined:: Aug 19, 2019

Dear Leo Sadovsky, ,

I owe you a pint, really good help. Thank you.

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.