Function to check the variable has value or not

     Define the below mentioned function for check the variable has value or not. If variable has value, the function will return true. Otherwise, it will return false.

function checkForParameter(parameter) {

  if (parameter! == “” && parameter! == null && parameter! == undefined && parameter! == false && parameter! == “null” && parameter! == “undefined” && parameter! == ” ” && parameter! == ‘false’) {

                                                 return true;

} else {

  return false;

}

}

sgstAmount is the variable. Function is checking variable has a value or not. If sgstAmount has value, it will enter to function and perform the operation. Otherwise, it will skip the function. For example,

Var sgstAmount = customRec.getvalue({

                   fieldId: ‘total’,
                   id: ‘id’
})

if(checkForParameter(sgstAmount)){
    totSgst=totSgst+sgstAmount;
    log.debug(“totSgst”, totSgst)

}

Leave a comment

Your email address will not be published. Required fields are marked *