Comprehensive use of JavaScript, LotusScript Agent and Formula Tips For the use of Designer Development B / S mode, JavaScript, LotusScript, and Formula are three development languages we mainly used. They have a strong advantage in their respective locations. 1. JavaScript can only access the data of the browser, and cannot access the Notes DOM; so, it is mainly used to use the data verification of the browser side, information prompt, etc. Operating the current BROWS window operation. 2. LotusScript can access Notes DOM. The data of the current document can be obtained at the Notes client, but because it cannot work directly in the browser; so LotusScript can only work on the server side in the application of the B / S mode. We have achieved power by writing a LotusScript agent. Document processing power. 3. Formula can access the background data, simple language, weak data processing, and cannot work on the browser. Formula primarily uses the display control of the element and the calculation formula of the domain value and simple data processing. These three ranges and processing capabilities are different. In the application, it integrates the three, which will greatly enhance the functions of the application. B. JavaScript communication to the agent (LS / FL) communication, JavaScript communication to the agent, using the URL Command. That is, the following format: http: // host / database / agentname? OpenAgent & parameters. Such operations can be used to solve tasks such as data queries, document deletions. This type of operation is characterized by parameters, but the current document of the browser is not removed, and the browser-ended document cannot be processed. So why do you want to communicate with JavaScript to proxy, and let the agent get the current document of the browser? First look at one example: In an application system, the user creates a new application can do this: Open the new application form, after filling each item, click the action button "Submit Application" to complete the operation. The designer triggers the "submission" operation must run a proxy or a formula (here we first assume that the submission operation is a proxy, which will introduce the submission operation formula). Before the "submission" that truly runs the agent, the system must perform verification of data legitimacy. The simplest approach is to write to the verification formula in each domain, or write the code that verifies the legitimacy of the data in the proxy. However, the common disadvantage of such practices is that even if the data is illegal, the server-side and browser ends have interactive, occupying bandwidth, affecting network speed. Also, the error message can only be output on the original window in the form of a web page. In this way, the information in the original window will be lost, which is not convenient for users to modify the original data. In response to this situation, we want to make the domain verification work in the browser. And, the error prompts use the pop-up window. JavaScript is in line with the requirements, but the difficult point is: Once verified how to call the agent? The solution is: 1. Keep the "Submit Application" operation button and submit agency. On the browser-side preview sheet, click Right click to view the source file to find the code in the OnClick event of the "Submit Application" operation button. 2. Newly built a "Submit Application" operation button, hide the original "Submit Application" button. Write a domain verification information JavaScript code in the newly created operation button, if verified, execute the first step. If you do not pass, use the Alert pop-up window to prompt the error message. 3. Note: Each additional operation button will affect the ONCLICK event code for the original "Submit Application" operation button. Therefore, a better way is to make the original "submit application" operation button to shared operation.
The above approach is the method we used in the workflow mode. Now we have an improvement method: 1. Without the original operation button, write the trigger submit agent in a button (Button), give this button (assuming "B1", find the HTML tab "Name" column in its property box "B1" ), Hide this button with CSS. (Similarly to the TML tab, fill in "Visibility: Hidden") 2 in the "style" field. Create a new operation button named "Submit Application", write the domain verification information JavaScript code in the button, if the verification is passed, "Document.Forms [0] .b1.onclick ()" (B1 here is the previous step We assume button name). If you do not pass, use the Alert pop-up window to prompt the error message. 3. Note If there are multiple such operations in the same form, the button's NAME must be different. The call to the button will also be clearly based on its Name. Throughout the two methods of calling the agency by JavaScript, each has its own characteristics. It is more convenient to use URLCommand, but the disadvantage is that the current documentation of the browser is not removed, and many powerful functions cannot be expanded. Using the second method, actually JavaScript is indirectly adjusted by calling the operation button. This method is powerful, but creation and maintenance is slightly complicated. Finally, it is pointed out that the so-called use of JavaScript calls formula, that is, refers to the JavaScript call operation button, and the operation button is executed in Formula to operate in the document. That is, the formula is indirectly adjusted with JavaScript. Three by the agent to communicate to JavaScript communication to JavaScript, can be divided into a JavaScript program with a proxy and a proxy setting JavaScript parameter. [One] Write the JavaScript program with the agent. We can use the Print system function in the proxy to print information on the window. This information is explained for the browser to explain the HTML statement. This way we can use the Print function to write a JavaScript program in the agent. For example, the following code segment: if dc.count = 0 THEN 'DC uses Database.search "