DavidLozzi / SharePoint-HideDisableFields

Lightweight JavaScript file to easily hide or disable fields on a SharePoint classic list form
MIT License
9 stars 4 forks source link

Add some simple comparison formulas #5

Open sharvancik opened 4 years ago

sharvancik commented 4 years ago

Is your feature request related to a problem? Please describe. Having the ability to compare two string fields on the screen to then make an action would be nice if those comparisons where a function that return true/false. Right now I have to code each comparison, example:

    selectedValue = $("h3:contains('Request Phase')").closest('tr').find('select').val();
    requestOpen = $("h3:contains('RequestOpen')").closest('tr').find('select').val();
    if (((selectedValue == 'Approved') || (selectedValue == 'Denied') || (selectedValue == 'Canceled'))) {
        Lozzi.Fields.disable("Request Phase");

Or checking to see of a downdown has changed:

    //on change of dropdown of Is this Critical we will call this
    $("h3:contains('Is this Critical')").closest('tr').find('select').change(function () {
        showHideRows();
    });

Describe the solution you'd like Well, this is a lot harder. In general, one compares two values and based on the results an action needs to happen. some examples might be:

Describe alternatives you've considered Code it as I had shown above.

Additional context

DavidLozzi commented 4 years ago

This is a good idea, though might be very large to implement. I'll think it through some. In the meantime, you should be able to use var theCell = Lozzi.Fields.getCell(fieldName) to get the cell, then something like theCell.find("input,select,textarea,img") to get the control with the value in it.