Data | Repeating SharePoint How to make it impossible for a user to add or modify a list of WSS to have duplicate data in a specified field. And to meet the following requirements as much as possible:
1 hope the solution is simple and easy to deploy (customers want to complete the deployment within 30 minutes)
2 You do not need to recompile any projects during deployment
3 has a certain versatility, cannot develop a component for a specific list
---------------------------------------------------------------
The results of the current study:
Research results and Solutions (take a new record for example)
==================
System Realization Thought
=======
Because the steps involved involve modifying the WSS default template and JavaScript code, complete the following steps in the test environment and back up the relevant information.
1. When the user creates a new record and submits the form, WSS calls the ClickOnce () function First (click on the new record page to view the HTML source file), however, ClickOnce () Does not exist in the NewForm.aspx file, but in the schema.xml of the corresponding List template (for example, the path we use customized list,list template is C:\Program files\common Files\ Microsoft Shared\Web server Extensions\60\template\1033\sts\lists\custlist) and all WSS list invokes the Ows.js file, referencing the JavaScript in it. The form is submitted to the/_vti_bin/owssvr.dll and the database is eventually inserted. This is the default form submission process.
2. To add custom code during the period, check to see if duplicate data is generated. We can use the following kinds of communication methods:
A to intercept the ClickOnce () function in Schema.xml, Use the Microsoft.XMLHTTP object to send a POST request to an ASPX page on the server side and receive the return data from the server side, where the schema.xml scope is a specific list. In this example, we use this method
b Because of the SCHEMA in the process of submitting the form. ClickOnce () defined in XML The function will eventually call the program segment in Ows.js, although we can intercept the default commit process in the relevant functions of ows.js and send the request to the server side, but we do not recommend this approach because modifying ows.js may affect multiple lists. This global approach is used only under certain conditions, and you are expected to conduct a comprehensive test.
c The first two ways is to send a request to the server on the client, for verification, if you need all postback back to the servers for authentication, please use FrontPage 2003, open NewForm.aspx, right-click on the input webpart, and select Customized the SharePoint List form menu item to convert the Input WebPart to table mode, as follows:
At this point we can use the traditional asp.net form to add the custom input field and submit button above, and can submit to a specific background page. This approach needs to be handled separately for each list's newform.aspx.
3. The server side is a asp.net page that will receive Listid (the GUID of the list) and fieldvalue (requiring field padding values), and the ASP.net page will read an XML configuration file and compare it to Listid to determine whether this list needs to be validated (for multiple list Common solution). If validation is required, information such as the field name that needs to be validated is read from the XML configuration and queried. Whether successful or not, the ASP.net page writes back The return information to the client.
4. The client's Microsoft.XMLHTTP object obtains the writeback string and makes the necessary parsing and determines the corresponding process.
Concrete implementation Steps
=======
1. In this sample, the customized list template is used as an example, in C:\Program Files\Common Files\Microsoft Shared\Web server Extensions\60\template\1033\ Copy the Custlist directory in the sts\lists directory and name the bit liangming
2. Open the XML directory under the upper directory (C:\Program files\common Files\Microsoft Shared\Web server Extensions\60\template\1033\sts\ XML) and locate the <ListTemplates> fragment, insert the following black Italic section, set the type to less than 1000, and have no duplicate values for the Type field of the current list, and keep the information for the name field and the ONET.xml directory name.
<ListTemplates>
<listtemplate name= "custlist" displayname= "Custom List" type= "0" basetype= "TRUE" onquicklaunch= "One" description= "Create a custom list when you want to specify your own columns." The list opens as a Web page and lets you add or edit items one in a time. Image= "/_layouts/images/itgen.gif" ></ListTemplate>
<listtemplate name= "liangming" displayname= "Liang Ming customized List" type= "basetype=" 0 "onquicklaunch=" TRUE "Securitybits=" description= "LIANG MING" image= "/_layouts/images/itgen.gif" ></ListTemplate>
3. To restart the IIS service by calling IISReset in a command window
4. In the new list page (any changes to the list template, you must create a new list to see the results) we'll find a liangming list template.
5. Open the Schema.xml in the list template directory and add the following code:
function CheckField ()
{
var Fldvalue;
for (i=0;i<frm.form.elements.length;i++)
{
Find the value of a specific field (the value that needs to be checked), and use the Title property here to modify the
if (Frm.form.elements[i].title = = "Employee ID") {
Fldvalue = Frm.form.elements[i].value;
Break
}
}
The default list GUID is stored in the Hidden onetidiohidden field
var Lstid = document.getElementById ("Onetidiohidden");
To send a request to a server-side page 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.responsetext);
Changes the program flow if the return information contains a label that represents the error
if (Resp.indexof ("</ERROR>") > 0)
return FAL