This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "schema.json", | |
"actions": [ | |
{ | |
"verb": "triggerFlow", | |
"url": "[paste the workflow trigger URL here from Flow]", | |
"name": "Apply Template", | |
"parameters": { | |
"param1":"", | |
"param2":"" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// parse query parameter | |
string siteURL = req.GetQueryNameValuePairs() | |
.FirstOrDefault(q => string.Compare(q.Key, "siteURL", true) == 0) | |
.Value; | |
string pageName = req.GetQueryNameValuePairs() | |
.FirstOrDefault(q => string.Compare(q.Key, "pageName", true) == 0) | |
.Value; | |
// Get request body |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var functionUrl : string = "https://[functionName].azurewebsites.net/api/[FunctionMethod]?code=[codeValue]" | |
const requestHeaders: Headers = new Headers(); | |
requestHeaders.append("Content-type", "application/json"); | |
requestHeaders.append("Cache-Control", "no-cache"); | |
const postOptions : RequestInit = { | |
headers: requestHeaders, | |
body: `{\r\n siteURL: '${siteUrl}',\r\n pageName: '${pageName}' \r\n}`, | |
method: "POST" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var id = await pnp.sp.web.lists.getByTitle("Site Pages").items.filter("FileLeafRef+eq+\'" + pageName + "\'").select("Id").get(); | |
console.log("Calling update Page properties called for - " + id[0].Id); | |
if(id.length > 0) | |
{ | |
await pnp.sp.web.lists.getByTitle("Site Pages").items.getById(id[0].Id).update({ | |
Field1: value1 != "" ? value1 : null, | |
Field2: value2 != "" ? value2 : null, | |
PeopleField1: peopleValID != "" ? peopleValID : null, | |
PeopleMultiUserField1: multiusers.length > 0 ? { | |
results: multiusers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<AppPermissionRequests AllowAppOnlyPolicy="true" > | |
<AppPermissionRequest Scope="http://sharepoint/content/tenant" Right="FullControl" /> | |
</AppPermissionRequests> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private async promoteNews(pageName: string, pageType:string, newsstatus: string, siteUrl: string): Promise<string> { | |
var functionUrl : string = "<azure function url>" | |
const requestHeaders: Headers = new Headers(); | |
requestHeaders.append("Content-type", "application/json"); | |
requestHeaders.append("Cache-Control", "no-cache"); | |
const postOptions : RequestInit = { | |
headers: requestHeaders, | |
body: `{\r\n siteURL: '${siteUrl}',\r\n pageType: '${pageType}', \r\n pageName: '${pageName}', \r\n pageStatus: 'edit', \r\n newsStatus: '${newsstatus}'\r\n}`, | |
method: "POST" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ClientSidePage IntranetPage = ClientSidePage.Load(cc, HttpUtility.UrlDecode(PageName)); | |
if (newsStatus.ToString().ToLower().Equals("published")) | |
{ | |
IntranetPage.PromoteAsNewsArticle(); | |
IntranetPage.Save(); | |
IntranetPage.Publish(); | |
} | |
log.Info("Site Page Updated"); | |
pageUpdated = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ClientSidePage IntranetPage = ClientSidePage.Load(cc, HttpUtility.UrlDecode(PageName)); | |
if (newsStatus.ToString().ToLower().Equals("unpublish")) | |
{ | |
IntranetPage.DemoteNewsArticle(); | |
IntranetPage.Save(); | |
IntranetPage.Publish(); | |
} | |
log.Info("Site Page Updated"); | |
pageUpdated = true; |