Search code examples
jqueryfunctionparametersodata

Jquery issues with string as parameter


I have a jquery code where I am calling a string as parameter and using it in side the function. but it is taking parameter as integer.

function CheckIsApplicable(MsNo) {
            var queryUrl = 'GroupEntity?$filter=(MSNumber eq ' +  MsNo + ')';
    }

MsNo is a string and the way the odata url considers it is a integer. It throws a bad request error if I call this function. How can I call a string in the filter? I tried '"+ MsNo +"' and it failed. Any suggestions?


Solution

  • try this

    MsNo.toString();
    

    here:

    function CheckIsApplicable(MsNo) {
            var queryUrl = "GroupEntity?$filter=(MSNumber eq '" + MsNo.toString() + "')"; 
        }