Skip to content

Instantly share code, notes, and snippets.

@AsishP
Created April 12, 2018 11:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AsishP/4085193b61834ffa8ecf38796a617171 to your computer and use it in GitHub Desktop.
Save AsishP/4085193b61834ffa8ecf38796a617171 to your computer and use it in GitHub Desktop.
private async updatePageProperties(fileid: number, submitstatus: string, promotedstate: number)
{
var datePublished = new Date();
var currentUserId = await pnp.sp.web.currentUser.select("Id").get();
await pnp.sp.web.lists.getByTitle("Site Pages").items.getById(fileid).update({
PromotedState: promotedstate,
News_x0020_Status: submitstatus,
FirstPublishedDate: submitstatus.toLowerCase() == "published" ? datePublished.toISOString() : null,
ApprovedById : submitstatus.toLowerCase() == "published" ? currentUserId.Id : null
}).then((iar: ItemUpdateResult) => {
console.log(iar);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment