Discussion from Liang Ming with Microsoft Expert
How to make users can't make a deduplication of data by adding or modifying the WSS List to make some specified fields. And need to meet the following requirements as much as possible:
1) I hope the solution is relatively simple, and it is easy to deploy (the customer wants to complete the deployment within 30 minutes)
2) I hope that no need to recompile any project during deployment.
3) Have a certain versatility, can not develop a component for a specific LIST
-------------------------------------------------- ------------- The results of the current study:
Research results and solutions (as an example of new record)
==================
System implementation ideas
=======
Since the steps involved involve modifying the WSS default template and JavaScript code, do the following steps in the test environment and back up the relevant information.
1. When the user has created a new record, the WSS will first call the ClickOnce () function (please click on the new record page, view the HTML source file), however, Clickonce () does not exist in the NewForm.aspx file, but Schema.xml of the List template (eg, we use the Customized List, the path to the list template is C: / Program Files / Common files / Microsoft Shared / Web Server Extensions / 60 / Template / 1033 / STS / LISTS / CUSTLIST) and all WSS LIST will call the ows.js file, reference to the JavaScript. The form will be submitted to /_vti_bin/owssvr.dll, and finally inserted into the database. This is the default form submission process.
2. In order to add a custom code during the period, check whether duplicate data is generated. We can take the following communication methods:
a) Intercept the ClickOnce () function in Schema.xml, send POST requests to the ASPX page of the Server end using the Microsoft.xmlhtttttttTP object, and receives the return data of the Server side, and Schema.xml's scope is a specific list. In this example, we choose this way
b) Due to the process of submitting the form, the ClickOnce () function defined in Schema.xml ultimately calls the block segments in OWS.JS, though we can intercept the default submission process in the relevant functions of OWS.JS, and Send a request to the Server end, but we do not recommend this way because modifying OWS.JS may affect multiple LISTs. This global approach is only used under certain conditions and I hope you have a comprehensive test.
c) The first two ways are to send a request to the server to the server, verify, if you need to all postback back to the server, use FrontPage 2003, open NewForm.aspx, right click on WebPart, and select "Customized The SharePoint List Form menu item, convert the webpart to Table mode, as shown below: At this point we can use the traditional ASP.NET form, add a custom input field and submit button above, and you can submit Specific background page. This approach needs to be processed separately for NEWFORM.ASPX for each List.
3. The server side is an ASP.NET page that will receive ListID (List's Guid) and FieldValue (requires field fills), and the ASP.NET page reads an XML configuration file and is used to determine if the ListId is used. This list is required (a universal solution for multiple LIST). If you need to verify, read information such as field names that you need to verify from the XML configuration, and check. Regardless of the success or whether the ASP.NET page will return to the client.
4. The client's Microsoft.xmlhttp object obtains the necessary resolution after the string is written, and determines the corresponding process.
Specific implementation steps
=======
1. In this sample, the Customized List template will be used as an example. Copy the CustList directory in the C: / Program Files / Common files / 50 / Template / 1033 / STSOTIONS / 60 / TEMPLATE / 1033 / STS / LISTS directory, and named Liangming
2. Open the ont.xml in the XML directory (C: / Program Files / Common Files / Microsoft Shared / Web Server Extensions / 60 / Template / 1033 / STS / XML) in the upper directory, and find the
4. In the new list page (any of the modifications to the List template, you must have a new list to see the result) We will find a lingming List template
5. Open Schema.xml under the List template directory, add the following code:
Function checkfield ()
{
Var FldValue;
For (i = 0; i { / / Find the value of a specific field (the value you need to check), use the title attribute here, can be modified according to the actual situation IF (frm.form.eferences [i] .title == "Employee ID") { FLDVALUE = frm.form.Elements [i] .value; Break; } } // Default List's GUID stores in the Hidden's OneTidioHidden field Var lstid = document.getElementByid ("OnetidioHidden"); // Send a request to the server using Microsoft.xmlhttp VAR XMLHTTP = New ActiveXObject ("Microsoft.xmlhttp"); Xmlhttp.Open ("post", "/ _ layouts / checkfield / docheck.aspx? listid =" lstid.value "& FieldValue =" FLDVALUE, FALSE); Xmlhttp.send (); // Get return information Var resp = new string (xmlhttp.responsext); // If the return information contains a label that represents an error, change the program process. IF (Resp.indexof (" Error>")> 0) Return False; Else Return True; } Function Clickonce () { / / Open the debug option after clicking the save button, only for debugging / / Please note this line in the official environment. Debugger; //verification failed IF (! Checkfield ()) { Alert ("Please check the duplicated data); Return; } SetAction (); IF (! g_msclicked) ...... 6. Call IISRESET in the Command window to restart the IIS service. And create a new list, add the Employee ID field (consistent with the field name acquired in JavaScript), view the source program in the NewForm.aspx page, check if there is the above code? If the above steps are not successful, please contact me in time. 7. Deploy the server-side program to the C: / Program Files / Common Files / Microsoft Shared / Web Server Extensions / 60 / Template / LayoutS directory (corresponding / _Layouts / virtual directory) and establish an application. Access the getListGuid.aspx page, get the GUID of a specific List, configure the listconfig.xml file according to the sample code. In the browser incoming the listID and fieldValue values, test whether the ASP.NET page is working properly. 8. The server page needs to get some objects in SharePoint, and there may be permission issues, please refer to the permissions in SharePoint SDK (Impersonate) method, and implement it. Please see the sample code for details. 9. Browse New Record page, test, and activate the client Debug of IE, track JavaScript execution Supplementary documentation ======= Http://msdn.microsoft.com/library/default.asp?url=/library/en-us/spsdk11/caml_schema/spxmlcononet.asp onet.xml Http://msdn.microsoft.com/library/en-us/spsdk11/caml_schema/spxmlconexample8.asp?frame =true example 8 - Creating a new template for custom lists Http://msdn.microsoft.com/library/en-us/spptsdk/html/tsptdoclibevents.asp?frame=true impersonate Source Code document list ======= Server ASP.NET Project 1. Docheck.aspx check Record 2. GetListGuid.aspx Displays the GUID of the List, help set the configuration file 3. ListConfig.xml configuration file Client 1. Schema.xml has been modified by a modified list template file 2. Liangming folder, customized list template (C: / Program Files / Common files / Microsoft Shared / Web Server Extensions / 60 / Template / 1033 / STS / LISTS / LIANGMING) 3. Ont.xml List Template Profile C: / Program Files / Common Files / Microsoft Shared / Web Server Extensions / 60 / Template / 1033 / STS / XML 4. Process.vsd Schematic of the above flow The test results are shown below =========== a) b) Add the first record screenshot (Employee ID is a non-repeatable field): c) Try to add a record with the EMPLOYEE ID list>