Domanda

I used the below rest API to create a client side page from a template.

https://mytenant.sharepoint.com/sites/xxx/_api/web/getfilebyserverrelativeurl('/sites/xxx/SitePages/templates/MyTemplate.aspx')/copyto(strnewurl='/sites/xxx/SitePages/MyFolder/NewPage.aspx',boverwrite=false)

Problem: Assume John created the Template. Tim creates a page using the template, now the Author field is showing John but Editor is showing Tim. Ideally Tim has to be both Author and Editor. I tried passing digest value in header as well but no luck.

È stato utile?

Soluzione

@Vetrivelmurugan,

You can use below rest endpoint to update author/editor:

Post : /_api/Web/Lists(guid'b38f437d-468e-4598-b6b9-a29ded00f028')/Items(21)/ValidateUpdateListItem()

Body:

{
   "formValues":[
      {
         "FieldName":"Author",
         "FieldValue":"[{'Key':'i:0#.f|membership|ab@abc.onmicrosoft.com'}]"
      },
      {
         "FieldName":"Editor",
         "FieldValue":"[{'Key':'i:0#.f|membership|nc@abc.onmicrosoft.com'}]"
      }
   ],
   "bNewDocumentUpdate":false
}

Test: enter image description here

More reference:

Altri suggerimenti

This is expected behaviour. The author field can be set to any user but the created and modified fields are system fields which are always set to the user who created or edited the item when using the UI. The created or modified values can however be set programmatically.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top