0

Using CSR I am able to set value of date field, but for time field it's not working. following code works for date field without time:

ctx.CurrentFieldValue = "01/01/2015";
return SPFieldDateTime_Edit(ctx);

but for datetime field with "Date & Time" I do not know in which format I should pass the date time value:

I think there I am passing time value in a wrong format 01/01/2015 01 AM 05 - not working 01/01/2015 10PM 05 - not working

ctx.CurrentFieldValue = "01/01/2015 01 AM 05";
return SPFieldDateTime_Edit(ctx);

what is the correct format?

enter image description here

1 Answer 1

0

If you had the 24h Time Format not 12h Time Format then correct string format will be: "01/01/2015 15:35"

The best way to now how format you must use, its check how SharePoint save those value. You can do this use the code:

var TestJSLinkRendering= TestJSLinkRendering || {};    
TestJSLinkRendering.CustomizeFieldRendering = function () {
        var ctx = {};
        ctx.Templates = {};
        ctx.Templates.Fields = {
            'Internal Name Date Time Field':{
                'EditForm': TestJSLinkRendering.TEST
            }
        };
        SPClientTemplates.TemplateManager.RegisterTemplateOverrides(ctx);
    };

    TestJSLinkRendering.TEST = function(ctx){
        console.log(ctx.CurrentFieldValue);
        var fieldType = ctx.CurrentFieldSchema.FieldType;
       var defaultTemplates = SPClientTemplates._defaultTemplates.Fields.default.all.all;
       return defaultTemplates[fieldType]["EditForm"](ctx);
    }

    TestJSLinkRendering.CustomizeFieldRendering();

And use the same format.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.