Question: HTML code is not displayed in the HTML Field of the Document 1C managed forms
Good day! Someone tell me, I'm creating external processing, created a form, created a Field in the form, created a Requisite in the form (Type: Unlimited String), data path: Requisite (View: HTML Document Field), in the Module I wrote programmatically:
&AtClient
Procedure Field1DocumentGenerated(Item)
ThisObject.Props = "
wellcome
What have I done wrong?
Answer: Who needs this idea, take it, ready-made working and stable chain, tested in 1C: Retail 8 / 2.2 managed forms !!!
Question: Field HTML document ElementsForm.IE.Document.getElementsByClassName()
The story is FormElements.IE.Document.getElementsByClassName("loginform__input-border") normally returns the desired element, but here
ElementsForm.IE.Document.getElementsByClassName("loginform__input-field ng-dirty ng-valid ng-touched") does not find any way
those. does not work when there are spaces in the name...
why?
Answer:() Are there many forms on the page? If not, then get an array of forms and select the one you need.
Question: the form attribute is being cleared (the field of the html document)
Answer:
Question: How to work with the Field of an HTML Document?
Tell me how you can implement the following actions or give a link to the material.
There is a need to programmatically fill in the fields on the site form, log in and programmatically fill in the following fields on the site.
???
Added after 5 hours 9 minutes
You need to programmatically fill in the input "s and click the button ..
Added after 16 hours 29 minutes
How to fill in the fields figured out. Any idea how to click the button?
Added after 1 hour 17 minutes
Understood everything. Thread can be closed/deleted
Answer: Through com. Now there is no time. I'll post back in the afternoon or evening.
Question: HTML document field (not again, but again)
Hello.
managed forms. Self-written conf. Got "script errors" when displaying a web page in an HTML document field. No, I'm not trying to make a full-fledged browser inside 1C (a reference to the general "Browser" form in the standard ones), but some elementary forms, for example, an authorization form on Google, must be displayed. And I would like to output in a human way, so that the user is not surprised at the curses about the scripts.
What has been done:
I configured IE in Windows to ignore scripts. Helped. But the agreement did not pass due to the inconvenience of setting up each client computer.
Scripts were thrown out from the content of the page received at the address when the Document Generated event occurred. Did not help. The curses manage to jump out in front of the nose of the awesome user before the scripts are thrown out.
The document was sent to be formed on the server. Then the HTML code was stripped of scripts and sent to the client in the field of the HTML document. Helped. But clicking buttons and other form work on the client was difficult - many actions require context that was left on the server (cookies). And even if you leave scripts for the necessary buttons and drag cookies from the server to the client, it is unrealistic to track all possible transitions and variations of the content of "foreign" pages, and all kinds of redirects that may occur. Potential hack detected.
Picked typical for the implementation of the output of someone else's HTML. Did not help. Either everything is not "twisted" yet, or the vendor's developers do not contact unknown HTML, or they stop the output in the web client, and the remaining problems with the scripts are ignored.
Help....
Answer:() valuable information, thanks
Question: Help to open the site through the field of the HTML document
Good afternoon. There is a website
Which does not support older browsers.
It must be opened in the HTML document field.
Tried doing compatibility mode:
Website = "
Perhaps I'm using the tags incorrectly for compatibility.
Thanks in advance
Answer:() Thank you, it helped.
Could not find the registry key for win 10.
Question: HTML document field and picture
Is this a glitch or...?
When pasting from the clipboard, instead of a picture, a cross. In the image properties, the address is shown as "cid:image001.jpg@01D0C0A8.FD63F6D0". Tried to copy from outlook "a and browser
Answer: add an image to the images, and then in the html field ..
Question: How to refer to the attribute of the tabular part of the document? (managed form 1C 8.3.11)
Hello Everyone There is not much development experience in 1 C 8.3 so far, so I ask for advice There is a document with a tabular part Dimension Grid with the details Group Template (string) and Size (Nomenclature Characteristics Directory) The Group Template is filled with a request (dimensions from the information register are filled in) next to the Size column you have to fill in manually the same dimensions only from the reference book
I would like to fill the Size column with a cycle, especially since the names are completely the same, how can I access the attribute of the Dimension Grid tabular part?
Through Object.DimensionalGrid.Size says that the field is not found? could you tell me how to implement the procedure?
Procedure FillTemplateOnServer() Request = New Request; Query.Text = "SELECT | SizesAgeGroup.CharacteristicNomenclature.Name AS TemplateGroup | FROM | RegisterInformation.SizesAgeGroup AS SizesAgeGroup |WHERE | AgeGroupSizes.TargetGroup = &TargetGroup | |ORDER BY | DimensionsAgeGroup.OrderInList"; Query.SetParameter("TargetGroup", Object.NomenclatureGP.Composition.TargetGroup); Object.DimensionalGrid.Load(Query.Execute().Unload()); TK=Query.Execute().Unload() ; For Each Page from the TK, the cycleTemplateValue=Page.GroupTemplate;Object.DimensionalGrid.Size=TemplateValue;EndCycle;EndProcedure Regards Damir
Answer: Everything worked great Thank you
Question: Error when calculating the sum of the current row of a tabular section in a managed document form
Tell me what's wrong?
Why is the calculation not working?
(Document.Invoice.Form.DocumentForm.Form(5,23)): Variable not defined (FormElements)
StringTabularPart=<>>FormElements.Materials.CurrentData;
Answer: Code in form module?
Managed forms use Elements instead of FormElements
Good afternoon. The question arose next. From the document procedure, I call the form of the reference element, fill it in and write it down, and it is necessary that after writing to the procedure that all this called, I get a link to the created element.
The procedure code is as follows:
Code 1C | ||
|
it is clear that the form of the reference object opens in this section of code
28
When integrating 1C with websites, the question always arises of transferring some data to a web server. Whether it is the transfer of query parameters to receive data from the web server in 1C, or the transfer of data from 1C, which must be saved or somehow
14
Developers on the 1C platform sometimes have the task of interacting with the 1C: Enterprise system with various mail programs and protocols. 1C Enterprise 8.0 has quite convenient tools for sending messages, importing letters from the mail
9
When exchanging data with websites, the JSON format is often used. Unfortunately, in 1C there are no standard procedures for working with this format. In the process of implementing one of the projects, I developed a number of procedures and functions that make life easier for the program.
8
The JSON format in 1C before version 8.3.6 is not implemented, but below I will give examples of functions that can be used to fully work with JSON in 1C previous versions. JSON (JavaScript Object Notation) is a text-based data interchange format widely used
5
In this article I will try to describe the process of parsing sites using 1C with an example. This article is not an instruction for use, but only demonstrates the capabilities of 1C. What we have? 1. Website on the Internet, which contains a list of products
Showing an Html page on a managed form 1C
To display an Html page, you need to insert the Html Document Field on the form and place the html code in the data source. Keep in mind the following: thin and web client on Internet Explorer work in a special way. Both of these cases use Internet Explorer in IE 7 compatibility mode.The first secret is that the thin client can be put into compatibility mode with an older version of IE. To do this, you need to use meta X-UA-Compatible. So on Windows 7 after adding
You can use SVG objects, for example:
You can switch the IE web client to a more modern compatibility version by placing the 1C web client in an IFrame and setting the compatibility meta tag in the parent html. An example of how this can be done is shown here:
But at the same time, normal operation and display of the web client is not guaranteed, since 1C originally designed the web client based on compatibility with IE6 / 7.
The second secret is that the layout of html layouts in text mode without the 1C visual editor deteriorates after the layout is closed in the configurator. For example, if you insert svg definitions on the html layout, then after reopening the configurator, you will see corrupted html (pay attention to the head header).
Therefore, if your layout is more complicated than showing a picture, then I advise you to save the html code in another place.
Storing everything in a row in common pictures
A modern web page is not limited to just html. In addition to it, there are pictures, js / css-files. The traditional approach allows storing and accessing images placed in common configuration images, but 1C developers have to contrive with js / css. Text files are either archived and unpacked before showing the page, or placed entirely in html. This approach does not use the cache built into almost every browser for get requests.My experience was to put a java script in the general pictures. This experience was partially successful; all browsers and thin client ran jQuery except IE. If anyone knows the secret and can make this method work on IE, please unsubscribe. The actions must be done as follows:
1. Create a general picture and put any picture in it
2. On the html-layout in edit mode, select any text and select a common image through the Elements-Link menu
3. Insert the text from the link into the script block
4. Replace the overall image with JavaScript content
Built-in 1C framework for web client
Few people know that the 1C web client includes a framework that simplifies working with form elements. The framework runs on JavaScript. It can be accessed via parent.WebUI. its functions require more research, but the properties are as follows:In theory, this framework can be used to call 1C server procedures. In this case, the html field will be fully integrated with other elements of the managed form, which will entail platform independence. Now the feedback is achieved through the WebBrowser Control, which is tied to Windows.
Keyword __STYLE__
I puzzled for a long time about what the __STYLE__ keyword means, which 1C automatically substitutes into the empty html layout template. But query research showed that __STYLE__ is not replaced by anything, and the server returns a 500 error for this request: Internal Server Error.The interaction of javascript and the 1C interface provides great opportunities for implementing non-standard functions. Previously, it was possible to directly call JavaScript functions through the DOM object document The fields of an HTML document. This feature is gone in modern browsers. Moreover, the ExternalObject type appears in the web client, which is not described anywhere at all. At Infostart, there were suggestions to call JavaScript through fireEvent, but this is very inconvenient. I offer my solution.
How it all started
I was inspired to deal with the HTML field by a large number of tasks in which there was a need to implement interactive maps with monitoring, routing, etc. Since it is impossible to do this with built-in 1C tools, I used to use an ActiveX component of my own production. On normal forms, everything worked acceptable, except that the solution was not even close to open frameworks like OpenLayers. After the advent of managed forms, there was an attempt to embed the same ActiveX in an HTML document and place it in a field. The solution works, but in view of the tightening of Microsoft's security policy, it required changing the security settings on each client, which ultimately turned out to be unacceptable. That's when we set ourselves the task of attaching maps based on Web engines (Yandex.Maps, OpenLayers and other Tile-oriented engines) to managed forms.
Option 1: Works in thick client, works in thin client, does not work in web client
The essence of the method is to get the parentWindow property of the HTMLDocumentField form element. Looks like this:
&OnServerCreateProcedureOnServer(Failure, StandardProcessing) WebMapFormAttributeString = Processing.UNP_WEBMap.GetLayout("HTMLLayout").GetText(); EndProcedure &OnClient Procedure WebMapDocumentFormed(Element) Report(Elements.WebMap.Document.parentWindow.HelloWorld(ThisForm)); EndProcedure &OnClient Procedure WebMapJavascriptAction(Variable) Export Report(Variable); EndProcedure
All this works fine in the thick and thin client, but it will not work in the web client, because in the web client the HTMLDocumentField in the Document property does not have a parentWindow.
Option 2: Works in Thick Client, Thin Client, Web Client (Chrome, IE, Edge tested)
To implement this option, you need to slightly fix the HTML layout. Namely:
And small changes in the code of the form
&OnServerCreateProcedureOnServer(Failure, StandardProcessing) RepeatFiring = False; WebMapFormAttributeString = Processing.UNP_WEBMap.GetLayout("HTMLLayout").GetText(); EndProcedure &OnClient Procedure WebMapDocumentGenerated(Element) If Not RepeatedFiring Then // In some cases, when additional libraries are connected, //the event may fire again in an already loaded document ObjectBody = Undefined; Attempt ObjectBody = Elements.WebMap.Document.parentWindow.document.body; Exception EndTry; If Not ValueFilled(ObjectBody) Then Try ObjectBody = Elements.WebMap.Document.body; Exception EndTry; EndIf; If Not ValueFilled(ObjectBody) Then Report("Something went wrong"); Else Report(ObjectBody.HelloWorld(ThisForm)); EndIf; Retrigger = true; EndIf; EndProcedure &OnClient Procedure WebMapJavascriptAction(Variable) Export Report(Variable); EndProcedure
Thus, for the thick and thin client, we leave everything as it was, but for universality we use the DOM body object extended by us. In the web client, the HTMLDocument.DocumentField form element contains the ExternalObject type, which is actually the DOM COM implementation of the body element.
Theoretically, you can write a function in body that will return a reference to window, and then you can call global functions.
Hope it helps someone ;-)
During the implementation of one project, it became necessary to execute javascript (hereinafter referred to as JS) code under the control of the HTML Document Field object, with the result obtained in 1C. The examples given in the articles found did not seem very convenient to use (a purely personal opinion). It was decided to try to find another, simpler solution, no more than 1 day was allotted for the search.
DIV.setAttribute("onclick", "alert("Coordinates");");
Execute the script
DIV.click();
TA-DAH. everything is working
Procedure ExecuteScript(TextScript) DIV = Elements.doc.Document.getElementById("TEST"); DIV.setAttribute("onclick", TextScript); DIV.click(); EndProcedure
Update as of 08/02/2016
Another way to call JS was suggested in the comments (thanks), if you have the ability to change the HTML code of the document, then you can write a function in it and then call it. passing the JS code to it.
and then in 1C:
Elements.DocumentHTMLField1.Document.parentWindow.exec("alert("OK")");
Returning a JS result in 1C
To transfer the result of the script to 1C from the FieldHTMLDocument object, we will use an event. Let's bind an OnClick event to the HTMLDocument Field that receives 3 parameters as input:
- The element in which the event occurred (the Field of the HTMLDocument itself)
- event object
- Sign of the implementation of the standard behavior
To trigger an event on click, you need to execute the following js code
Varevt = document.createEventObject(); // create an empty event object evt.propertyName = "function1"; // I propose to put the name of the result in the propertyName prop (something like a type, or the name of the function from which the data was received) evt.data = "156"; //we will pass the result data to the data prop document.body.fireEvent("onclick", evt); // execute the event on clickHtmlDocumentField
After executing this js code in the procedure, when the second parameter is clicked, the event object we created will come. Which is pretty easy to handle.
Answer parsing example.
&OnClient // get the name and result of the event Procedure DocOnClick(Element, EventData, StandardProcessing) OperationName = EventData.Event.propertyName; OperationData = EventData.Event.data; If OperationName = "" Then //not our event Return; EndIf; If OperationName = "Function1" Then // process result ElseIf OperationName = "function2" Then // process result //...... EndIf; EndProcedure
This method gets rid of the use of wait handlers, and provides a convenient event identifier. By the identifier, we know exactly what data we received and how to parse it.
Additions from 03/26/2016
And in this place, too, misunderstandings occurred (the error is reproduced only on the platform 8.3.5.1570, but in order to prevent these situations in the future, I will give a solution) The very reason - when relaunching the form with the HTML field of the document at the time of the procedure call, when clicking on the HTML field, the platform call stuck and brought down the entire COM object (An exception occurred (htmlfile): Undefined error). The solution was to disable the standard execution of the click event, and disable the event bubbling mode. How to do this, see below.
// disable event bubbling
Evt.cancelBubble = true;
// disable default behavior
Evt.returnValue = false;
As a result, we will get a function to transfer data to 1s from JS.
Function return1c(name,data)( var evt = document.createEventObject(); evt.propertyName = name; evt.data = data; evt.cancelBubble = true; evt.returnValue = false; document.fireEvent("onclick",evt ); );
Conclusion.
By combining these methods, you can quite easily run the js code you need and receive data in 1C for further processing.
Implementation example in