1

I have SharePoint list hosted in SharePoint online.

I need to change the display format for the modified filed to standard from friendly using CSOM code. I am able to do it through UI.

Below is the code snippet I used to change:

                   Field f = splist.Fields.GetByTitle("Modified");
                    FieldDateTime field = ctx.CastTo <FieldDateTime> (f);
                    // FieldDateTime dateTime = 
                    field.DisplayFormat = DateTimeFieldFormatType.DateTime;
                    field.Update();
                    splist.Update();
                    ctx.ExecuteQuery(); 

Any help appreciated.

0

You need to set the FriendlyDisplayFormat of the field as below:

Field f = splist.Fields.GetByTitle("Modified");
FieldDateTime field = ctx.CastTo <FieldDateTime> (f);
// FieldDateTime dateTime = 
//field.DisplayFormat = DateTimeFieldFormatType.DateTime;
field.FriendlyDisplayFormat = DateTimeFieldFriendlyFormatType.Disabled;
field.Update();
splist.Update();
ctx.ExecuteQuery(); 

Reference - DateTimeFieldFriendlyFormatType

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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