This topic contains 1 reply, has 0 voices, and was last updated by k_dunc 7 years, 11 months ago.

  • Author
    Posts
  • #6157 Score: 0

    Charles Li
    • Contributions: 0
    • Level 1

    Hi,

    I am making a search with script and below is a client code. i want to search the pending leave number. if the number is not ‘0’ or null value, then alert the string. but the number is always ‘ ‘(‘ ‘ is null but there is nothing in the ”). No matter if there is pending leave in system.

    function checkLeaveStatus(){

    //alert(1);

    if(nlapiGetFieldValue(‘custrecord325’)==1){

    var Employee=nlapiGetFieldValue(‘custrecord324’);

    var filter=new Array();

    filter[0]=new nlobjSearchFilter(“isinactive”, null, “is”, “F”);

    filter[1]=new nlobjSearchFilter(‘custrecord344′,null,’is’,’2′);

    filter[2]=new nlobjSearchFilter(‘custrecord324′,null,’is’,Employ ee);

    filter[3]=new nlobjSearchFilter(‘custrecord326′,null,’onorafter’ ,’thisyear’);

    filter[4]=new nlobjSearchFilter(‘department’,’User’,’noneof’,’5′ );

    filter[5]=new nlobjSearchFilter(‘custrecord325′,null,’is’,’1′);

    var g = new Array();

    g[0] = new nlobjSearchColumn(“custrecord327”,null,’sum’);

    var pendingLeave=nlapiSearchRecord(‘customrecord310’,n ull,filter,g);

    var pendingLeaveNum=pendingLeave[0].getValue(g[0]);

    // nlapiLogExecution(“DEBUG”, “pendingLeave”,pendingLeaveNum);

    //alert(pendingLeaveNum);

    if (pendingLeaveNum==null||pendingLeaveNum==”) {

    return true;

    }

    else {

    alert(‘You have pending Annual leave application. Please talk to your line-manager to get the previous application approved.’);

    return false;

    }

    }

    }
    This is a cached copy. Click here to see the original post.

  • #6158 Score: 0

    k_dunc
    • Contributions: 0
    • Level 1

    Should you be checking if pendingLeave actually has any results? If so, does it?


    Charles Li replied on 09/23/2016, 02:43 AM: I have found the problem.

    filter[3]=new nlobjSearchFilter(‘custrecord326′,null,’onorafter’ ,’thisyear’);

    the problem is that the value ‘thisyear’ is a range. So i can’t use ‘onorafter’, for this year, 2016, is not a point in time. I should use within.

    thank you Kirk.

You must be logged in to reply to this topic.