none
Project Server 2013: Timesheet Data Entry Custom Validation RRS feed

Answers

  • From the few posts/articles that I was able to piece the script below which performs the custom validation (routine checks for 8 hour or less and increments of half hours). 

    A major part of the solution was derived from the following post:  http://social.msdn.microsoft.com/Forums/en-US/ab657a54-df01-46c6-9ad1-3ab1cd9b48f1/problem-with-pjaddgridsatelliteinitializationnotifier-on-project-server-2013?forum=project2010custprog

    My java experience is a bit limited so I am open to improvement suggestions:

    var val;
    
    _spBodyOnLoadFunctionNames.push("TimesheetMain");
    
    function TimesheetMain() {
        val = new EdwPSCustomValidation;
    }
    
    function EdwPSCustomValidation() {
    
        SP.SOD.executeOrDelayUntilScriptLoaded(function () {
    
            if (window.PJ == null || typeof JsApi == 'undefined') {
                return;
            }
            JsApi.ExtensibilityManager.AddListener("PJ", function (api, isInited) {
                if (isInited == true && api.get_ApiType() == 44) {
                    API_TSG = api.get_impl();
                    gridControl = api.get_impl()._jsGridControl;
    
                    var existingValidateFunc = PJ.RemoteTextConv.GetPostprocessor(PJ.ConversionType.Work);
                    PJ.RemoteTextConv.RegisterPostprocessor(PJ.ConversionType.Work, EdwPSCustomProcessor);
    
                    function EdwPSCustomProcessor(convType, fieldKey, newValue, bIsLocalized, formatType, textConvConfigs, result) {
    
                        if (existingValidateFunc != null) {
                            result = existingValidateFunc(convType, fieldKey, newValue, bIsLocalized, formatType, textConvConfigs, result);
                        }
                        if (result.isValid) {
                            if (result.dataValue > 480000) {
                                result.isValid = false;
                                result.errorMsg = "Actual Hours for a day may not exceed 8";
                            }
                            if (result.isValid) {
                                if (result.dataValue % 30000 > 0) {
                                    result.isValid = false;
                                    result.errorMsg = "Actual Hours must be in 0.5 hour increments";
                                }
                            }
                        }
                        return result;
                    }
                }
            })
        }, "sp.ribbon.js");
    
    }

    • Marked as answer by Mike Agnello Friday, November 15, 2013 12:52 PM
    Friday, November 15, 2013 12:49 PM