sc.check.calendar RAD

Hello,

Has anyone ever used the sc.check.calendar RAD app to check if a particular ticket is within business hours?

Is there any other way to check if a certain date/time is within the business hours of a certain calendar?

Thank you in advance.

  • While I have not personally used that RAD application to validate that a date is within the business hours specified by a caldutyhours record that is exactly what the application is designed to do.

    You pass in the caldutyhours record, the date and it will return true/false in the 'Flag' variable.

    Let me know where you want to use this, for example in JS and I can help with you the calling syntax.

    Steve H.

     

  • Hello vvim,

    Indeed you can use sc.check.calendar RAD to confirm if a date is valid within the calendar hours defined on the record for the caldutyhours table.

    In order to test it you can use this as example:

    1- Select any display screen you prefer and add a new display option (For example I used sd.view). I called display option Test Date.

    2- Under RAD tab, please add:

    RAD Application => sc.check.calendar

    Separate Thread => false

    Names:

    name

    time1

    boolean1

    Values:

    $mycalendar  

    $mytime

    $L.isdatevalid

    --- Note: I tested using variables, however if you want to reference any field in the current record use: datetimefield in $L.file to replace any variable except $L.isdatevalid which controls the logic to display a message

    Now, under Post Javascript tab add:

    if(vars.$L_isdatevalid)

    print("Valid date");

    else

    print("Invalid date");

    Save changes.

    Finally access any record that will take you to the format you added the display option. The logic will tell you if date is valid or not. What is key as you can tell is $L_isdatevalid which contents is date is valid (true) or invalid(false).

    Hope this helps.

  • In firs time, thank you very much to you both for your answers.

    JD_Jinesta's option that has given me works perfectly!!!

    But I need to ask from a javascript. I'm testing various functions, but can't work... always gives me "Invalid date".

    function Calendar(calendar){
    
        var rteReturnValue = new SCDatum();
        var rteNames = new SCDatum();
        var rteVals = new SCDatum();
        var date = system.functions.tod();
        var valid = vars.$L_isdatevalid;
        
        rteNames.setType(8);
        rteVals.setType(8);
        
        rteNames.push("name");
        rteNames.push("time1");
        rteNames.push("boolean1");
        
        rteVals.push(calendar);
        rteVals.push(date);
        rteVals.push(valid);
        
        system.functions.rtecall("callrad",rteReturnValue,"sc.check.calendar",rteNames,rteVals,false);
        
        //print(valid);
        
        if (valid)
            print("Valid date");
        else
            print("Invalid date");
        
    }

    What am I getting wrong? Please, can you help me?

    Thanks in advance,

    Regards,

     

  • Hi vvim,

    Please try for line 7

    var valid = "$L.isdatevalid";

    instead of

    var valid = vars.$L_isdatevalid;

    I just tested it and got "Valid date" message.

    Regards,

  • Hi JD_Jinesta,

    Thanks for your answer.

    I made the change you tell me, but now always shows "Valid date" message, and it isn't correct. Depend the calendar is valid date or invalid date.

    Regards,

  • Hi vvim,

    You are correct. From what I see it looks like $OUT.FLAG variable might not be working as expected when is called from JS. I'll try to do a little bit more of investigation and let you know my findings.

    Regards,

  • Verified Answer

    Hi vvim,

    I got help from Steve H. and this is the appropriate code:

    function Calendar(calendar){

        var date = system.functions.tod();
        var date = vars.$G_mydate;
        vars.$L_isdatevalid = 'false';
        var flag = vars.$L_isdatevalid;

     var argNames = new SCDatum();
     var argVals = new SCDatum();
     var argTypes = new SCDatum();
     var results = new SCDatum();
       
     argNames.setType(8);
     argVals.setType(8);     
     argTypes.setType(8);
     results.setType(8);

     argNames.push("name");  //calendar name
     argVals.push(calendar);
     argTypes.push(2);

     argNames.push("time1"); //date time
     argVals.push(date);
     argTypes.push(3); 
     
     argNames.push("boolean1"); //return
     argVals.push(flag);
     argTypes.push(4);   
      

     results.push("boolean1");  //object file
     
     var radResults = lib.RAD.run("sc.check.calendar", argNames, argVals, argTypes, results);

     var valid = system.functions.val(radResults.results[0], 4);
     
     if ( valid )
            print("Valid date");
        else
            print("Invalid date");
     
    }

    Hope this helps finally :)

     

  • Perfect!!

    Thank you so much JD_Jinesta, this function works correctly. It's what I was looking for.

    Regards,