0

Goal : Prevent user from inputting duplicate information through Datasheet view.

To add some context, duplicate information was being inputted into a library list. To resolve the issue, I created a javascript file that was attached to the New Item Form, so that whenever a new item was created the file would check the library list to see if that information already exists and prevents the user from submitting the new item if so. However, it turns out the users are inputting new information through a editable Datasheet view rather then through the New Item Form.

So is there anyway to verify the information being inputted through a Datasheet view?

Edit (More info): The list takes information from 2 fields (That cannot be unique) and creates a calculated field (which needs to be unique). Calculated fields don't have that column setting option (Unless there is...?)

1
  • 1
    Can you not just enable "enforce unique values" for the columns you don't want duplicate information for? SharePoint will enforce that in datasheet/quick edit view. Aug 20 '20 at 14:49
0

Just like Dylan said, if you set the column to enforce unique value, then users will not be able to input duplicate values in that column in DataSheet view. enter image description here

enter image description here

0

If for some reason Jerry's answer isn't suitable and your logic needs code then you can implement grid event handlers using JSLink on the grid webpart:

https://docs.microsoft.com/en-us/previous-versions/office/hh323843(v=office.14)

Example for OnEntryRecordAdded from above:

<script type="text/javascript">
    Type.registerNamespace("GridManager");

    GridManager = function () {
        this.Init = function (jsGridControl, initialData, props) {
            control = jsGridControl;
            var dataSource = new SP.JsGrid.StaticDataSource(initialData);
            var jsGridParams = dataSource.InitJsGridParams();

            // This event is triggered Occurs when a new entry record appears on the grid.
            jsGridControl.AttachEvent(SP.JsGrid.EventType. OnEntryRecordAdded, GotHere);

            jsGridControl.Init(jsGridParams);
        }
    };
    function GotHere(obj) {
        alert('Got Here, ' + obj. recordKey);

    }
</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.