Client script (cell edit) in List not working

suryan
Kilo Expert

Below is Client script wrote for type: on cell edit.

If old value is not 27(Delivered to client) and change to new state 27 then it should allow only if manager review met is 'Yes'. For testing purpose i add alerts after

  if (oldValue !=27),     if (newValue==27) and before var managerreview, script is not running after   if (newValue==27). I checked the field name it is correct. This is not working on list view.

function onCellEdit(sysIDs, table, oldValues, newValue, callback)

{

      var saveAndClose =false;

        for (var i = 0; i < oldValues.length; i++)

        {

                  var oldValue = oldValues[i];

        if (oldValue !=27)

        {    

                  if (newValue==27)

                  {

                            var managerreview = g_form.getDisplayValue('u_manager_review_met');

                            if (managerreview=='Yes')

                            {

                                      saveAndClose = true;

                            }

                  }

        }

}

        if(saveAndClose == false)

                  {

                            alert("This State change is Not Allowed.");

                  }

//Type appropriate comment here, and begin script below

callback(saveAndClose);

}

Thanks in   advance..

7 REPLIES 7

souren0071
Tera Expert

Hi Suryan,



May I know why do you need to check the oldvalues of state? The client script needs to be triggered only if anyone tries to change the state to 27 with a manger view yes. If these two conditions dont match it should show an alert.



Please let me know if my understating is correct.



Regards,


Souren


Hi,



I just checking if he tries to move to same state i dont want to run the code so am checking if(!oldstate). - its ok we can remove that code.


change the state to 27 - > get value from field if manager review is yes , if yes then allow to change which is saveandclose == true.


Runjay Patel
Giga Sage

Hi Suryan,



How are you using g_form in onCellEdit client script.



Its work on list view not on form view, resulting will not get value of field "u_manager_review_met".



Regards,


Runjay