We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

in oncell edit client script old value showing like unidentified when i change state

mchandra
Tera Contributor

Hi Team,

 

i want to auto pop new value and old value when user change state from list view, i have written below script. but it is showing only new value, old value showing like undefined.

 

please give solution if anyone know.

 

client script - Oncell Edit

field - state

 

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

 

    var stateMap = {

        "1": "New",

        "2": "In Progress",

        "3": "On Hold",

        "6": "Resolved",

        "7": "Closed"

    };

 

    var oldValue = oldValues[sysIDs[0]];

 

    var oldDisplay = stateMap[oldValue] || oldValue;

    var newDisplay = stateMap[newValue] || newValue;

 

    var message = "You are changing State\n\n" +

        "Old Value: " + oldDisplay + "\n" +

        "New Value: " + newDisplay + "\n\n" +

        "Do you want to proceed?";

 

    if (confirm(message)) {

        callback(true);

    } else {

        callback(false);

    }

}

1 ACCEPTED SOLUTION

Laveena-Agarwal
Mega Sage

Hi @mchandra 

 

Replace var oldValue = oldValues[sysIDs[0]]; with var oldValue = oldValues[0]; , it works like a butter 🙂

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

 //Type appropriate comment here, and begin script below
   var saveAndClose = true;
 alert(sysIDs)

    var stateMap = {

        "1": "New",

        "2": "In Progress",

        "3": "On Hold",

        "6": "Resolved",

        "7": "Closed"

    };

 

    var oldValue = oldValues[0]; // fix this

 

    var oldDisplay = stateMap[oldValue] || oldValue;

    var newDisplay = stateMap[newValue] || newValue;

 

    var message = "You are changing State\n\n" +

        "Old Value: " + oldDisplay + "\n" +

        "New Value: " + newDisplay + "\n\n" +

        "Do you want to proceed?";

 

    if (confirm(message)) {
		   saveAndClose = true;

        

    } else {
 saveAndClose = false;
        

    }
callback(saveAndClose); 
}

 

 

View solution in original post

2 REPLIES 2

Laveena-Agarwal
Mega Sage

Hi @mchandra 

 

Replace var oldValue = oldValues[sysIDs[0]]; with var oldValue = oldValues[0]; , it works like a butter 🙂

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

 //Type appropriate comment here, and begin script below
   var saveAndClose = true;
 alert(sysIDs)

    var stateMap = {

        "1": "New",

        "2": "In Progress",

        "3": "On Hold",

        "6": "Resolved",

        "7": "Closed"

    };

 

    var oldValue = oldValues[0]; // fix this

 

    var oldDisplay = stateMap[oldValue] || oldValue;

    var newDisplay = stateMap[newValue] || newValue;

 

    var message = "You are changing State\n\n" +

        "Old Value: " + oldDisplay + "\n" +

        "New Value: " + newDisplay + "\n\n" +

        "Do you want to proceed?";

 

    if (confirm(message)) {
		   saveAndClose = true;

        

    } else {
 saveAndClose = false;
        

    }
callback(saveAndClose); 
}

 

 

Thanks @Laveena-Agarwal  its working!!!!!