tag:blogger.com,1999:blog-30234768372665277442024-02-02T06:46:06.578-08:00The SharePoint HiveManaging SharePoint 2016/Online (I started with SP2007) is my dayjob ... every so often, I have a challenge that I can't solve via Google, so I have to figure it out for myself. When that happens, I post the solution here, reasoning that if I couldn't find the answer by searching the internet, nor could others.
I hope these posts help someone ...The SharePoint Hivehttp://www.blogger.com/profile/02187796084766651206noreply@blogger.comBlogger30125tag:blogger.com,1999:blog-3023476837266527744.post-40159420714038761202024-01-26T03:07:00.000-08:002024-01-26T03:07:04.457-08:00PowerApps - Retrieve an Employee's ID (employeeId)<p><b>YOU'D THINK IT'D BE EASIER TO GET THE EMPLOYEE ID, RIGHT?</b> Just add Office365 as a data source to your Power Apps form then call:</p>
<p><span style="font-family: courier;">Office365Users.UserProfile(ThisItem.Id).employeeId</span></p>
<p>... or something similar. But no. Can't do it that way.</p>
<p>As is my habit with this sort of thing, I went first to Google. And from what I could see there wasn't a way to get the employeeId natively in PowerApps. Any solution I found wanted me to run a PowerAutomate Flow, which wasn't what I was after.</p>
<p>Then I had a breakthrough. I hadn't realised it before, but there is also a flavour of Power Automate you can call directly from a Power App - it really is a constant learning journey, this PowerApps stuff, isn't it?</p>
<h3 style="text-align: left;">WHAT I NEEDED IT FOR</h3>
<p>There are probably many scenarios where you might need to know a colleague's <b>employeeId</b>. By that I mean the multi-digit label (often sourced from WorkDay) that Active Directory copies and uses to identify a colleague. In the case of our corporation, it's a six digit number that you can see in Delve but can't otherwise access, at least not programmatically.</p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_WjS8BUqRTYUIn19FW_24OqNF30OKcByo5OHgWE7IZJToUwS_83B1mAg_OhpFEmm_Nd0n7ZA-jIXPxvl0D9AqJE0OC7e5vtpMOyBXgvvP6FTxzQFqEeHGZTcPGrYjZCamyjZ6u9uy6BZySa-f41Z8_AEdzBBMAS4W0UvPDNwmoqFUFH5xUtEaRjtQKOU/s690/pic16_Delve_edit.jpg" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="467" data-original-width="690" height="271" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_WjS8BUqRTYUIn19FW_24OqNF30OKcByo5OHgWE7IZJToUwS_83B1mAg_OhpFEmm_Nd0n7ZA-jIXPxvl0D9AqJE0OC7e5vtpMOyBXgvvP6FTxzQFqEeHGZTcPGrYjZCamyjZ6u9uy6BZySa-f41Z8_AEdzBBMAS4W0UvPDNwmoqFUFH5xUtEaRjtQKOU/w400-h271/pic16_Delve_edit.jpg" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>Why does Microsoft display the Employee ID in Delve, yet won't let you retrieve it via the Office365Users method?</i></td></tr></tbody></table>
<p>In this case, I was looking to allow colleagues to book a session with the official corporate photographer. In order to differentiate between two John Smiths, we name the images in the format:</p>
<p><span style="font-family: courier;">FirstName_Surname_EmployeeID</span></p>
<p>Then they all get stored in a SharePoint Document library and I can showcase them to the Business using a SharePoint Gallery (out of scope for this blog post).</p>
<h3 style="text-align: left;">HOW I DID IT</h3>
<p>The first part is fairly easy. I created a SharePoint list with a particular set of columns then, to keep it simple, customised the list's native forms via Power Apps.</p>
<p></p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBhxdOeem4MjAdGArmj-be73m7BABlLHVesFFWEFAFl0C21jFXyJ24qxwyur7vhlmSV5XRyZAKM4MP2EJfvntptMgy8aRp-IRHRK9rPwHUyardrUrteqVnkj9XZ6hjWYBxDO5MWsGOrpDRyqkwGpPfvAVFue_SJFAfikhI6rkeDiJb8Qi6xyj_QZQFRAU/s851/pic01_ListStructure.jpg" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="324" data-original-width="851" height="153" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBhxdOeem4MjAdGArmj-be73m7BABlLHVesFFWEFAFl0C21jFXyJ24qxwyur7vhlmSV5XRyZAKM4MP2EJfvntptMgy8aRp-IRHRK9rPwHUyardrUrteqVnkj9XZ6hjWYBxDO5MWsGOrpDRyqkwGpPfvAVFue_SJFAfikhI6rkeDiJb8Qi6xyj_QZQFRAU/w400-h153/pic01_ListStructure.jpg" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>There are other columns in the application, but these are the minimum needed to make the Get Employee ID function work.</i></td></tr></tbody></table>
<p>The key columns were:</p>
<ul style="text-align: left;">
<li>Timeslot (Text)</li>
<li>UserName (Name)</li>
<li>PhotoFileName (Text)</li>
<li>Location (Text)</li>
<li>Date (Date)</li>
</ul>
<p></p>
<p></p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjR0E6xBMJdqA6mEfB7QULgi8h3IOUlmkDCU7LpvF-3PFC4k2mxeFKixDXqXWANBFSMtsSRRawUGMJIIQQNZtX-kugk6nbS6My348kY1wC4NNJ7eoh0wAOFYKgfXlffdHPXKYCfeeGj85GXaJ5Cy9Xkl-2bO9NMAEJANnycCgZyFg8LX96Imdcgmm3cxI/s784/pic02_Booking%20gallery.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="139" data-original-width="784" height="71" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjR0E6xBMJdqA6mEfB7QULgi8h3IOUlmkDCU7LpvF-3PFC4k2mxeFKixDXqXWANBFSMtsSRRawUGMJIIQQNZtX-kugk6nbS6My348kY1wC4NNJ7eoh0wAOFYKgfXlffdHPXKYCfeeGj85GXaJ5Cy9Xkl-2bO9NMAEJANnycCgZyFg8LX96Imdcgmm3cxI/w400-h71/pic02_Booking%20gallery.JPG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">This is what the Gallery looks like ... just one timeslot added for demo purposes.</td></tr></tbody></table>
<p>To make the booking form available to fellow employees, I created a Power Apps Gallery and set it up to display the vacant sessions which colleagues could reserve by clicking on "Book this timeslot" (a link to the list's EditForm). Once the Timeslot was booked, I made it invisible by having the Gallery check whether the PhotoFileName cell in the list was empty. I may discuss the building of the Gallery in a future blog if anyone is interested.</p>
<p></p>
<p></p>
<p>So, to get started with customising the List's EditForm, let's click on <b>Integrate</b> and select from <b>Power Apps</b> the <b>Customize forms</b> option from the drop-down's flyout menu.</p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhn8rbY0p6ZxQ0gT0h1guSFc7N0ohzKerr8NNTn3b9MDRxWXgBrvPVAfiNaZGzRLBzooebwjDHdzSQpwy3LoQX2nFKjytZuOzVp4vdWin3Qi-sTG4gjm_yZYlX8mEufylg2pd_eiDZ0d9G8H5adSqD32MXOm4DfB7yYwnmdiEWabTBn4AEN9_ery40NvDE/s367/pic03_Modify-List-Forms.jpg" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="150" data-original-width="367" height="131" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhn8rbY0p6ZxQ0gT0h1guSFc7N0ohzKerr8NNTn3b9MDRxWXgBrvPVAfiNaZGzRLBzooebwjDHdzSQpwy3LoQX2nFKjytZuOzVp4vdWin3Qi-sTG4gjm_yZYlX8mEufylg2pd_eiDZ0d9G8H5adSqD32MXOm4DfB7yYwnmdiEWabTBn4AEN9_ery40NvDE/s320/pic03_Modify-List-Forms.jpg" width="320" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>This is pretty simple customisation, so no need for a Canvas App.</i></td></tr></tbody></table>
<p>Before starting an customisation on the form, I needed to add Active Directory as a datasource, because that's where the <b>employeeId</b> is stored.</p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWMUNRzGBtLfTDCf9ox31twA7p5Inu3GQvfZ_Kn9NdellCN0FvuejqWvpWxTd9eWhUj0tuF-ibDUD-ThMp3I6C3hHO6k8vMMhtHdlYWxQZzauQaeLu4DhjOVwsjh903TMvFFc9FLKtOnofHvmhPutEbS_UI2OuwY8P4txb0n9Qiuj3OEVBHi6R_hWzLhc/s647/pic08a_Data-view.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="647" data-original-width="344" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWMUNRzGBtLfTDCf9ox31twA7p5Inu3GQvfZ_Kn9NdellCN0FvuejqWvpWxTd9eWhUj0tuF-ibDUD-ThMp3I6C3hHO6k8vMMhtHdlYWxQZzauQaeLu4DhjOVwsjh903TMvFFc9FLKtOnofHvmhPutEbS_UI2OuwY8P4txb0n9Qiuj3OEVBHi6R_hWzLhc/w213-h400/pic08a_Data-view.JPG" width="213" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i><b>Add data,</b> then select <b>Office365Users</b> directly.</i></td></tr></tbody></table>
<p>I didn't want our registrants to mess with the Date or Timeslot fields, because they're fixed for each Photography session. So I added a Text Label to the DataCard and made it a concat of the Timeslot and the Date, separated by a comma, like this:</p>
<p><span style="font-family: courier;">DateTime_Label.Text = <br /></span></p>
<p><span style="font-family: courier;">Concatenate(<br />
<span style="white-space: pre;"> </span>
Text(DateTimeValue(ThisItem.Date), "dd/mm/yyyy"),<br />
<span style="white-space: pre;"> </span>
", ",<br />
<span style="white-space: pre;"> </span>
ThisItem.Timeslot<br />)</span></p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhd0sU_AI-UqnNZ0n4jVsEDmp38f1vgRdfHHTWxt533VJq_XBCK0izs4fabP0auzY3a1wL2Z5F7m_qhilh9gb_KBX_7iLQG-ZIVmo2s1QHxID3R8Gb8HMbZUO_QNQ2EwzbVUCyb2c9PrytAf_LbYXg_S4T4e67PZAbS5tfGEb0SKubc_0eEDY3dnt1zEgY/s455/pic04a_The-Form.jpg" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="455" data-original-width="371" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhd0sU_AI-UqnNZ0n4jVsEDmp38f1vgRdfHHTWxt533VJq_XBCK0izs4fabP0auzY3a1wL2Z5F7m_qhilh9gb_KBX_7iLQG-ZIVmo2s1QHxID3R8Gb8HMbZUO_QNQ2EwzbVUCyb2c9PrytAf_LbYXg_S4T4e67PZAbS5tfGEb0SKubc_0eEDY3dnt1zEgY/s320/pic04a_The-Form.jpg" width="261" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>To display the Time and Date, add a Text Label and use the Concat function to join the two.</i></td></tr></tbody></table>
<p>Next, I set up the UserName field to get the email of the current user - I'm going to use this value in the Flow that will retrieve the employeeId:</p>
<p><span style="font-family: courier;">UserName.Default = Office365Users.MyProfile().Mail</span></p>
<p>Then I added a Text label to the PhotoFileName field, to start building the final filename for the image that will be added to the directory once the Photographer's done his work. This will be in the format:</p>
<p>FirstName_Surname_</p>
<p>I did this by adding this script to the Text value of the label:</p>
<p><span style="font-family: courier;">Photofile_Label.Text = </span></p>
<p><span style="font-family: courier;">Concatenate(<br /><span style="white-space: pre;"> </span>Office365Users.MyProfile().GivenName,<br />
<span style="white-space: pre;"> </span>"_",<br />
<span style="white-space: pre;"> </span>Office365Users.MyProfile().Surname,<br />
<span style="white-space: pre;"> </span>"_",
<span style="white-space: pre;"> </span><br />
<span style="white-space: pre;"> v</span>EmpID.empid<br /></span>
<span style="font-family: courier;">)
</span></p>
<p>The value for the variable "vEmpID" will be generated by the Flow. We're just setting up the form to receive the value when the Flow delivers it.</p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJqQGTUwLbv_vVKApeDaf2beHde6iYsKhZCRv4S_0Hm9SSF3VZ66kkci-WYU6TQBB75n5pzf0KGWO6Ci616Co1TU433tevv_eAqZkceQ3eCJPDQedmP8vrMyEqZYfyNAdtzrg8xETF5M_YLxHmDxkHe9BSzUPYkm7_i5Dl5ThD-yQEBRCdtgTKQ6KY410/s455/pic05_The-Form.jpg" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="455" data-original-width="371" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJqQGTUwLbv_vVKApeDaf2beHde6iYsKhZCRv4S_0Hm9SSF3VZ66kkci-WYU6TQBB75n5pzf0KGWO6Ci616Co1TU433tevv_eAqZkceQ3eCJPDQedmP8vrMyEqZYfyNAdtzrg8xETF5M_YLxHmDxkHe9BSzUPYkm7_i5Dl5ThD-yQEBRCdtgTKQ6KY410/s320/pic05_The-Form.jpg" width="261" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>The UserName field captures the email of the current user and the PhotoFileName field compiles a string of the user's name and their Employee ID.</i></td></tr></tbody></table><br />
<p>Finally, for this part of the process, set the Update value of the PhotoFileName DataCard to fetch its value from the <b>PhotoFile_Label</b>.</p>
<p><span style="font-family: courier;">PhotoFileNameDataCard.Update = Photofile_Label.Text</span></p>
<p>We'll come back to the EditForm shortly, but now let's set up the Flow ...</p>
<h3 style="text-align: left;">ADD AN EMBEDDED FLOW TO THE FORM</h3>
<p>So the trick to fetching the current user's employeeId value is to add an embedded Flow to the PowerApps form. This was quite a revelation to me, but a welcome one. To embed a Flow in PowerApps all you need to do is to click on the Power Automate icon in the PowerApps left-hand column. Then, give the Flow a name and start building it, the same way you would in the Power Automate application.</p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjvtG284acAvM1W9txUU8cSewegayOYanNlMVrq-SoUskm0pxcvRZqCqU4S5rMVBnmQtbeXTaVWZZd8X465M4hXxytwi83fd98Y_cBAaMXWQnf2g6H8VmuO_GySWZga8CoJZ3APsfFz0ZsjCB6PGYUcHgEdJoCVaa0UvwuVdwJXq5JvUO4FNu8vMiP9U4/s327/pic09a_Power-Automate.jpg" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="246" data-original-width="327" height="241" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjvtG284acAvM1W9txUU8cSewegayOYanNlMVrq-SoUskm0pxcvRZqCqU4S5rMVBnmQtbeXTaVWZZd8X465M4hXxytwi83fd98Y_cBAaMXWQnf2g6H8VmuO_GySWZga8CoJZ3APsfFz0ZsjCB6PGYUcHgEdJoCVaa0UvwuVdwJXq5JvUO4FNu8vMiP9U4/s320/pic09a_Power-Automate.jpg" width="320" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>Each Flow you create in your PowerApps environment will need a unique name.</i></td></tr></tbody></table>
<p>Once you have created the Flow, you'll need to edit it to add the functions, so click on the ellipsis then select <b>Edit</b> from the flyout menu.</p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4Bya-pY2Wt6yeE_BS-6q215-N4TOS57p5cIJZl3Nd0YguF7pgeRWhxBm2jNUb3dajQ4Cf2EPTNy596OnBSzHamO9eCo4xgqBBOeOoMstNEuye-E_ggyJWlyQUw0K8HA_2PKdfarHha2CutItJP4DLPZPloCtq1K7rdAV9N9y3Xh00CvsdgZjgGI7lFjM/s482/pic09b_Power-Automate.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="310" data-original-width="482" height="206" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4Bya-pY2Wt6yeE_BS-6q215-N4TOS57p5cIJZl3Nd0YguF7pgeRWhxBm2jNUb3dajQ4Cf2EPTNy596OnBSzHamO9eCo4xgqBBOeOoMstNEuye-E_ggyJWlyQUw0K8HA_2PKdfarHha2CutItJP4DLPZPloCtq1K7rdAV9N9y3Xh00CvsdgZjgGI7lFjM/s320/pic09b_Power-Automate.JPG" width="320" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>I called my Flow "GetIDPB", because I had another Flow in my PowerApps environment called "GetID" ...</i></td></tr></tbody></table>
<p>The first item you'll need to add to your Flow is the PowerApps function. This is what will take the current user's email address and use it to retrieve the corresponding <b>employeeId</b>. Add "Email" as the Input type and put the Form field value in the adjacent field, like this:</p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgltDxJ5nrRowx0BcDFGYJVnWUAkgg2JTSO1xyD5shOVpt5Ep9fLOist8zs0BSEiRawRblCz8iK6RCt9HQT-hnvBp_hXUDRwKXSxecimi9O7C5nVgI5O2a0hG1IURoKr0fJxB4IhZh4cARepOm6VkgA1d3L3SR6CHJRdut4brkffSD2q-sscY8pz2uUhs0/s621/pic10_Power%20Automate.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="228" data-original-width="621" height="146" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgltDxJ5nrRowx0BcDFGYJVnWUAkgg2JTSO1xyD5shOVpt5Ep9fLOist8zs0BSEiRawRblCz8iK6RCt9HQT-hnvBp_hXUDRwKXSxecimi9O7C5nVgI5O2a0hG1IURoKr0fJxB4IhZh4cARepOm6VkgA1d3L3SR6CHJRdut4brkffSD2q-sscY8pz2uUhs0/w400-h146/pic10_Power%20Automate.JPG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>The name of the form field that holds the current user's email address will be different in your form.</i></td></tr></tbody></table>
<p>Next, we're going to add the function, <b>Get user profile</b>, click on the <b>Advanced</b> option and add the output from the previous function into the <b>User (UPN)</b> field and add "employeeid" into the <b>Select fields</b> field.</p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZR2qcwz2fkrdIJ9b1DX6PEemD6y2AjJagINY8JujDBgHrZR4-4reZMxmsW0H3VxFYSh-_eeHPrrvSOl2Z_4_1Jrg8ISxSN3WnPgyuC-goN7SHeXSEG4zQeuI18juurTGi2-0EQNr3-dWi2rQMoMfliki6PHU5_nmcUeIYZz5MNEGNljctCqLI3uuFf0k/s612/pic11_Power%20Automate.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="224" data-original-width="612" height="146" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZR2qcwz2fkrdIJ9b1DX6PEemD6y2AjJagINY8JujDBgHrZR4-4reZMxmsW0H3VxFYSh-_eeHPrrvSOl2Z_4_1Jrg8ISxSN3WnPgyuC-goN7SHeXSEG4zQeuI18juurTGi2-0EQNr3-dWi2rQMoMfliki6PHU5_nmcUeIYZz5MNEGNljctCqLI3uuFf0k/w400-h146/pic11_Power%20Automate.JPG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>This is the step that goes off and finds the Employee ID.</i></td></tr></tbody></table>
<p>Now we add a <b>Compose</b> function and make the <b>Input</b> the <b>Output</b> from the previous <b>Get user profile</b> function.</p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-TRyC-9OLd2nkUE2d7El7YjBBhtLLlQdhVGlfA_A_MKrQ-cAd_Db7CSxNSd77dF2m84AYYuXY5cM1imbzi4lacg9LTWuYPPCpzhJ6USOUEnfeaCejLko9q_tNshhXIpI2n5S5GTRr5HppOTqyn1DNVdfROWc3jfc4Sa6GWFXcrZCGe9CfpvumoTNoI0I/s606/pic12_Power%20Automate.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="146" data-original-width="606" height="96" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-TRyC-9OLd2nkUE2d7El7YjBBhtLLlQdhVGlfA_A_MKrQ-cAd_Db7CSxNSd77dF2m84AYYuXY5cM1imbzi4lacg9LTWuYPPCpzhJ6USOUEnfeaCejLko9q_tNshhXIpI2n5S5GTRr5HppOTqyn1DNVdfROWc3jfc4Sa6GWFXcrZCGe9CfpvumoTNoI0I/w400-h96/pic12_Power%20Automate.JPG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>I'm not exactly sure what this step is doing, but just go with it ...</i></td></tr></tbody></table>
<p>For me, the <b>Dynamic Content</b> menu didn't offer me the Output from the <b>Get user profile</b> function, so I had to add it as an expression, like this:</p>
<p><span style="font-family: courier;">outputs('Get_user_profile_(V2)')?['body/employeeid']</span></p>
<p>The next step is optional, but I found it handy during testing to make sure the Flow was triggering when I needed it to and that the Employee ID was being captured, like this:</p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiI6ggHuZaTETB7RkAH-QG1c57oCt4gbW5tVrlJrtcwUmS4LcDpjFzhjS7mE3IVm3yfOexvwuglwj5P0HsFOU0i-p4tWcjKgIqGOSJi3e4Xv0Mn6tzZvi2tuxCR__ihX4XMbYviGUdIlUYO-rXVyY3vWRL5izlgWNYNR0ZRMbfLdH9HYf3b3Fg569qbzAo/s611/pic13_Power%20Automate.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="309" data-original-width="611" height="203" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiI6ggHuZaTETB7RkAH-QG1c57oCt4gbW5tVrlJrtcwUmS4LcDpjFzhjS7mE3IVm3yfOexvwuglwj5P0HsFOU0i-p4tWcjKgIqGOSJi3e4Xv0Mn6tzZvi2tuxCR__ihX4XMbYviGUdIlUYO-rXVyY3vWRL5izlgWNYNR0ZRMbfLdH9HYf3b3Fg569qbzAo/w400-h203/pic13_Power%20Automate.JPG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>You can always remove the <b>Send an email</b> function when you're happy the Flow is performing as expected.</i></td></tr></tbody></table>
<p>We're going to hold the Employee ID in a variable, so we can deliver it back to the Power App form, so let's initialise one.</p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWYCp2d1KGtFC5wZQlpGkd1rL8PM8MKqyJHSI1OrnrKHib39QtKt73a56jI_uC3esckU2VXSeQY3YNnw2oTFj2gXf0jAVyDshnvtCEbV_Jl6w8ObEIbG4nvLe8fGTSBt5YEaGEloAzexW1vGf-AZLZaNCgbSTGMbnLsYSXZy2OBepc5ti19UQ9NbV5MRE/s613/pic14_Power%20Automate.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="223" data-original-width="613" height="145" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWYCp2d1KGtFC5wZQlpGkd1rL8PM8MKqyJHSI1OrnrKHib39QtKt73a56jI_uC3esckU2VXSeQY3YNnw2oTFj2gXf0jAVyDshnvtCEbV_Jl6w8ObEIbG4nvLe8fGTSBt5YEaGEloAzexW1vGf-AZLZaNCgbSTGMbnLsYSXZy2OBepc5ti19UQ9NbV5MRE/w400-h145/pic14_Power%20Automate.JPG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>No need to populate Value, we'll assign one to the variable in the next step.</i></td></tr></tbody></table>
<p>The last step is to deliver the result back to the Power App form, so that requires the <b>Respond to a PowerApp flow</b> function. Just add the variable name and set its value to the output from the <b>Compose</b> function. It does seem like overkill because I added the same value for the variable in the next step, as well ...</p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2Jh7FBjIPZDc3Y4DsSqera4mhgFgbECjDqDdEcAOGAH1tijHSiQkPr3Esb9YPO9Il9SD3VqsYrdch9uAxbbre4WKQIYSZ9ycB5nv_dsjWAiWXXVHw4BsRiJsB84Qt8UKOSlBWWJfTokkGRAPVBJtImBezBvfHytuHNVNbhHpyr1Q6_xrEuJ2O7GxuWv8/s608/pic15_Power%20Automate.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="185" data-original-width="608" height="121" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2Jh7FBjIPZDc3Y4DsSqera4mhgFgbECjDqDdEcAOGAH1tijHSiQkPr3Esb9YPO9Il9SD3VqsYrdch9uAxbbre4WKQIYSZ9ycB5nv_dsjWAiWXXVHw4BsRiJsB84Qt8UKOSlBWWJfTokkGRAPVBJtImBezBvfHytuHNVNbhHpyr1Q6_xrEuJ2O7GxuWv8/w400-h121/pic15_Power%20Automate.JPG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>We're setting the value of the variable in this step and sending it back to the PowerApps form.</i></td></tr></tbody></table>
<p>And that's it ... we're ready to return to the Form and make sure the PhotoFileName field is ready to receive the value for the Employee ID.</p>
<p>But don't forget to <b>Save</b> your Flow first.</p>
<h3 style="text-align: left;">AND ... BACK TO THE FORM</h3>
<p>I'd already set up the PhotoFileName field to receive the value from the EmpID variable once the Flow had run. The next challenge was to come up with a way to trigger the Flow.</p>
<p>In most scenarios, we ask the user to make some sort of change to the form, and we can usually piggyback on that change to trigger other actions. But in this case, I just wanted the person booking the session with the photographer to check that the timeslot was correct and then click the <b>Save</b> button. The rest I wanted to happen automatically and invisibly.</p>
<p>My first thought was to use a Timer ... so I added one to the Form and set it up like this:</p>
<p><span style="font-family: courier;">Timer.Duration = 500</span> -- in milliseconds<br /><span style="font-family: courier;">
Timer.Start = false</span><br /><span style="font-family: courier;">Timer.Autostart = true<br />Timer.OnTimerEnd = Set(vEmpID, GetIDPB.Run(DataCardValue7.Text)</span></p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkUHpcKH0ojCxn9MWS-YiDwN2rScLTo4s8Pke8hhceCwXq463N6KNVdm796bQhe97sxALIusPolQ5v1FUtDMzTGCLats99UIgoI-q4NKALIDvWomSwYVDpNrieAoDm1-_k-BclnnEL11Dvy2a7XaRgBMVYTij6N8lh7z-bOkfiZTQfMvCNaz4OFn7Awro/s442/pic06_The-Form.jpg" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="442" data-original-width="373" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkUHpcKH0ojCxn9MWS-YiDwN2rScLTo4s8Pke8hhceCwXq463N6KNVdm796bQhe97sxALIusPolQ5v1FUtDMzTGCLats99UIgoI-q4NKALIDvWomSwYVDpNrieAoDm1-_k-BclnnEL11Dvy2a7XaRgBMVYTij6N8lh7z-bOkfiZTQfMvCNaz4OFn7Awro/s320/pic06_The-Form.jpg" width="270" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>Adding a Timer button seemed like the right choice, but at first it wouldn't trigger the Flow.</i></td></tr></tbody></table>
<p>But that didn't work. For some reason, the Timer button would not launch the command that starts the Flow running. I tried setting the <b>Start</b> function to "true" but that didn't help either.</p>
<p>After some minutes of deep thought I came up with a solution. Swap the actions of the <b>Timer</b> button and the <b>Save</b> button.</p>
<p>On the <b>Timer</b> button I set the <b>Autostart</b> value back to "false". Then I gave the Start function the value of (variable) "vStart". Finally, I set the <b>OnTimerEnd</b> value to what I'd originally put in the <b>Save</b> button:</p>
<p><span style="font-family: courier;">SubmitForm(SharePointForm1);Navigate(FormScreen_Thanks,ScreenTransition.Fade)</span></p>
<p>And on the <b>Save</b> button, I changed the <b>OnSelect</b> value to:</p>
<p><span style="font-family: courier;">Save.OnSelect = Set(vEmpID, GetIDPB.Run(DataCardValue7.Text));Set(vStart, true)</span></p>
<p>... note the addition of the command that sets the vStart variable to "true".</p>
<p>Now when I clicked on the <b>Save</b> button, the Flow was triggered, the Employee ID was retrieved, the Flow sent me an email containing my Employee ID and the Form updated the SharePoint List field PhotoFileName with my First Name, Surname and Employee ID.</p>
<p>Satisfied that all was working as expected, I could now hide the form's PhotoFileName and UserName fields, along with the Timer button.</p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUQnsS4hkpl_mvf3GUpeoUEjzjEJnt9d2qArilxrVxqxCBwTzcGevZHa2jdr5Vg5_8jR0FHixDHJkZliUlconsxY9Kaai2CFQtb3JKPCHWxFDodCzvkkZdXQf4i6xc5xSoTAcPcTDu7iReN7MeEg60LvvqhzJBbfmVBYmCjgoZQyhyJHeiyDm71VCICPE/s463/pic18_SharePoint%20EditForm%20final.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="444" data-original-width="463" height="307" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUQnsS4hkpl_mvf3GUpeoUEjzjEJnt9d2qArilxrVxqxCBwTzcGevZHa2jdr5Vg5_8jR0FHixDHJkZliUlconsxY9Kaai2CFQtb3JKPCHWxFDodCzvkkZdXQf4i6xc5xSoTAcPcTDu7iReN7MeEg60LvvqhzJBbfmVBYmCjgoZQyhyJHeiyDm71VCICPE/s320/pic18_SharePoint%20EditForm%20final.JPG" width="320" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>After hiding the fields and functions the user doesn't need to see, this is what the final triggered EditForm looks like.</i></td></tr></tbody></table>
<p>The one final test to make sure all was working before removing the <b>Send an email</b> action from the <b>GetIDPB</b> flow ...</p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKnru5KfMQESFZFPGmANHZTWY4YS73jEkCzsBuIBu1xmzqq5RmefBHl2sf6fr8s8l9Y-kzT2WsyahmOlXvcSsQlfVxDxSo0M3VhiCquO9u9xLJ5U1tl0CoDxe1pbzTuzZgoq40wo0xcGZrwWm5ZoGWQ-kweVvHqkiNVl-PFX4PyClafz3DwfkUZZJWXxM/s912/pic17_SharePoint%20list%20final.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="235" data-original-width="912" height="103" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKnru5KfMQESFZFPGmANHZTWY4YS73jEkCzsBuIBu1xmzqq5RmefBHl2sf6fr8s8l9Y-kzT2WsyahmOlXvcSsQlfVxDxSo0M3VhiCquO9u9xLJ5U1tl0CoDxe1pbzTuzZgoq40wo0xcGZrwWm5ZoGWQ-kweVvHqkiNVl-PFX4PyClafz3DwfkUZZJWXxM/w400-h103/pic17_SharePoint%20list%20final.JPG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>After clicking <b>Save</b>, the SharePoint list will be updated to look like this.</i></td></tr></tbody></table>
<p>And that's it. Maybe in the future Microsoft will make this process a bit simpler, but until then, this should suffice.</p>
<p>I hope this helps someone.</p>
<p><br /></p>
<p><br /></p>
<p><br /></p>
<p><br /></p>
AirPiratePresshttp://www.blogger.com/profile/13136561512898563240noreply@blogger.com0tag:blogger.com,1999:blog-3023476837266527744.post-62573518658968491172023-04-22T02:12:00.000-07:002023-11-16T12:26:36.162-08:00Passing SharePoint List values from one list to another<p><b>I WAS LOOKING TO PASS LIST VALUES FROM ONE LIST TO ANOTHER</b> in Power Apps, and it was quite a bit trickier than I imagined.</p><p>The company I work for has a private box at one of the big London concert venues that is used for entertaining corporate clients. My colleagues in the Events team manage the use of the box, but the process had become mired down in a maze of emails and Excel spreadsheets. I was asked if there was a better way to manage requests to use the box.</p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieLLAgCiJWVCbhcvIgPo0_cA7z4MgtzLElZBOCX761C5ADRiSo14HT0KMXFd7lotmekeOoxFB0Zei6ZJQbH8lOjUoO-EXZ7aiKu7khvRll_68yju1oSc7ib5IHAAoZT-ve_GZz17th0rnzqEgxfMnGPSBbr3aQgxiBDqx9JRWBcNREbUU7iowdFn9Z/s1181/pic01_SPcalendar.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="522" data-original-width="1181" height="176" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieLLAgCiJWVCbhcvIgPo0_cA7z4MgtzLElZBOCX761C5ADRiSo14HT0KMXFd7lotmekeOoxFB0Zei6ZJQbH8lOjUoO-EXZ7aiKu7khvRll_68yju1oSc7ib5IHAAoZT-ve_GZz17th0rnzqEgxfMnGPSBbr3aQgxiBDqx9JRWBcNREbUU7iowdFn9Z/w400-h176/pic01_SPcalendar.JPG" width="400" /></a></div><br />We already had a SharePoint classic calendar which was populated with the forthcoming events at the venue, but I wanted to create an application form that could manage the request process end-to-end.<p></p><p>The first barrier I ran into is that you can't customise the form-set for a classic calendar using Power Apps. And I wasn't able to see if using SharePoint Designer was an option, as my SPD stopped working a few months back (I've no idea why). So I had to come up with another way.</p><p>I didn't really want to get rid of the SharePoint calendar, because a lot of work had been invested in it and it is a pretty good way for our requestors to see a simple layout of forthcoming events ... so I wondered if I could create a second SharePoint list to manage the requests to use the box. It would all hinge on whether I could send some data from the calendar to the secondary Requests list. I was thinking ... query strings!</p><h3 style="text-align: left;">THE SOLUTION</h3><p>The first step was to see whether I could send data to a Power Apps form in a query string. So I set up the Requests Management list and made sure I had a DateTime field to hold the Event's start time from the Calendar ("Start Time"). Both Lists would use the <b>Title</b> column to pass the name of the event.</p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgd_XiRJA6WHqyWF0BTQrqkpPy_zpqXyTswAGxc_mQoK8KVnlk3OByejdoBLHvWO6DGFRqaKY5tTiN1-yq_RhTCrzGtfAfKMCIzKSBOBMHuIjBJJRMrEKGVCEUZtYUhXgQGTOu1SBEN8rbkGLTTnLY4uSlG8ETUGfqu1HJ2PyY1Lh48vYb7dcm_33_/s670/pic02_CalendarStartTime.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="120" data-original-width="670" height="71" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgd_XiRJA6WHqyWF0BTQrqkpPy_zpqXyTswAGxc_mQoK8KVnlk3OByejdoBLHvWO6DGFRqaKY5tTiN1-yq_RhTCrzGtfAfKMCIzKSBOBMHuIjBJJRMrEKGVCEUZtYUhXgQGTOu1SBEN8rbkGLTTnLY4uSlG8ETUGfqu1HJ2PyY1Lh48vYb7dcm_33_/w400-h71/pic02_CalendarStartTime.jpg" width="400" /></a></div><br />So, to see whether it would work, I built a link, including the query string, using the simple canvas app I built to manage the Requests list, like this:<p></p><p><span style="font-family: courier;">https://apps.powerapps.com/play/[PowerAppID]?tenantId=[tenantID]&<b>Event</b>=[Title]&<b>Date</b>=[Start Time]</span></p><p>I knew from previous Power Apps I'd built that the Date value would be passed in the format "2022-11-06T18:00:00Z", but there would be no need to try to reformat that at this stage.</p><p>Then, I needed to prepare the fields in the recipient form to receive the data from the query string. To do that I set the <b>Event</b> field in the Power Apps form to:</p><p><span style="font-family: arial;">Event_DataCardValue1.Default = </span><span style="font-family: courier;">Param("Event")</span></p><p>... and the <b>Date</b> field to:</p><p><span style="font-family: arial;">DataCardValue2.DefaultDate = </span><span style="font-family: courier;">Param("Date")</span></p><p>But when I pasted the constructed URL into the browser and hit <b>Return</b>, the result wasn't quite what I was looking for.</p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZEbySpDdOVbIPx_sDtezxspQLXSlRFAdtucDazel26WUzHuGlq2cbTvBSAHgGTgBK_YgFp4tizqwBl_zVmTvDlUFsfeLuHRd8qNUcFqlpCqypvV-3KDC7NTBEjYESoOfE1ZM5dFruTZ2g1qVbOpzTwgHb1GkSarWgPXB7wiau5yGsA7De7NjBwm9Y/s475/pic03_QueryStringTest.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="176" data-original-width="475" height="119" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZEbySpDdOVbIPx_sDtezxspQLXSlRFAdtucDazel26WUzHuGlq2cbTvBSAHgGTgBK_YgFp4tizqwBl_zVmTvDlUFsfeLuHRd8qNUcFqlpCqypvV-3KDC7NTBEjYESoOfE1ZM5dFruTZ2g1qVbOpzTwgHb1GkSarWgPXB7wiau5yGsA7De7NjBwm9Y/s320/pic03_QueryStringTest.jpg" width="320" /></a></div><br />The <b>Event</b> value passed just fine, but the <b>Date</b> ... well, all I got was the date.<p></p><p>A quick search of Google suggested that a Power Apps Date field can't display the time value from a DateTime field. Quite why Microsoft thought that was a good idea, I couldn't say. But it left me in a bit of a bind. Because sometimes, concert venues have more than one show on a particular date and I needed to understand which show the Requestor was asking for.</p><p>One partial solution I found via Google was a suggestion that to fill in a time value in a Power Apps form, I could add an invisible dropdown, pre-populated with hour values, to the DateTime DataCard and then have the query string value select the appropriate hour value from the drop down to display. Sounded a bit convoluted, but I thought I might be able to adapt it to my needs.</p><p>So, I added the dropdown, then put this in its Items field:</p><p><span style="font-family: courier;">["09","10","11","12","13","14","15","16","17","18","19","20"]</span></p><p>I figured I'd just put the hours that I knew would be likely to turn up in the query string - no show would start before 09.00 hours or after 20.00 hours.</p><p>Then I made the <b>Hours</b> dropdown's Default value:</p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhx7ZJ4flS98Hh0eWvls-Qne19ddzA9nqoTJeiUCzBMu64A9oGdTV--o5he9E6tc5d2SNwL_DLb48uWeyPjh8ZPcGTVIgfE-9yMeyz_ZkmQKDmfRtd5jH1pG1YrvPzLSJwuI9XcqDydR8b1-wuAEtGm2nFuGbeZDw8YzLzIaKMe2fTIt3Umrkhmfdnh/s317/pic04_HoursDefault.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="259" data-original-width="317" height="259" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhx7ZJ4flS98Hh0eWvls-Qne19ddzA9nqoTJeiUCzBMu64A9oGdTV--o5he9E6tc5d2SNwL_DLb48uWeyPjh8ZPcGTVIgfE-9yMeyz_ZkmQKDmfRtd5jH1pG1YrvPzLSJwuI9XcqDydR8b1-wuAEtGm2nFuGbeZDw8YzLzIaKMe2fTIt3Umrkhmfdnh/s1600/pic04_HoursDefault.jpg" width="317" /></a></div><br />ddHours.Default = <span style="font-family: courier;">Text(DateTimeValue(Param("Date")), "hh")</span><p></p><p>... and tried again. Success!</p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9SMB3yYfLJLzEMkfaBmQcYkm-TFm97ar1nT1w6jRgjXppDY7QNtoAyV4YLHUfY3XomJDeB0GJYNtm8cHda4hqlPRd5n_lEJ25zcusj-6CoYPMPiypm-SkOEJupm93if8h_5g9kv6wTQbQSDtPtv1MvLSsPj56yWQcvnzdauneBnDyD_vFDRZmhB8_/s475/pic05_QueryStringTest.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="176" data-original-width="475" height="119" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9SMB3yYfLJLzEMkfaBmQcYkm-TFm97ar1nT1w6jRgjXppDY7QNtoAyV4YLHUfY3XomJDeB0GJYNtm8cHda4hqlPRd5n_lEJ25zcusj-6CoYPMPiypm-SkOEJupm93if8h_5g9kv6wTQbQSDtPtv1MvLSsPj56yWQcvnzdauneBnDyD_vFDRZmhB8_/s320/pic05_QueryStringTest.jpg" width="320" /></a></div><br />That was easier than I thought ... but then came the <b>Minutes</b> field. Using a similar approach, I added a dropdown for the Minutes value into the DateTime DataCard, and set it up like this:<p></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpi33qBDc1JWXniiikWm8GLEgTk1YUxL1_vb4120iBhTQEZyjCK41rhIV2yZP8CNFDk-icmP1U7-tR9uTeFQG-EqCkYb5Xi-svf9e_owZl8ZfPbAuVJovKkMP9JGY8C-mBsadD7lmWg-FwT6oVQzRDjR-AfUZsBbrcv5mICxk7jPlbfxno3mGXfCRa/s319/pic06_MinsDefault.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="233" data-original-width="319" height="233" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpi33qBDc1JWXniiikWm8GLEgTk1YUxL1_vb4120iBhTQEZyjCK41rhIV2yZP8CNFDk-icmP1U7-tR9uTeFQG-EqCkYb5Xi-svf9e_owZl8ZfPbAuVJovKkMP9JGY8C-mBsadD7lmWg-FwT6oVQzRDjR-AfUZsBbrcv5mICxk7jPlbfxno3mGXfCRa/s1600/pic06_MinsDefault.jpg" width="319" /></a></div><br />Putting this in the Minutes dropdown's Items field:<p></p><p><span style="font-family: courier;">["00","11","15","30","45"]</span></p><p>... and setting the <b>Mins</b> dropdown's Default value to:</p><p>ddMins.Default = <span style="font-family: courier;">Text(DateTimeValue(Param("Date")), "mm")</span></p><p>But it didn't work.</p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1Ib-l5QLaCQ_fxZqZSesKs5G8U1W5SSGAWtvbf0ROjSdYO2D7neXx-WLzxXYUqgjw-8R_fRUoqrjk2s3LrRvJvjN4UchfULkoTbBEXqad66R87hKYcd4wMsa07K7YgML8yYhjxZaANLTRNHirgp13fPr5TKgWB0o9oc_6_p4VN174IRyDWMofcg60/s475/pic07_QueryStringMinsTest.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="176" data-original-width="475" height="119" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1Ib-l5QLaCQ_fxZqZSesKs5G8U1W5SSGAWtvbf0ROjSdYO2D7neXx-WLzxXYUqgjw-8R_fRUoqrjk2s3LrRvJvjN4UchfULkoTbBEXqad66R87hKYcd4wMsa07K7YgML8yYhjxZaANLTRNHirgp13fPr5TKgWB0o9oc_6_p4VN174IRyDWMofcg60/s320/pic07_QueryStringMinsTest.jpg" width="320" /></a></div><br />A bit more frantic Googling and I came across this variation for the Default field:<p></p><p>ddMins.Default = <span style="font-family: courier;">Minute(Param("Date"))</span></p><p>Ah-ha! Success! This one worked. All I had to do next was figure out the <b>Update</b> value for the parent DataCard and we'd be in business ...</p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLo14JNQLMH5ckQCaiDIwGxjZFTS8naJr5KNlLwMBp3PAKUfuWBBXPD5PIJbxEJu0zBy3SwsnTDdLO-KHKy9B4JxADAZgsYKeJ8Cqm11DycrqPYq-4TqUtx4MUCHDZVJ8WmoHxWsdUZR8ZbnYHJFrguXM30gw9vVuPaQs8Pdb6lMl0Y33wFaxVNHUs/s475/pic08_QueryStringMinsTest.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="176" data-original-width="475" height="119" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLo14JNQLMH5ckQCaiDIwGxjZFTS8naJr5KNlLwMBp3PAKUfuWBBXPD5PIJbxEJu0zBy3SwsnTDdLO-KHKy9B4JxADAZgsYKeJ8Cqm11DycrqPYq-4TqUtx4MUCHDZVJ8WmoHxWsdUZR8ZbnYHJFrguXM30gw9vVuPaQs8Pdb6lMl0Y33wFaxVNHUs/s320/pic08_QueryStringMinsTest.jpg" width="320" /></a></div><br />So, in the same Google search I found a formula for updating the DateTime column in the <b>Requests Management</b> list. It looked like this:<p></p><p>EventDate_DataCardValue1.Update = <span style="font-family: courier;">DataCardValue2.SelectedDate + Time(Value(ddHours.Selected.Value), Value(ddMins.Selected.Value),0)</span></p><p>I'm not entirely sure what's going on here, but the first bit fetches the <b>Date</b> value that's been passed to the form by the query string. The second bit adds the <b>Hours</b> value from the invisible hours dropdown and the third bit adds the <b>Mins</b> value from the invisible mins dropdown. The bit I'm not sure about is the zero at the end (could it be the value for seconds?) ... but never mind, it works!</p><h3 style="text-align: left;">AND ... BACK TO THE CALENDAR</h3><p>So, the other part of this problem was to create a link in the original source calendar that would send our intrepid requestor to the Power Apps Request form.</p><p>I've used Power Platform to create a dynamic link before and <a href="http://thesharepointhive.blogspot.com/2022/06/simple-approval-form-with-powerapps.html" target="_blank">documented it here</a>. So my first thought was to see if this could be adapted to generate a dynamic link that would be formatted the same way as my manually-created test link above. Just to remind you, the link needed to look like this:</p><p><span style="font-family: courier;">https://apps.powerapps.com/play/[PowerAppID]?tenantId=[tenantId]&Event=[Title]&Date=[Start Time]</span></p><p>But first create a new field in the source calendar, <b>Register</b>, and make it a "Hyperlink or picture field".</p><p>Next, as in the earlier post, I thought I could create a Flow in Power Automate that would generate a dynamic link when a new Calendar entry was added.</p><p>I used a "When an item is created or modified" flow, because I figured that it would be useful if the time of an event changed, the administrator could make the change, then delete the existing link, and a new link would be generated.</p><p>So, to build the dynamic link in the Flow, we're going to use the <b>Send an HTTP Request to SharePoint</b> action:</p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj23yeE2bxX_WBZbrjrG_ys31NZfdkvNXL4WcJO943phHGtGOdETzmRqn9NFplp6bCH9ZhA68FDPyfqu3Fgo4qfhT6d1cOx_NQxL-g8xFLLmgVz3r-muH8oXpnWWbRAnVgYWP-5gcaKniAU1qwqT3sOkG1L4EYb26FTGA_Y71AOz8-5DNWjPRiekE4V/s632/pic09_SendHTTPrequest.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="542" data-original-width="632" height="343" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj23yeE2bxX_WBZbrjrG_ys31NZfdkvNXL4WcJO943phHGtGOdETzmRqn9NFplp6bCH9ZhA68FDPyfqu3Fgo4qfhT6d1cOx_NQxL-g8xFLLmgVz3r-muH8oXpnWWbRAnVgYWP-5gcaKniAU1qwqT3sOkG1L4EYb26FTGA_Y71AOz8-5DNWjPRiekE4V/w400-h343/pic09_SendHTTPrequest.jpg" width="400" /></a></div><br />The settings in this Action should be:<p></p><p></p><p>Set <b>Method</b> to:</p><p><span style="font-family: courier;">POST</span></p><p>Set <b>Uri</b> to:</p><p><span style="font-family: courier;">_api/web/lists/GetByTitle('Calendar')/items([ID])</span></p><p>... where the [ID] is replaced with a dynamic ID look up.</p><p>Set <b>Header</b> to:</p><p><span style="font-family: courier;">{</span></p><p><span style="font-family: courier;"> "Content-Type": "application/json;odata=verbose",</span></p><p><span style="font-family: courier;"> "X-HTTP-Method": "MERGE",</span></p><p><span style="font-family: courier;"> "IF-MATCH": "*"</span></p><p><span style="font-family: courier;"> }</span></p><p>And finally, I set <b>Body</b> to:</p><p><span style="font-family: courier;">{'__metadata': {'type':'SP.Data.HRBookSlotListItem'},'Register':</span></p><p><span style="font-family: courier;"> {'Description': 'Book this slot',</span></p><p><span style="font-family: courier;"> 'Url': 'https://apps.powerapps.com/play/[PowerApps ID]?tenantId=[tenantId]&Event=[Title]&Date=[Start Time]'}</span></p><p><span style="font-family: courier;">}</span></p><p><b>BUT</b> ... this only <i>nearly</i> worked. What I found on testing was that the dynamic link generated wasn't quite right. Any wordspaces from the <b>Title </b>field were being replaced with a "+" sign. Random! Why not "%20", which is the usual replacement for a word space in a URL? Who knows?</p><p>So I figured what I would do is write the <b>Title</b> value to a variable then replace the + symbol with the more functional encoded wordspace ("%20"). Here's how I did it.</p><p>First, Initialise a variable to hold the Title value.</p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiHbzo8pnUxHs01LnKhEelqgsf7djY1PjwUvGV9NPSUt3T9BQXn8af-Zqe6IaXdQX-lMoBWi6tfLG_DcevkknkuTvaf1v4fy93AkMn-ZPW0t3XEsUlVjacwhmHKfyrgZfNHEr5Zq6UTff0qsHWr-bwvRQrybU425kGaPseKktoOmdI1mK5_umJz_2K/s635/pic10_InitialiseVariable_vTitle.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="229" data-original-width="635" height="144" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiHbzo8pnUxHs01LnKhEelqgsf7djY1PjwUvGV9NPSUt3T9BQXn8af-Zqe6IaXdQX-lMoBWi6tfLG_DcevkknkuTvaf1v4fy93AkMn-ZPW0t3XEsUlVjacwhmHKfyrgZfNHEr5Zq6UTff0qsHWr-bwvRQrybU425kGaPseKktoOmdI1mK5_umJz_2K/w400-h144/pic10_InitialiseVariable_vTitle.JPG" width="400" /></a></div><br />Then, initialise a second variable to process and hold the transformed <b>Title</b> value.<p></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEju7bYHIdoZXLyITC89sLq3tf6jcozdH8W6MBwht8dF8nycV7-lFy1ByHBIoefo95rIf3f9Mu1Qu-WdkRzktCPkXFSKM3FhnPtFOK5tHvtDhyEpN6bq-emt6OCm6su0h3ywf6o9pom-JjSGRyQ7lPYwY0ZBC9uzeBzvYTN60odxws2WsaIBq1OkNM7D/s630/pic11_InitialiseVariable_vReplace.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="336" data-original-width="630" height="214" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEju7bYHIdoZXLyITC89sLq3tf6jcozdH8W6MBwht8dF8nycV7-lFy1ByHBIoefo95rIf3f9Mu1Qu-WdkRzktCPkXFSKM3FhnPtFOK5tHvtDhyEpN6bq-emt6OCm6su0h3ywf6o9pom-JjSGRyQ7lPYwY0ZBC9uzeBzvYTN60odxws2WsaIBq1OkNM7D/w400-h214/pic11_InitialiseVariable_vReplace.JPG" width="400" /></a></div><br />Here's the formula that we use to scan the <b>Title</b> value and replace the open word space with the encoded "%20":<p></p><p><span style="font-family: courier;">[</span></p><p><span style="font-family: courier;"> {</span></p><p><span style="font-family: courier;"> "Old": " ",</span></p><p><span style="font-family: courier;"> "New": "%20"</span></p><p><span style="font-family: courier;"> }</span></p><p><span style="font-family: courier;">]</span></p><p>Next, I added a condition to make sure that the new Register field in the calendar was empty:</p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXIpYXOCj22jSgyNfV85zt2e_RxntP-Hr8ao9w16DTFptJfOYMYQXLrfhccFcXY8_5OwJw6qlOBMvNW5qAFf8K3yax7A8BI-IJ4EgyaheZz6hVdDyGQTHhptfPsFM4M14kmfJGUkCFLNXUZEAUs8TPjxFV0Mz5OGRba304q8KQHSE2qJJw6_9pqlbk/s622/pic12_FlowCondition.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="197" data-original-width="622" height="126" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXIpYXOCj22jSgyNfV85zt2e_RxntP-Hr8ao9w16DTFptJfOYMYQXLrfhccFcXY8_5OwJw6qlOBMvNW5qAFf8K3yax7A8BI-IJ4EgyaheZz6hVdDyGQTHhptfPsFM4M14kmfJGUkCFLNXUZEAUs8TPjxFV0Mz5OGRba304q8KQHSE2qJJw6_9pqlbk/w400-h126/pic12_FlowCondition.JPG" width="400" /></a></div><br />In the Yes branch of the <b>Condition</b>, we need to add an <b>Apply To Each</b> container, so we can cycle through the <b>Title</b> values and replace the wordspace with "%20", like this:<p></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5yMWBMDhX3mC17z7T2IyYmtxs0P_Va72v96y0vaOk7f2Faarprg3E3UGQ1l_CZGhC1xcOpX8ZSOS6Yv-t3Nf5TT0T1ZtqTRr3I9mGLA0L-UcfzYijaYk9OLMO6M0XiQB2EjTDURRntGTNzUJHmgoCylGACST2n2QLuVj16gYPEBS-Ee2vpdCwaMBC/s683/pic13_ApplyToEach.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="625" data-original-width="683" height="366" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5yMWBMDhX3mC17z7T2IyYmtxs0P_Va72v96y0vaOk7f2Faarprg3E3UGQ1l_CZGhC1xcOpX8ZSOS6Yv-t3Nf5TT0T1ZtqTRr3I9mGLA0L-UcfzYijaYk9OLMO6M0XiQB2EjTDURRntGTNzUJHmgoCylGACST2n2QLuVj16gYPEBS-Ee2vpdCwaMBC/w400-h366/pic13_ApplyToEach.JPG" width="400" /></a></div><br />We place the <b>vReplace</b> variable in the <b>Select an output from a previous step</b>.<p></p><p>Then we add a <b>Compose</b> action and insert this expression:</p><p>Inputs.fx = <span style="font-family: courier;">replace(variables('vTitle'), item()?['Old'], item()?['New'])</span></p><p>Finally, add a <b>Set variable action</b> and select <b>vTitle</b> in the <b>Name</b> field and add <b>Outputs</b> from the <b>Compose</b> action in the <b>Value</b> field.</p><p>Next comes the <b>Send an HTTP request to SharePoint</b> that we already configured earlier, but now we've replaced the dynamic <b>Title</b> value with the <b>vTitle</b> variable.</p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAC6AKDOk6Ml_16heCC0qpAPc4fOTm3ivNkguKeY1Ayo_mGHs6dLNRXmmyK_Wj_X_4NjF5u9ffOmnllepyxOg2jIzeCkHnmvdYUTXIumIj_qlOWoNNPzmUt7HvSDFYkUBOYM7baT4GF55tmayCDFyrZtT56YAnE1p3GdTI4Pn_SgJlVYOHb1snRIF0/s632/pic14_SendHTTPrequest.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="542" data-original-width="632" height="343" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAC6AKDOk6Ml_16heCC0qpAPc4fOTm3ivNkguKeY1Ayo_mGHs6dLNRXmmyK_Wj_X_4NjF5u9ffOmnllepyxOg2jIzeCkHnmvdYUTXIumIj_qlOWoNNPzmUt7HvSDFYkUBOYM7baT4GF55tmayCDFyrZtT56YAnE1p3GdTI4Pn_SgJlVYOHb1snRIF0/w400-h343/pic14_SendHTTPrequest.jpg" width="400" /></a></div><br />Now when you add a new event to the event calendar, the appropriate dynamic link is generated and added to the <b>Register</b> field in the <b>Calendar</b>, like this:<p></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjD7bdK4cTwZti8jMH6o8IZmaDkmqB66pgIrvFuVy8WmF_fDfsrggLKntsbSKO_scFS4nAcSB46Ie6UXOTfmt6Rhb0y9cJS0tihQt54KfNGE9Bf_fJZ1UVq9M0874l5HH0vB_AfxpQyEwh34tA_U1azaWQQRH69gkw8uCN4MrWuqc1iUoHdMHIeY9pU/s532/pic15_RegisterLink.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="158" data-original-width="532" height="119" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjD7bdK4cTwZti8jMH6o8IZmaDkmqB66pgIrvFuVy8WmF_fDfsrggLKntsbSKO_scFS4nAcSB46Ie6UXOTfmt6Rhb0y9cJS0tihQt54KfNGE9Bf_fJZ1UVq9M0874l5HH0vB_AfxpQyEwh34tA_U1azaWQQRH69gkw8uCN4MrWuqc1iUoHdMHIeY9pU/w400-h119/pic15_RegisterLink.jpg" width="400" /></a></div><br />That's pretty much it. The Event <b>Name</b> and the Event <b>DateTime</b> get passed from the original calendar item, via the Power Apps form, to the <b>Requests Management</b> list. Once a new instance is created in the <b>Requests Management</b> list, a different Flow takes care of routing the request to the Department Head for approval, and finally informing the Requestor of the status of their request.<p></p><p>I hope that helps someone.</p><p><b>Next: More query string shenannigans</b></p><p><br /></p><p><br /></p>AirPiratePresshttp://www.blogger.com/profile/13136561512898563240noreply@blogger.com0tag:blogger.com,1999:blog-3023476837266527744.post-3790300170711139882023-02-02T07:44:00.003-08:002023-02-02T07:47:23.276-08:00Where did that Contoso dummy content come from?<p><b>HERE'S A THING ...</b> an internal client of mine was working on a modern Experience site, and some of her navigation links were taking her to a page of dummy Contoso content. Like this:</p>
<p></p>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDu19Gupw3mSIDQgnQt5uMlNTS92gaxgBR7hLaBTnkkaXLnW2oK8qDRSBm-JQFPilGpLrbctfcpfLxJ_UkEFyt42iw9_Zjpy7zKGK1aUIKp58zpGCTP2Isnmexsqz7AP3PI1HLqypRaWMb0WEOyRS9oot-VSiaGI1aRNjl7K7A2uVA_8fp_wN8RYJC/s1259/pic01_ContosoDummyContent.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="975" data-original-width="1259" height="310" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDu19Gupw3mSIDQgnQt5uMlNTS92gaxgBR7hLaBTnkkaXLnW2oK8qDRSBm-JQFPilGpLrbctfcpfLxJ_UkEFyt42iw9_Zjpy7zKGK1aUIKp58zpGCTP2Isnmexsqz7AP3PI1HLqypRaWMb0WEOyRS9oot-VSiaGI1aRNjl7K7A2uVA_8fp_wN8RYJC/w400-h310/pic01_ContosoDummyContent.jpg" width="400" /></a></div>
<p>Trying to Google for things like "Contoso content" was no help at all ... so I needed to figure this out by myself.</p>
<p>I wondered if there was a dummy or template page lurking in the <b>SitePages</b> library of the site, but I couldn't see anything. When I looked at the URL in the browser address window, I saw a long URL, but no sign of a page name.</p>
<p><span style="font-family: courier;">https://xxx.sharepoint.com/sites/DataMI/?xsdata=MDV8MDF8fDVjYTA2ZjVhN2MwNjQyMWYzMDcxMDhkYjA0MzAwZDg3fGNlNTZmYWU2MDU1ZDRjOWZiNmM5OWQzNDE1MDZhNDkxfDB8MHw2MzgxMDgzNzY2MzQ5NjIwMzN8VW5rbm93bnxWR1ZoYlhOVFpXTjFjbWwwZVZObGNuWnBZMlY4ZXlKV0lqb2lNQzR3TGpBd01EQWlMQ0pRSWpvaVYybHVNeklpTENKQlRpSTZJazkwYUdWeUlpd2lWMVFpT2pFeGZRPT18MXxNVFkzTlRJME1EZzJNamN3T1RzeE5qYzFNa</span></p>
<p>(I've trimmed off several lines of this for space-saving.)</p>
<p>So I started nosing around in the navigation links and found that the links that produced this behaviour were simply pointing at the top level of the site:</p>
<p><span style="font-family: courier;">https://xxx.sharepoint.com/sites/DataMI/</span></p>
<p>... with or without the closing slash.</p>
<p>Of course, in a Modern Experience site, you can't have a navigation link that doesn't have a URL ... so I switched those links to labels, which solved the problem temporarily.</p>
<p>If I pasted the URL of the actual Home page into the browser address window, I got the actual home page:</p>
<p><span style="font-family: courier;">https://xxx.sharepoint.com/sites/DataMI/SitePages/Home.aspx</span></p>
<p>And if I clicked on the <b>Home</b> link in the top navigation menu, I also got the Home page.</p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4VxYytdtqqxmd3xWyhr7dZZ7VO9s8yBjjEKGG-ek2CLoOX-wmcb-u28eZ7rZMudBRYyTFWwBiT63N74nB_EtXYQqBWc0IAaAkplyQBvHNe2TcHfE9ORVV2ufsnf4faJ9TOusNzgymIMbALzw_f297v8-ThSh-4S7K1QvDGaLuuSscQEKzI5VeOhBr/s612/pic02_HomePageLink.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="96" data-original-width="612" height="63" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4VxYytdtqqxmd3xWyhr7dZZ7VO9s8yBjjEKGG-ek2CLoOX-wmcb-u28eZ7rZMudBRYyTFWwBiT63N74nB_EtXYQqBWc0IAaAkplyQBvHNe2TcHfE9ORVV2ufsnf4faJ9TOusNzgymIMbALzw_f297v8-ThSh-4S7K1QvDGaLuuSscQEKzI5VeOhBr/w400-h63/pic02_HomePageLink.JPG" width="400" /></a></div><br />... but no great surprise, as this also had the full link to Home.aspx.<p></p>
<p>I began wondering if this was something to do with the setting of the default page for the site. So on a hunch, I found Home.aspx in the SitePages library and set it as the site default page.</p>
<p>Problem solved.</p><p>All I can think of is that at some time in the site's past, someone either deleted the default page (I don't know how, as SharePoint won't let you delete a designated default page) or found some way to NOT have a default page at all. The fact that the Home navigation link had the full URL of the Home page tends to support both those ideas.</p>
<p>Anyway, if you see this behaviour, now you know why.</p>
<p>I hope this helps someone.</p><p><br /></p>AirPiratePresshttp://www.blogger.com/profile/13136561512898563240noreply@blogger.com0tag:blogger.com,1999:blog-3023476837266527744.post-33182611751293534272022-12-22T13:10:00.002-08:002024-01-28T06:59:20.025-08:00Power Apps: Add person to SharePoint Name field via dropdown in Canvas App form<p><b>POWER APPS AND SHAREPOINT IS AN IMMENSELY POWERFUL COMBINATION</b> that allows you to construct time-saving automated applications that will save your colleagues valuable time when following business processes. But you knew that already, right?</p><p>I was recently working on a business process that required the Requestor choose an Approver from a list of authorised Approvers. Each area of the business had a different set of Approvers, and I wanted to make sure that the Requestor wasn't able to select the wrong Approver for their business area.</p>
<p>What's the problem, I hear you shout. Just whack in a ComboBox or a DropDown and off you go ... and, in truth, that's how I first approached the problem.</p><p>In addition to the main list which would hold the requests ("FAC") I created a lookup list ("FAClob") with two columns - a simple text column (I just used the existing <b>Title</b> column) to hold the Line of Business values and Person or group column to hold the corresponding Authorisers.</p>
<p></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDQkHW7Z3UEXEk_vC2P6PsOsQBRFcXw5j7iT5N2TcIM6ANq7wttscRe56ZYcdq8Z2xaYFDvtv535uuZXE4F17bsU0FtGGr1xrlceCJyEQeGtuEi6XFf4GJAjROd-Km4x0tu0-IL4XusGKuglsJMM5ZITnGwToa1OlNah1Z9uBiqiywagh2hpMHfqnb/s695/pic01_LookupList.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="430" data-original-width="695" height="248" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDQkHW7Z3UEXEk_vC2P6PsOsQBRFcXw5j7iT5N2TcIM6ANq7wttscRe56ZYcdq8Z2xaYFDvtv535uuZXE4F17bsU0FtGGr1xrlceCJyEQeGtuEi6XFf4GJAjROd-Km4x0tu0-IL4XusGKuglsJMM5ZITnGwToa1OlNah1Z9uBiqiywagh2hpMHfqnb/w400-h248/pic01_LookupList.JPG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>Here's the lookup list. Normally, I'd order by the Title column, but here I've ordered by the Underwriter column to show that the Title column contains an assortment of duplicate values.</i></td></tr></tbody></table><p></p>
<p>I did then try to integrate the lookup list into the main list by adding a lookup column and pointing it at my LoB/Authorisers lookup list ... but quickly realised that was not the right approach. Far better to handle the looking up in the actual Canvas App that will handle the Requestors' submissions to the main list. So I deleted lookup column in the main FAC list and instead added a simple text field for the Line of Business and a Person or group field for the Authoriser.</p>
<p></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjHLbkmVx9kfbPAN9OW0EX5HDHiCG6x61OAhaEBwBhzCqlz2xMkTj71lodTPE2lVVElzglWyeJRAWb7Pm7SdgRPeQcjkf5znWcSYRxjS1c2Ne-acFoCR_62zMfpwb1frL-1xBak6j6rUbk8KwIcqKtZGkGrKA93AMv6MTe2-moU1St6EisbWJzuNpM/s541/pic02_LookupColumns.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="250" data-original-width="541" height="185" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjHLbkmVx9kfbPAN9OW0EX5HDHiCG6x61OAhaEBwBhzCqlz2xMkTj71lodTPE2lVVElzglWyeJRAWb7Pm7SdgRPeQcjkf5znWcSYRxjS1c2Ne-acFoCR_62zMfpwb1frL-1xBak6j6rUbk8KwIcqKtZGkGrKA93AMv6MTe2-moU1St6EisbWJzuNpM/w400-h185/pic02_LookupColumns.JPG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>Here's the corresponding columns in the main FAC list.</i></td></tr></tbody></table><p></p>
<p>So next I switched over to Power Apps, refreshed the DataSources to ensure that my app was looking at the latest versions of the lists, then set about adding the two new FAC fields to the New Form I was working on ...</p>
<p></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFXEuP79cpdH3cR54hZQzn_CuSzMf7IQt0MD-yDYb-E27gZWVXfL5xRHzPF1e3xmq8ckRyqqVpj5NdL_hBsA1hBGexygdhxhMEqPsPADzaNPhkFrrSPNitymClZ39DVL-7OVf9rX_4paJENRTuAMo6kl7KVl4xkV3nrmsS7HlSE_c4nl99e3aMQOTV/s519/pic03_LookupCBs.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="177" data-original-width="519" height="136" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFXEuP79cpdH3cR54hZQzn_CuSzMf7IQt0MD-yDYb-E27gZWVXfL5xRHzPF1e3xmq8ckRyqqVpj5NdL_hBsA1hBGexygdhxhMEqPsPADzaNPhkFrrSPNitymClZ39DVL-7OVf9rX_4paJENRTuAMo6kl7KVl4xkV3nrmsS7HlSE_c4nl99e3aMQOTV/w400-h136/pic03_LookupCBs.JPG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>Here's the new fields with the dropdowns already in place.</i></td></tr></tbody></table><p></p>
<p>With the fields in place in the Canvas App Form, I then set up the Line of Business DataCard. I added a DropDown to the DataCard and renamed it ddLoB. Then, switched to Advanced in the dropdown's Property panel and set the Items value to:</p><p><span style="font-family: arial;"><b>ddLoB.Items =</b></span><span style="font-family: courier;"> Distinct(FAClob,Title)</span></p><p>and</p><p><span style="font-family: arial;"><b>ddLoB.Value =</b></span><span style="font-family: courier;"> Result</span></p>
<p></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinxoDBJaBYfiqtdd9DQQ7ZVFcaup9-zFqBaQ_xmKPbuTt7-Dq-IhLhsh7j8qj8gMJjSS3Nl1yNEli0w0-4aCb5cIsmCJo-6hnVxQLtDui1qz68iBOU9OByGS-2-bpPR3awz37kvu5SGjfddFmoRXNq_LxdncjE4Bd1Ck2tEjiTLR8r3zubMy10lqLw/s319/pic04_ddLoB.jpg" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="224" data-original-width="319" height="281" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinxoDBJaBYfiqtdd9DQQ7ZVFcaup9-zFqBaQ_xmKPbuTt7-Dq-IhLhsh7j8qj8gMJjSS3Nl1yNEli0w0-4aCb5cIsmCJo-6hnVxQLtDui1qz68iBOU9OByGS-2-bpPR3awz37kvu5SGjfddFmoRXNq_LxdncjE4Bd1Ck2tEjiTLR8r3zubMy10lqLw/w400-h281/pic04_ddLoB.jpg" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>You can leave the pane's Default value as "1", the Defaults default value, as changing it doesn't seem to do anything.</i></td></tr></tbody></table><p></p>
<p>The "Distinct" ensures that we only display one of each of the LoB values from the lookup list.</p>
<p>Next, we need to set up the DataCard by editing a couple of fields in the DataCard's Advanced Properties pane ...</p>
<p></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5eToN76LdPYibw7cInvN39bFPMZZpnB0ud-Kb0d6We2y5lQ38w2tAcVNhbgkCfoXbGTSb7VT3efVV5fHCgFVCukfexNfr-ccq9h7CPAyW1jvoCjJ0AnAS9QYGYKXzl7BQm4ihFusRHmX7BEV9-dvXHfc6ptjxzHShF1YGgC9u7BXYFj7IpnLlCL8m/s318/pic05_LoB-DataCard.jpg" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="145" data-original-width="318" height="182" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5eToN76LdPYibw7cInvN39bFPMZZpnB0ud-Kb0d6We2y5lQ38w2tAcVNhbgkCfoXbGTSb7VT3efVV5fHCgFVCukfexNfr-ccq9h7CPAyW1jvoCjJ0AnAS9QYGYKXzl7BQm4ihFusRHmX7BEV9-dvXHfc6ptjxzHShF1YGgC9u7BXYFj7IpnLlCL8m/w400-h182/pic05_LoB-DataCard.jpg" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>We need the single quotes around '1-LoB' because it contains a hyphen.</i></td></tr></tbody></table><p></p>
<p>The default value should already be set to <span style="font-family: courier;">ThisItem.'1-LoB'</span> (the single quotes are needed because I called my SharePoint List column <b>1-LoB</b>, denoting this is a field for Form 1 in the process), but we have to change the Update value to:</p>
<p><span style="font-family: arial;"><b>1-LoB_DataCard1.Update =</b></span> <span style="font-family: courier;">ddLoB.SelectedText.Value</span></p>
<p>Right ... that's the Line of Business field taken care of. Next, the Authoriser field.</p>
<p>What I need to do here is to make sure that when a requestor selects a Line of Business from the dropdown, the choice of authoriser is limited to the corresponding names from the lookup list. So I added a dropdown ("ddAUW") to the Authorisers DataCard and set these fields in the Properties/Advanced window ...</p>
<p><span style="font-family: arial;"><b>ddAUW.Items =</b></span> <span style="font-family: courier;">Distinct(Filter(FAClob,Title = ddLoB.SelectedText.Value),Underwriter.DisplayName)</span></p>
<p><span style="font-family: arial;"><b>ddAUW.Value =</b></span> <span style="font-family: courier;">Result</span></p>
<p></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZrsqmOKeo3JlW4CwfzzuMsmR2OeJ2e0jozFCouhMpCwxvAUrLbtm2R0pHXXFbm5u43g5xF8DhBQkzXKcD0aZJNPzFkAVCEpg6zeInCtldzJMbTQggTJwKqDlaKuR17l48M2PDNpZrT1zlJ8c7gBAJ-AZrHfa7SE1y8zrjYi4SUUdB9AH-PYEX603E/s318/pic06_ddAuthoriser.jpg" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="263" data-original-width="318" height="331" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZrsqmOKeo3JlW4CwfzzuMsmR2OeJ2e0jozFCouhMpCwxvAUrLbtm2R0pHXXFbm5u43g5xF8DhBQkzXKcD0aZJNPzFkAVCEpg6zeInCtldzJMbTQggTJwKqDlaKuR17l48M2PDNpZrT1zlJ8c7gBAJ-AZrHfa7SE1y8zrjYi4SUUdB9AH-PYEX603E/w400-h331/pic06_ddAuthoriser.jpg" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"></td></tr></tbody></table><p></p>
<p>The Authorisers dropdown's Items formula is a little more complicated because a Person or Group field holds a table rather than a single value, and we have to tell the dropdown which part of the table to return.</p>
<p>Then I turned my attention to the Update value in the DataCard ... and initially I fell into the trap of thinking I could just update the SharePoint list with a value from the Authoriser dropdown. Like this:</p>
<p><span style="font-family: arial;"><b>1-AuthorisingUW_DataCard1.Update =</b></span> <span style="font-family: courier;">ddAUW.Result</span></p>
<p>I was just using a submit button to send the form's values to the SharePoint list, with the simple command:</p>
<p><span style="font-family: arial;"><b>Submit_Button.OnSelect =</b></span> <span style="font-family: courier;">Submit(Form1)</span></p>
<p>But, of course, it didn't work. And, of course, it couldn't be as simple as that, could it?</p>
<p>So I asked my colleague Ernani if he had any idea what was going on. He suggested switching out the simple Submit button for a patch function, and even went to the trouble of writing the patch formula for me ... which was great, and it worked. But I like simplicity, and I felt that as I developed the forms needed for the whole application, having complex patches instead of simple Submits might become an albatross around my neck.</p>
<p>So, I wondered if I could take the section of the patch formula that sends the Authoriser details to the SharePoint list and instead pasted that code into the DataCard's Update action, that might serve the same function, while still allowing me to use a simple submit button. Here's the formula:</p>
<p><span style="font-family: courier;">{ </span></p>
<p><span style="font-family: courier;">'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser", </span></p>
<p><span style="font-family: courier;">Claims: "i:0#.f|membership|" & LookUp(</span></p>
<p><span style="font-family: courier;"> FAClob,</span></p>
<p><span style="font-family: courier;"> Underwriter.DisplayName = ddAUW.SelectedText.Value,</span></p>
<p><span style="font-family: courier;"> Underwriter.Email</span></p>
<p><span style="font-family: courier;">),</span></p>
<p><span style="font-family: courier;">DisplayName: "",</span></p>
<p><span style="font-family: courier;">Email: LookUp(</span></p>
<p><span style="font-family: courier;"> FAClob,</span></p>
<p><span style="font-family: courier;"> Underwriter.DisplayName = ddAUW.SelectedText.Value,</span></p>
<p><span style="font-family: courier;"> Underwriter.Email</span></p>
<p><span style="font-family: courier;">)</span></p>
<p><span style="font-family: courier;">}</span></p>
<p>And here's what it looks like in place:</p>
<p></p><p></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiABf38h8x6rfa3WrAsz8CrUq8HD0nC8NbeKYZz8TfpMTioU463pLLF10C5oE4G_7uKaV4c79tJOI63nGkry30w3mxScbyHCWpRs9AzaIRU8vgw1WlUfEbDyxW8LzLuTJInayuumzXmQNZjCn4mEEbVqK8W2KfIhuMBRs4rEUKDtCT-N5WRBx-84yCV/s321/pic07_Authoriser-DataCard.jpg" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="321" data-original-width="318" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiABf38h8x6rfa3WrAsz8CrUq8HD0nC8NbeKYZz8TfpMTioU463pLLF10C5oE4G_7uKaV4c79tJOI63nGkry30w3mxScbyHCWpRs9AzaIRU8vgw1WlUfEbDyxW8LzLuTJInayuumzXmQNZjCn4mEEbVqK8W2KfIhuMBRs4rEUKDtCT-N5WRBx-84yCV/w396-h400/pic07_Authoriser-DataCard.jpg" width="396" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>This is what the Advanced properties looks like after adding the formula.</i></td></tr></tbody></table><br />Then I just checked that the Default value of the DataCard was:<p></p><p><span style="font-family: arial;"><b>1-AuthorisingUW_DataCard1.Default =</b></span> <span style="font-family: courier;">ThisItem.'1-AuthorisingUW'</span></p>
<p>And you know what? When I tested it, it worked!</p>
<p>There's a lot more to this particular form than what I've outlined above, but for me, the key breakthrough was the updating of the SharePoint Person and Group field from a Power Apps dropdown.</p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUBz_AlosyphkYKi9f1AhaJ3lFnclqISk4P4MHyO2a27-g-z_-OXg7GABvvIdi05T6TxIs_Z2aYYQojTH0iqQxI7XP_u-qRBsJ0bGT8pNqpD1D4GbVyc5fYXwSvo26_mqvQleOvF_Sr6e_bupVPo9PdRA6rPFYXvb4zhpcGjGIARcIdZBtgHWSXRITNJk/s493/pic08_Authoriser-dropdown.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="238" data-original-width="493" height="193" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUBz_AlosyphkYKi9f1AhaJ3lFnclqISk4P4MHyO2a27-g-z_-OXg7GABvvIdi05T6TxIs_Z2aYYQojTH0iqQxI7XP_u-qRBsJ0bGT8pNqpD1D4GbVyc5fYXwSvo26_mqvQleOvF_Sr6e_bupVPo9PdRA6rPFYXvb4zhpcGjGIARcIdZBtgHWSXRITNJk/w400-h193/pic08_Authoriser-dropdown.jpg" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>Here's what the final cascade looks like ... select UK Casualty in the Line of Business dropdown and the Authorising Underwriters are restricted to those who can sign off requests for that business area.</i></td></tr></tbody></table><br />I hope this helps someone.<p></p>
<p><br /></p>
<p><br /></p>
<p><br /></p>
<p><br /></p>
<p><br /></p>AirPiratePresshttp://www.blogger.com/profile/13136561512898563240noreply@blogger.com0tag:blogger.com,1999:blog-3023476837266527744.post-11664026172294941812022-06-04T09:06:00.005-07:002022-07-12T04:07:09.444-07:00Simple approval form with PowerApps, Deep Links and Flow<p><b>I STRUGGLED WITH THIS FOR A COUPLE OF DAYS BEFORE REALISING</b> that Microsoft had recently moved the goalposts on how Deep Linking works in PowerApps. Consequently, many of the "how-to" instructions on the Internet have been rendered inaccurate. It wasn't until I stumbled across a post on the Microsoft site that I realised something had been fundamentally changed.</p><p>So I'll go through the method that worked for me, and add comments on what I was doing wrong as I go ...</p><h3 style="text-align: left;">THE REQUIREMENT WAS ...</h3><p>... the client wanted to create a process where colleagues could request a report from a database. The request would be forwarded to an authoriser, who would add a few more details to the request and save their amendments to the queue.</p><p>A SharePoint list seemed the best way to do this and I thought all I needed to do was to create a Canvas App in PowerApps and then pass the ID of the newly-created list item to an EditForm, the method referred to as "deep linking".</p><p>I'd started on a similar project in November 2021, but it never progressed beyond the early stages. Nonetheless, I figured I could re-use some of the tech from that project in this new one. That was my first mistake.</p><p>I figured I needed to add an "If" statement to the <b>OnStart</b> control of the App in the canvas app, so we would know whether this was a call for a NewForm or an EditForm ... something like:<br /></p><p><b>App.OnStart</b> = <span style="font-family: courier;">If(<br /> !IsBlank(Param("ID")),<br /> Set(<br /> varID,<br /> Value(Param("ID"))<br /> );<br /> Navigate(Screen2)<br />)</span></p><p>... ought to work, right?</p><p>Except that PowerApps told me I couldn't have "Navigate" in the <b>OnStart</b> control.</p><p>So I tried other combinations, searched on Google for a day or two and was just about to beg a colleague for some help when I found a mention in a Microsoft blog that good ol' MS had changed the way the <b>App.OnStart</b> and <b>App.StartScreen</b> works.</p><p>It's probably my fault for not following the PowerApps roadmap more closely, but still ...</p><p>Anyway, piecing together the info from the Microsoft blog and the work I'd done on the earlier project, I was able to figure out a way to get a working app for my client, and ...</p><h3 style="text-align: left;">THIS IS HOW I DID IT</h3><p>I won't bother going in to how you add fields to a Canvas App ... there's plenty of other blogs that tell you how to do that. So let's assume you have a SharePoint List configured to hold answers to questions you want to ask. And let's assume you have created a Canvas App and you've set the SharePoint List as the App's data source and added the necessary Form fields. Let's take a look at what the Canvas App looks like at this stage.</p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguQYnCbYnLlkFO-SF6SL-xurLvfB4I_UbGL3gaQaQssKOdoYvm3EN_xc7v-JXc55PdDSCruXEyHkW6MeoYa3t4RAwNvKlzJBC9-0sCoSbh_5yejQmS4Ozxk2F0AImwq8pWFKCNkMLx89va6D-KmeSl5L7stoTinqs5mWVnVTh_9tBQd511OIdV6Zds/s1431/pic01_StartScreen.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="876" data-original-width="1431" height="245" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguQYnCbYnLlkFO-SF6SL-xurLvfB4I_UbGL3gaQaQssKOdoYvm3EN_xc7v-JXc55PdDSCruXEyHkW6MeoYa3t4RAwNvKlzJBC9-0sCoSbh_5yejQmS4Ozxk2F0AImwq8pWFKCNkMLx89va6D-KmeSl5L7stoTinqs5mWVnVTh_9tBQd511OIdV6Zds/w400-h245/pic01_StartScreen.JPG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>Screen1 is the part that acts like a NewForm. The requestor fills in the visible fields and clicks <b>Submit</b> to save the data to the list.</i></td></tr></tbody></table>So we leave the <b>App.OnStart</b> control blank, as we no longer have a need to set a variable and we can't use it to Navigate. Instead, we put this expression in the <b>App.StartScreen</b> control:<div><br /></div><div><b>App.StartScreen</b> = <span style="font-family: courier;">If(Value(Param("parID")) >= 1, Screen2, Screen1)</span><br /><div><p>What we're saying here is, if the value of the parameter we pass to the App in the query string (which we'll get to later) is equal to or greater than the numerical value "1", go to Screen2 ... otherwise, go to Screen1.</p><p>Wrapping the 'Value ()' around the 'Param("parID")' expression makes sure we're using a number rather than a text string.</p><p>Simple, yes?</p><p>Now we jump to the Form in Screen2 and add an expression into its <b>Item</b> control.</p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgy821uO-DpcndfOVs3CPRWFyCiW9dfFKV91CNuhXDvCljy-_ea-5zCfuT_Rdpb5KNYJi6zn2jzj0sgn2nYWjS54TUWzDLbzmuiCEd3lNDq9q4OyF6iGKdLmgozNKAt_kAwz3kzEK8PAcaKVZwkHr8WzBD-hEZpixgy165T_IR1po4z71Frs-_3qehj/s1428/pic04_Form2-Item.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="877" data-original-width="1428" height="246" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgy821uO-DpcndfOVs3CPRWFyCiW9dfFKV91CNuhXDvCljy-_ea-5zCfuT_Rdpb5KNYJi6zn2jzj0sgn2nYWjS54TUWzDLbzmuiCEd3lNDq9q4OyF6iGKdLmgozNKAt_kAwz3kzEK8PAcaKVZwkHr8WzBD-hEZpixgy165T_IR1po4z71Frs-_3qehj/w400-h246/pic04_Form2-Item.JPG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>Screen2 will hold the form we're using as the EditForm. We need to set it up to receive the ID passed to it in the query string.</i></td></tr></tbody></table>The expression is:</div></div><div><br /></div><div><b>Form2.Item</b> = <span style="font-family: courier;">LookUp('MI Requests', ID=Value(Param("parID")))</span></div><div><br /></div><div>This is just saying, go and find the item in the list (MI Requests) whose ID matches the value in the query string that was just passed to you.</div><div><br /></div><div>That's that part done. Next, let's get the <b>Submit</b> buttons set up.</div><div><br /></div><div>For the first form, use this submit expression.</div><div><br /></div><div><b>Button1.OnSelect</b> = <span style="font-family: courier;">SubmitForm(Form1); Navigate(Screen3, ScreenTransition.Fade)</span></div><div><br /></div><div><div>For the second form, use this submit expression.</div><div><br /></div><div><b>Button2.OnSelect</b> = <span style="font-family: courier;">SubmitForm(Form2); Navigate(Screen3, ScreenTransition.Fade)</span></div><div><span style="font-family: courier;"><br /></span></div><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUad78k94aEo6yzb_-Hj5-xHk5RNcWu9F7tyo61mR5yBwhOQRR2-cNjhPcgRBZPvNKNb31U01qDuB8y8rP5cH7ykF6n-CfrsTKj4t1KSjftGM5wzfVQ7mnoXBkoyGl9QjxFGcDO7AAnNWWi6kiapO00FE3ZiqBlbwL5TtOakbsa8sxQZ5Vzh90VPyU/s1427/pic05_Form2-Submit.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="877" data-original-width="1427" height="246" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUad78k94aEo6yzb_-Hj5-xHk5RNcWu9F7tyo61mR5yBwhOQRR2-cNjhPcgRBZPvNKNb31U01qDuB8y8rP5cH7ykF6n-CfrsTKj4t1KSjftGM5wzfVQ7mnoXBkoyGl9QjxFGcDO7AAnNWWi6kiapO00FE3ZiqBlbwL5TtOakbsa8sxQZ5Vzh90VPyU/w400-h246/pic05_Form2-Submit.JPG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>Here's the submit expression for the second <b>Submit</b> button ... pretty similar to the <b>Submit</b> button for Form1.</i></td></tr></tbody></table><div>And the query string (told you we'd get to it) to guide your approver to the second (EditForm) form is:</div></div><div><br /></div><div>https://apps.powerapps.com/play/[yourAppID]?[yourTenantID]&parID=[ID]</div><div><br /></div><div>Strictly speaking, you only need the [yourTenantID] part if you expect to be using this form outside of your organisation, but I've included it here for the sake of clarity. The [ID] value you will retrieve in the Flow when you create the dynamic link as part of your request/approval process.</div><div><br /></div><div>But in the meantime, you can test that your forms are working correctly by substituting the [ID] value in the above query string with an actual ID value for an item in your list.</div><div><br /></div><h3 style="text-align: left;">GO WITH THE FLOW</h3><div>As with the PowerApp form, I'm not going to go through every step of creating the Flow to send the link to your approver person, but let's just quickly look at how you create the dynamic link that sends the query string to the form.</div><div><br /></div><div>I find this works best if you add a <b>Send an Email (V2)</b> action in the Flow. In my application, I set up a Condition to check whether the incoming list-change included a value for the Status field (which the requestor's form doesn't include). If not, it was a request for a New Item. If it did, then it was an Edit Item change and as such needed no further action ... up to you whether you elaborate on that.</div><div><br /></div><div>But the key bit is ... in the <b>Send an Email (V2)</b> action, switch to HTML view then build the link like this:</div><div><br /></div><div><span style="font-family: courier;"><a href="https://apps.powerapps.com/play/[yourAppID]?[yourTenantID]&parID=<span style="background-color: #01ffff;">[ID]</span>" Review the request and add any relevant information to the form</a><br /></span></div><div><span style="font-family: courier;"><br /></span></div><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjY6bNRTxisqiApFrbQ6w-gPULecwGEjydzulRaD1rQ_WTXSx4Kj49_d9xHn6fVlgnCP_W0pIPaJcgc3zi5lJxUruOHjDOQQndD_GAeeZoXrkFWYZpqhiWNaadCWwG2q-9PaI_uudbZ9gZ8qdPqzIo61oEh0rg5_TvJyu6UDa1WbZenKf3gYYxcV2PK/s695/pic06_Flow_DeepLink.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="695" data-original-width="634" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjY6bNRTxisqiApFrbQ6w-gPULecwGEjydzulRaD1rQ_WTXSx4Kj49_d9xHn6fVlgnCP_W0pIPaJcgc3zi5lJxUruOHjDOQQndD_GAeeZoXrkFWYZpqhiWNaadCWwG2q-9PaI_uudbZ9gZ8qdPqzIo61oEh0rg5_TvJyu6UDa1WbZenKf3gYYxcV2PK/w365-h400/pic06_Flow_DeepLink.JPG" width="365" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>Switching the body of the email action to HTML view really helps you get the dynamic ID in the right place. You'll struggle otherwise.</i></td></tr></tbody></table><div>You'll need to swap out the [ID] for the actual dynamic ID from the <b>When an item is created or modified</b> section.</div><div><br /></div><div>Now, when you fill in Form1 and submit, the new item is created. The Flow sends an email containing the link/query string to the reviewer/approver. When they click on the link, the form opens the submitted item's Edit Form, like this ...<br /></div><div><br /></div><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2vrVIeJ1dNEltYEEySu_NHFFYoiL2OY3qMeKVw5THpJd1WrmOqdJsDMiI7Z2I15YXz9z7gI2kZwRlHch0LeceHhEeXOtspiDZmxXchwTkNGe5OiSYSWuCNWdwwxoQ4rfQQyMhJeaRGmElxmX9mzHygKtBY6RlBYTETK31f4zw6Ym1Z_6-TYlDhrRW/s908/pic07_EditForm.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="908" data-original-width="564" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2vrVIeJ1dNEltYEEySu_NHFFYoiL2OY3qMeKVw5THpJd1WrmOqdJsDMiI7Z2I15YXz9z7gI2kZwRlHch0LeceHhEeXOtspiDZmxXchwTkNGe5OiSYSWuCNWdwwxoQ4rfQQyMhJeaRGmElxmX9mzHygKtBY6RlBYTETK31f4zw6Ym1Z_6-TYlDhrRW/w249-h400/pic07_EditForm.JPG" width="249" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>For ease of use, I displayed the requestor's data in non-editable fields in the top half of Form2, and placed the fields the reviewer needs to complete in the lower half.</i></td></tr></tbody></table><div>The pale blue section at the top of the form shows the data that was submitted by the requestor, the white section of the form shows the data added by the reviewer/approver.</div><div><br /></div><div>And that should be it, really ... Though I found the Microsoft change annoying at first, it does make for a cleaner and simpler PowerApp in the end.</div><div><br /></div><div>I hope this helps someone ...</div><div><br /><br />PS - [Here's the link to <a href="https://powerapps.microsoft.com/en-us/blog/app-startscreen-a-new-declarative-alternative-to-navigate-in-app-onstart/" target="_blank">blog that explains Microsoft's changes</a>.]</div>AirPiratePresshttp://www.blogger.com/profile/13136561512898563240noreply@blogger.com0tag:blogger.com,1999:blog-3023476837266527744.post-85975340386597816412022-04-12T08:11:00.002-07:002023-08-06T13:49:21.277-07:00Why doesn't SharePoint understand British Summer Time?<p><b>I'VE HAD THIS PROBLEM A COUPLE OF TIMES ... </b>you add some fiddly code to your Flow (or Workflow) to generate a handy Calendar Invite (.ics file) for your end user, but the resulting calendar entry is an hour out. For some reason, Microsoft have never been able to offer us anything other than UTC time in SharePoint and Outlook. And it's an awful pain for us developers.</p><p>I was creating a Meeting Calendar for an event our company would be attending. My colleagues would need to book the meeting space set aside for our company to use at the event, and it made sense for us to offer an automated booking service for those attending.</p>
<p>I could have used a SharePoint Calendar as the starting point, but I wanted to have something a bit more user-friendly, so I opted for a SharePoint Custom List. This would also give me a bit more control over the fields in the list.</p>
<p>So I set up the list and modified the input form in PowerApps to make it a bit more visually attractive (exactly how that's done can be discovered with a quick Google search - it's outside the scope of this article) and I ended up with something like this:</p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhopjRfDUHYJaR0PesGt-9FX1rHagzb7IC4KDyftveLKEzcnTOsYkvDmeOFnz79vO8IGU0DAA1HVzBFBU1vcz-UiDiYDdWgHr-265iZjgP126EiVnz3d6Bnp-Jr-grYpPk2IHaPc-_9L5MdTEPn7pp33lTwfnhz_qxUaC1i3K5ZGW8AvN2NQKDGONwT/s1500/pic01_PowerAppsInputForm.jpg" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="868" data-original-width="1500" height="231" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhopjRfDUHYJaR0PesGt-9FX1rHagzb7IC4KDyftveLKEzcnTOsYkvDmeOFnz79vO8IGU0DAA1HVzBFBU1vcz-UiDiYDdWgHr-265iZjgP126EiVnz3d6Bnp-Jr-grYpPk2IHaPc-_9L5MdTEPn7pp33lTwfnhz_qxUaC1i3K5ZGW8AvN2NQKDGONwT/w400-h231/pic01_PowerAppsInputForm.jpg" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>To keep things simple, I'm asking the user to just select a Date, Time and Duration of the meeting they want to book. (They're also asked to select a Venue, but that's not important right now.)</i></td></tr></tbody></table>
<p>You can see that all the attendee has to do is add the Name of the Host (Name field) - the person filling in the form may not be the meeting host - add the names of any colleagues who may also be attending, then select the
<b>Date</b> of the meeting, the <b>Time</b> of the meeting and the <b>Duration</b> of the meeting. I was planning to have the Power Automate Flow do the configuring of the <b>EventDate</b> and <b>EndDate</b> for the meeting.</p>
<p>I'm deliberately mimicking the column names that are found in Calendars, as these are needed when it comes to generating the .ics file later in the process. It doesn't hurt to have a <b>Location</b> column as well.</p>
<p>These three columns are hidden (and not included in the NewForm) because the user never needs to see them.</p>
<h3 style="text-align: left;">ADDING EXTRA COLUMNS TO THE LIST</h3>
<p>So, the Venue, Date, Time and Duration fields are simple Choice columns in the SharePoint list, which return text values. If I was going to generate an iCalendar file, then I'd need to convert that text into valid Dates and Times. It's probably possible to do that in PowerApps (and I will have a think about that for next time), but because I wanted to get it done, I chose the Power Automate route.</p>
<p>I created an "On create" Flow and added the Site and List. Then I added the <b>Update Item</b> and <b>Send an Email</b> components. We'll fill those in later. But mainly, I needed to figure out a way to transform the simple text values in the List into properly formatted DateTime values. Then I discovered the <b>Compose</b> action.</p>
<p>It's funny how you can use a platform for years, yet still discover new things about it. I'd never come across <b>Compose</b> before, but what a great tool ...</p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5zjlFLjqNUT-cU71YUAE-0qjh9wvOzdcCuqyp0pyfUfNuQiXFqr00ZlvCDJPMBVlnIVB6lRiROKsSZ3zubrS21V_8jolHaNKTe2fuFJ7-vS0YBHWYH_-RV5Rgb1awBpdR5YPVmPHWUdHwYOLBAA_K2-eVG8E3YlPSORCvQR4ljW5BR_vsJdNU5g9R/s698/pic02_Flow-Compose.jpg" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="698" data-original-width="631" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5zjlFLjqNUT-cU71YUAE-0qjh9wvOzdcCuqyp0pyfUfNuQiXFqr00ZlvCDJPMBVlnIVB6lRiROKsSZ3zubrS21V_8jolHaNKTe2fuFJ7-vS0YBHWYH_-RV5Rgb1awBpdR5YPVmPHWUdHwYOLBAA_K2-eVG8E3YlPSORCvQR4ljW5BR_vsJdNU5g9R/w361-h400/pic02_Flow-Compose.jpg" width="361" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>The Compose action is an absolute wonder ... I'm so annoyed that I didn't know about it before ...</i></td></tr></tbody></table>
<p>I added a couple of Compose actions then set about adding the scripting that would do the conversion. The trickiest was the Date. The scripting was fairly straightforward, but I did get some unexpected results, at first. So, use formatDateTime and transform the text value into a date by typing this script:</p>
<p><span style="font-family: courier;">formatDateTime(triggerOutputs()?['body/Date/Value'],'yyyy-MM-dd')</span></p>
<p>... into the <b>Expression</b> area of the Compose function's Dynamic Content, here:</p>
<div style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEis2nV1uxln3D8exDu1fbdl1FCU9FuaPsiOqS_IoQ4PtK_XDxizV2sn9-SCdoC3LlNQfETXc6z5x31Icfem7lrQItn4QM7VSnh1nQla1-lp2AYr8_IBa6C8tpngpqkkL0R8AGkbul6NGCJvlRQG27_Cq4TK9AimkqkP9jILKi2RlRwqqSWA4MIT-I3q/s430/pic03_ComposeDate.JPG"><img border="0" data-original-height="312" data-original-width="430" height="290" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEis2nV1uxln3D8exDu1fbdl1FCU9FuaPsiOqS_IoQ4PtK_XDxizV2sn9-SCdoC3LlNQfETXc6z5x31Icfem7lrQItn4QM7VSnh1nQla1-lp2AYr8_IBa6C8tpngpqkkL0R8AGkbul6NGCJvlRQG27_Cq4TK9AimkqkP9jILKi2RlRwqqSWA4MIT-I3q/w400-h290/pic03_ComposeDate.JPG" width="400" /></a></div>
<p>However, when I tested the output of <b>Compose - Date</b> action, the result was a scrambled date which had reversed the Day and Month values, so instead of 11th of May, it was rendering as 5th December. Straightaway, I checked the Region Setting of the parent site, but that was set to "English (UK)" and to the correct London TimeZone.</p>
<p>So why it was rendering the date incorrectly, I have no idea. And rather than spending ages trying to figure it out, I cheated and changed the formula to:</p>
<p><span style="font-family: courier;">formatDateTime(triggerOutputs()?['body/Date/Value'],'yyyy-<span style="background-color: #ffa400;">dd-MM</span>')</span></p>
<p>... which did the trick!</p>
<p>Once I had the Date rendered correctly, I had to append the chosen time to it. This is where the second <b>Compose</b> action comes in. Using the concatenate command, I built this expressions and added it to the Expression field of the "Compose_-_Full_DateTime" action:</p>
<p><span style="font-family: courier;">concat(outputs('Compose_-_Date'),'T',triggerOutputs()?['body/Time/Value'],':00Z')</span></p>
<div style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHFDC73sLlR5L_WZz7NY3SAViIcFpvkbwMu2IUPVcfPf5C66XOpYP6sfH9KzLOgnJ8GT4swKKe_b6vcXiMq-3gGHk9c48KRQnK5NjqYqeW5251zPbxfwD4cBW7R3PmA1yXTmmxzdSyrDCGr4Ty6y_YtShilqB8H7h0YWjqkbzMK890VJAMpM6ZrTUI/s424/pic04_ComposeDateTime.JPG"><img border="0" data-original-height="319" data-original-width="424" height="301" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHFDC73sLlR5L_WZz7NY3SAViIcFpvkbwMu2IUPVcfPf5C66XOpYP6sfH9KzLOgnJ8GT4swKKe_b6vcXiMq-3gGHk9c48KRQnK5NjqYqeW5251zPbxfwD4cBW7R3PmA1yXTmmxzdSyrDCGr4Ty6y_YtShilqB8H7h0YWjqkbzMK890VJAMpM6ZrTUI/w400-h301/pic04_ComposeDateTime.JPG" width="400" /></a></div>
<p>All I've done here is build a DateTime value by structuring it in a format that SharePoint understands, eg:</p>
<p><span style="font-family: courier;">2022-05-11T10:00:00Z</span></p><p>The real puzzler came when I tested the Flow to see whether the above would help me generate a calendar invite for the end user.</p>
<h3 style="text-align: left;">SO ... WHY <i>DOESN'T</i> SHAREPOINT UNDERSTAND BST?</h3>
<p>There is annoying glitch in SharePoint where the TimeZone of a site can only be set to a UTC value. In the case of the "00:00 Dublin, Edinburgh, Lisbon, London" setting, that translates to Greenwich Meantime ... which isn't a problem in the winter, but becomes an issue in the Summer when UK clocks are wound forward by an hour. (I think in the US, this is referred to as Daylight Saving Time).</p><p>The result is that when you set a DateTime value in SharePoint and copy it over to Outlook, the date goes in at an hour ahead of the time you wanted.</p>
<p>There doesn't seem to be a fix for this and, though it comes up in many SharePoint and Microsoft forums, no one at Microsoft seems to have the appetite to fix it.</p><p>The upshot of this is, I needed to find a way to compensate for this anomaly myself.</p>
<p>Luckily, I found a function in my list of Flow actions called <b>Subtract from time</b>. I added the action, changed its name to "Subtract from Time - Because of BST" to remind me of why it's there when I come back a few weeks from now, then just set it to the following:</p>
<p></p>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnVtr8VUZvcajeHtS1NW33IqRJU9JFM_IHIltHeWng9U78ia9bGLiZ6OHbQw4RiqA0rAVamBS_cQv9qiM-hxa2fCgw0NWf7DnP9p6VLN0PXVxwTV1M7KDXR8LI4RDOy5atZBrMhc300QcJeZcH0kzYVZkaTgoohWFcjeeYnKkxwv_WGIoXi5GPK10k/s640/pic05_SubtractFromTime.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="228" data-original-width="640" height="143" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnVtr8VUZvcajeHtS1NW33IqRJU9JFM_IHIltHeWng9U78ia9bGLiZ6OHbQw4RiqA0rAVamBS_cQv9qiM-hxa2fCgw0NWf7DnP9p6VLN0PXVxwTV1M7KDXR8LI4RDOy5atZBrMhc300QcJeZcH0kzYVZkaTgoohWFcjeeYnKkxwv_WGIoXi5GPK10k/w400-h143/pic05_SubtractFromTime.JPG" width="400" /></a></div><br />
<p>The Base time is set to the output from the previous action <b>Compose - Full DateTime</b>. The Interval is set to 1 and the Time unit is Hour. That's it.</p><p></p><p>Now we have all the components in place to configure the <b>Update item</b> action.</p>
<p>So open up the <b>Update item</b> panel and set it up like this:</p>
<p></p>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqFqd9lUvcsIR8p6YESN71QdE4Qseb71v2nvwUDjOzbOZflHseXkhK4q7nsvOM0YmMOVVJCSPCMkKTQFX97ixVnjLgWkcDj-Q0ovjsZWcZWqnvnHUCBNE8gywcoj4lGv9y5C19ca6I9diUAvTV17sBQe0vtFtU6KxM4uidbrUBjYgFeZKOSjdsCL-J/s848/pic06_UpdateItem.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="848" data-original-width="633" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqFqd9lUvcsIR8p6YESN71QdE4Qseb71v2nvwUDjOzbOZflHseXkhK4q7nsvOM0YmMOVVJCSPCMkKTQFX97ixVnjLgWkcDj-Q0ovjsZWcZWqnvnHUCBNE8gywcoj4lGv9y5C19ca6I9diUAvTV17sBQe0vtFtU6KxM4uidbrUBjYgFeZKOSjdsCL-J/w299-h400/pic06_UpdateItem.JPG" width="299" /></a></div><br />
<ul style="text-align: left;">
<li>Set the Title to: "Meeting at [Venue value]".</li>
<li>Set the EventDate field to the output from the <b>Subtract from time - Because of BST</b> action.</li>
<li>Set the Location field to [Venue Value].</li>
</ul>
<p></p>
<p>My last job was to set up the notification that goes to the Requestor once they click <b>Save</b> on the SharePoint input form. The main thing I wanted to do was to include an iCalendar invite so the Requestor could add the event to their Outlook calendar.</p>
<p>It's not hard to find on the Interweb, but to save you looking it up, here's the script for generating an iCalendar event:</p><p><span style="font-family: courier;">[YourSite]/_vti_bin/owssvr.dll?CS=109&Cmd=Display&List=[YourListID]&CacheControl=1&ID=[ID]&Using=event.ics</span></p>
<p>For this to work properly, you must have at least the two Date columns in your list named <b>EventDate</b> and <b>EndDate</b>. Without these, the script just won't work. </p><p>As mentioned earlier, you would do well to have a <b>Location</b> field as well, and to configure the content of the <b>Title</b> field in a way that makes sense (The <b>Title</b> field content will become the Name of the event when it's added to the user's Outlook calendar.)</p>
<p>The List ID can be found by going to the List's Settings window and grabbing it from the end of the URL window ...</p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHqBRU5uteJUEiEW6Z0_19j0sgA-9fgdGPZAtRDobz0_AurC-DokVmpPQNLYtXJGj7OHrsrmhDb7yhdcYfq17XQsf07dwHQBJsO1ZayLMQTvhEsVQHYNp4G5NfoTkTUe9Tik9D4R8TFq0hIdDI1q8cau7cAoOCEKJAqY90SlM-2MYlmPyOFmPXZNRw/s948/pic07_ListID.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="34" data-original-width="948" height="14" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHqBRU5uteJUEiEW6Z0_19j0sgA-9fgdGPZAtRDobz0_AurC-DokVmpPQNLYtXJGj7OHrsrmhDb7yhdcYfq17XQsf07dwHQBJsO1ZayLMQTvhEsVQHYNp4G5NfoTkTUe9Tik9D4R8TFq0hIdDI1q8cau7cAoOCEKJAqY90SlM-2MYlmPyOFmPXZNRw/w400-h14/pic07_ListID.JPG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>Click on the image to enlarge it.</i></td></tr></tbody></table>
<p>... and you'll need to replace [ID] with the ID of the list item we're processing at that point. I actually found it a lot easier to configure this formula using a Flow Variable.</p><p>So, add an <b>Initialise variable</b> action and a <b>Set variable</b> action, like this:</p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNqTuAns-pwaqExFHA1_OhcFPJUU98IT2olnzJF53LX6PL3nzMNFC0bHEXhTC17_0FQU0Vlr2SE67TA1-R9P7sSDGgpxg7YCaUNqwi9FT47XEsV3vlBBCHuDOo2C7Bv1Is7vYFP6tWz92rEozpxBEqlfDPemOWYu_HF7T5K4whl5rBYCcA2UiaHKHX/s679/pic08_FullFlow.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="679" data-original-width="636" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNqTuAns-pwaqExFHA1_OhcFPJUU98IT2olnzJF53LX6PL3nzMNFC0bHEXhTC17_0FQU0Vlr2SE67TA1-R9P7sSDGgpxg7YCaUNqwi9FT47XEsV3vlBBCHuDOo2C7Bv1Is7vYFP6tWz92rEozpxBEqlfDPemOWYu_HF7T5K4whl5rBYCcA2UiaHKHX/w375-h400/pic08_FullFlow.JPG" width="375" /></a></div><br />Then in the <b>Initialise variable</b> action, name your variable as "calendarInvite", set the Type to "String" and leave the Value field blank.<p></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgv1_DSUDt8O4a_TrdT29NrIvNC55DmQ4-LFtxwVGNxzIF-GCaoNX1l98AEZNeGJ9BB5_2aPrHoZtV02ULfMCSJy1Oc--AsGzMc0xSO1ledjQr7wtbjEHP9ve8AThj1oAtF4hEHSUBTnfQcSmkq7Xglom8fsyulsGL3l_1yenSmRaRXnZ3-Z14MBxN3/s626/pic09_InitialiseVariable.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="213" data-original-width="626" height="136" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgv1_DSUDt8O4a_TrdT29NrIvNC55DmQ4-LFtxwVGNxzIF-GCaoNX1l98AEZNeGJ9BB5_2aPrHoZtV02ULfMCSJy1Oc--AsGzMc0xSO1ledjQr7wtbjEHP9ve8AThj1oAtF4hEHSUBTnfQcSmkq7Xglom8fsyulsGL3l_1yenSmRaRXnZ3-Z14MBxN3/w400-h136/pic09_InitialiseVariable.JPG" width="400" /></a></div><br />Next, in the <b>Set Variable</b> action, set the variable Value to:<p></p><p><span style="font-family: courier;"><a href="</span><span style="font-family: courier;">[YourSite]/_vti_bin/owssvr.dll?CS=109&Cmd=Display&List=[YourListID]&CacheControl=1&ID=[ID]</span><span style="font-family: courier;">&Using=event.ics"><strong>Add the Event to your Calendar</strong></a></span></p><p>You should be able to replace the "[ID]" with the item's ID from the <b>When an item is created</b> action ... so the <b>Set Variable</b> action looks like this:</p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhN_xEw3X1RFfBObkg9r8k3dCkGmRHGSI2RZe0ija9fNk8vfG5jTBEe9F_c74hXUYsD4oBKxl_ICZx98kIO23yEitKqyw9T0V2RkjAVsNIe5dTHJ3bGCgdsMuC_qlWJQdkDW6IckKluO2YkWDnEKyLQ_63T9jj2wICNtVd7-P0NUThv9VZ5PXd3tZxc/s633/pic10_SetVariable.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="245" data-original-width="633" height="155" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhN_xEw3X1RFfBObkg9r8k3dCkGmRHGSI2RZe0ija9fNk8vfG5jTBEe9F_c74hXUYsD4oBKxl_ICZx98kIO23yEitKqyw9T0V2RkjAVsNIe5dTHJ3bGCgdsMuC_qlWJQdkDW6IckKluO2YkWDnEKyLQ_63T9jj2wICNtVd7-P0NUThv9VZ5PXd3tZxc/w400-h155/pic10_SetVariable.JPG" width="400" /></a></div><br />But if that isn't working for you, try replacing the [ID] with the expression:<p></p>
<p><span style="font-family: courier;">@{triggerOutputs()?['body/ID']}</span></p>
<p>All that remains is to compile the email notification that's sent to Requestor to confirm their booking. Because the variable now contains the text and the URL for the Calendar Invite, all you need to do is add the Variable to the body text of the email in the appropriate place, like this:</p>
<p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZtuw_nPK9bbeNZbH7uWnqQtF-OuN4jLNelRq5e6qIFoubFX0fcNwnJW0-rAMcn9MQ1Qx5fKQmCf09M2bgpJXWsFNzUhFtW8-HbG3fyXgFejHK4flQCtJuy0wJCXHDr34ZHVng6pi37Q-WpjdtdPh1c4N5TSzIyELazertnoWhBNABPQIZIFrhYW0D/s1047/pic11_SendEmail.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1047" data-original-width="641" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZtuw_nPK9bbeNZbH7uWnqQtF-OuN4jLNelRq5e6qIFoubFX0fcNwnJW0-rAMcn9MQ1Qx5fKQmCf09M2bgpJXWsFNzUhFtW8-HbG3fyXgFejHK4flQCtJuy0wJCXHDr34ZHVng6pi37Q-WpjdtdPh1c4N5TSzIyELazertnoWhBNABPQIZIFrhYW0D/w392-h640/pic11_SendEmail.JPG" width="392" /></a></div><br />And that is pretty much it.<p></p>
<p>When the recipient of the email clicks on the email's Calendar link, the new event has a subject line of "Meeting at [Venue]", a seasonally adjusted EventDate and End Date, and even a Location value.</p><p>There may be a more "correct" way to deal with the fact that SharePoint is unable to adjust the time of the event for local, seasonal timeshifts, but at least this quick fix works.</p><p>If you wanted to be really ambitious, you could add a <b>Condition</b> action to the process to create two branches ... one for events in the winter (not British Summer Time) and one for summer when there is some form of daylight saving time in place.</p><p>Hope this helps someone ...</p><p><br /></p><p><br /></p>
<p></p>AirPiratePresshttp://www.blogger.com/profile/13136561512898563240noreply@blogger.com0tag:blogger.com,1999:blog-3023476837266527744.post-88268716766544430332022-03-14T02:47:00.000-07:002022-03-14T02:47:01.670-07:00PowerApps - linking the Gallery Arrow to a DispForm / Editform<p><b>I WAS BUILDING</b> a gallery linked to SharePoint in a Canvas App, and ran into a spot of bother.</p><p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEiNxkTIVsKFrxQzlksS3Lttw9xlG45fxXkuF7QqlReACuW0noEx0fetkFHF9Pj5Exd77igANLyvMftoVM1g_5QS9F1SHj6OaWwPRbFOF3Hua13Ep1SKTB5dnm5BX4VcEjnt5lDp9IihkNOwfwZbtVCyQatJ1xwUX_QoYeQoun-CHmkN0JcOIbP56USg=s369" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="245" data-original-width="369" height="212" src="https://blogger.googleusercontent.com/img/a/AVvXsEiNxkTIVsKFrxQzlksS3Lttw9xlG45fxXkuF7QqlReACuW0noEx0fetkFHF9Pj5Exd77igANLyvMftoVM1g_5QS9F1SHj6OaWwPRbFOF3Hua13Ep1SKTB5dnm5BX4VcEjnt5lDp9IihkNOwfwZbtVCyQatJ1xwUX_QoYeQoun-CHmkN0JcOIbP56USg=s320" width="320" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><span style="font-size: x-small;"><i>It's that arrow on the right that was giving me grief.</i></span></td></tr></tbody></table><br />It was really easy to create a Title in the Gallery that linked back to the relevant item in the SharePoint list. I just used an HTML field and a concatenate expression, like this:</p><p><span style="font-family: courier;">Concatenate(</span></p><p><span style="font-family: courier;"> "<b><a href='https://MySite.sharepoint.com/sites/EO-IT/Lists/CaTS%20Calendar/DispForm.aspx?ID=",</span></p><p><span style="font-family: courier;"> ThisItem.ID,</span></p><p><span style="font-family: courier;"> "' style='text-decoration:None;'>",</span></p><p><span style="font-family: courier;"> ThisItem.Title,</span></p><p><span style="font-family: courier;"> "</a></b>"</span></p><p><span style="font-family: courier;">)</span></p><p>But you see that pesky arrow on the right side of the Gallery Item? Well, I struggled with the syntax to make that link to the same item in the SP list. I tried several variations on what I thought would work in the item's <b>OnSelect</b> control and kept drawing a blank.</p><p>Finally, I tried this simple formula:</p><p><span style="font-family: courier;">Launch(Concatenate("https://MySite.sharepoint.com/sites/EO-IT/Lists/CaTS%20Calendar/DispForm.aspx?ID=",ThisItem.ID))</span></p><p>… and to my surprise it worked. The reason I was surprised is that I’m fairly sure that this was the first formula I tried and that PowerApps threw an error.</p><p>So in case anyone else experiences the same glitch, I can confirm that the above is the correct syntax.</p><p>Hope that helps someone.</p>AirPiratePresshttp://www.blogger.com/profile/13136561512898563240noreply@blogger.com0tag:blogger.com,1999:blog-3023476837266527744.post-20211625778011288622021-04-17T00:47:00.000-07:002021-04-17T00:47:30.577-07:00Flow: Send an email to multiple addresses stored in a list or library<p><span style="font-family: arial;"><b>SO HERE'S A STRANGE THING. </b>I was working on a scheduled Flow that would loop through the items in a list and send out alerts to groups of Owners and Responders when a task was close to its deadline. Sounds straightforward, right? Being fairly new to Flow, I certainly thought so, and even went as far as to trust Microsoft's recommendations as I was building my Flow application. But it turns out that there were "unexpected benefits" along the way. Notably, all the Owners were receiving duplicate notifications from all the tasks - not what I intended and definitely not what the Owners wanted.</span></p>
<p><span style="font-family: arial;"></span></p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0baqKTg1FffvBn20iHwdDhGxnLHArJ4nJaIcyjiyEwHChYOBfnF8eT4Nl6bgbP_AK0Sctf-JQa5jaOmnoIXkyKswQJ-lCU-Fs-zvK3BbuqF1NbZvibACl9ExTvCtVtI5mu0hHFYuT5cc/s1122/pic01_TaskList_raw.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="461" data-original-width="1122" height="164" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0baqKTg1FffvBn20iHwdDhGxnLHArJ4nJaIcyjiyEwHChYOBfnF8eT4Nl6bgbP_AK0Sctf-JQa5jaOmnoIXkyKswQJ-lCU-Fs-zvK3BbuqF1NbZvibACl9ExTvCtVtI5mu0hHFYuT5cc/w400-h164/pic01_TaskList_raw.JPG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>Here's a screengrab of the list. You can see that I've added a couple of Owners and a couple of Responders for each task. I want each Responder to receive a notification and all appropriate Owners to be CCed on each notification.</i></td></tr></tbody></table>
<span style="font-family: arial;">So for this exercise, I created a simplified version of the list I built. You can see each task in the list has a set of Owners (generally managers in charge of the project phases) and Responders (who are generally supposed to carry out the tasks). The list also has a "Completed" tickbox so Responders can set the task to "Complete".</span>
<p></p>
<p><span style="font-family: arial;">Right, so with my List all ready and populated with Tasks, I set to creating the Flow that would scan the List once a week, then send notifications to all named stakeholders as a task fell due.</span></p><p><span style="font-family: arial;"></span></p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjH29jHlUZAxipmYaQNMNfXLx7F3f8_pyu7XViMfRrIpng1Hn-CPKqKgh0zYzK6H_gmlaTZgQNQP9AOqRRzWycIfgrYoB0MeuXcbC6xoNi9cX9Z7LZlpmmdUyp3kJvYjiFXIXYXM4qorI/s736/pic02_Scheduled-Flow.jpg" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="376" data-original-width="736" height="204" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjH29jHlUZAxipmYaQNMNfXLx7F3f8_pyu7XViMfRrIpng1Hn-CPKqKgh0zYzK6H_gmlaTZgQNQP9AOqRRzWycIfgrYoB0MeuXcbC6xoNi9cX9Z7LZlpmmdUyp3kJvYjiFXIXYXM4qorI/w400-h204/pic02_Scheduled-Flow.jpg" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>I want my Flow to run once a week, and notify all Responders that the deadline for their task is drawing close.</i></td></tr></tbody></table>
<span style="font-family: arial;">You can set the parameters of your Scheduled Flow at the point of creation or after you've created it ... I generally choose after. In this example, I want the Flow to run once a week on Wednesdays at 1pm.</span>
<p></p>
<p><span style="font-family: arial;"></span></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi22gbPs-S-W_2Gx_BeJ5bV4IUaeUVGtn-1mIwETt_yusUvz2UWc42fJfnnhGvqjXNY-g6XXH7hAijrp9nTK7VNtCv_FsAFprfVrwUVcT_8mvv6HHfcllAoclyoiujsMyz1v4O2XDKqbMU/s606/pic03b_SetUpScheduled-Flow.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="399" data-original-width="606" height="264" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi22gbPs-S-W_2Gx_BeJ5bV4IUaeUVGtn-1mIwETt_yusUvz2UWc42fJfnnhGvqjXNY-g6XXH7hAijrp9nTK7VNtCv_FsAFprfVrwUVcT_8mvv6HHfcllAoclyoiujsMyz1v4O2XDKqbMU/w400-h264/pic03b_SetUpScheduled-Flow.JPG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>Let's have the Flow run on Wednesday at 13.00.</i></td></tr></tbody></table>
<span style="font-family: arial;">The next step is to add the <b>Get Items</b> call. We need the Flow to scan the entire list, looking for deadlines to act upon. So we add a <b>Get Items</b> action, then point it at the SharePoint site and specific list we want it to scan.</span><p></p><p><span style="font-family: arial;"></span></p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJFzgrSjOrS-khF7SMWFI7o14VheQ9D1V0POy5Yd8lGqahhytjh5W11dOxSSZSiatl0aLOHxfmLR9ECyxd19B2MnmA37Zw4C8O3ZkDlt709a2VgQdt_y4c-gJUcDqCeCb5b3xntZr0Cls/s608/pic04_GetItems.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="446" data-original-width="608" height="294" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJFzgrSjOrS-khF7SMWFI7o14VheQ9D1V0POy5Yd8lGqahhytjh5W11dOxSSZSiatl0aLOHxfmLR9ECyxd19B2MnmA37Zw4C8O3ZkDlt709a2VgQdt_y4c-gJUcDqCeCb5b3xntZr0Cls/w400-h294/pic04_GetItems.JPG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>Pretty basic stuff, right ... create a Flow, add a Get Items action. Don't get too comfortable. It starts getting more challenging from here on.</i></td></tr></tbody></table>
<span style="font-family: arial;">What I wanted was to set up a Condition that would only trigger the remainder of the Flow if the deadline was in the range of one week ago to one week from now. This would mean that a deadline falling within the two-week window would result in notifications being triggered. If Responders don't mark the task "Complete", they'll continue to receive alerts in that two-week window. You might prefer a one-month window, but as you'll see, that's no more difficult to achieve.</span>
<p></p>
<p><span style="font-family: arial;"></span></p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjy65tRtjTp0535EQmcDOAcS8KZE1R_iR1Uv2mBODE6h1pvT-D8udiXp9DuYDesiIBM7-FNN-BBcSzBjVqEyLw9lr3DXLTs-Q2tYSx-ufA_-Feu1obdiwsxJ2lMBq3GZ7CkeyXZCYSABt8/s1219/pic05_AddCondition.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="372" data-original-width="1219" height="122" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjy65tRtjTp0535EQmcDOAcS8KZE1R_iR1Uv2mBODE6h1pvT-D8udiXp9DuYDesiIBM7-FNN-BBcSzBjVqEyLw9lr3DXLTs-Q2tYSx-ufA_-Feu1obdiwsxJ2lMBq3GZ7CkeyXZCYSABt8/w400-h122/pic05_AddCondition.JPG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>Add a condition. We'll need more than one condition, but I'm getting to that.</i></td></tr></tbody></table>
<span style="font-family: arial;">So ... we add a Condition to the Flow. Then, when we select the Deadline in the "Choose a value" window, Microsoft helpfully adds an <b>Apply to each</b> wrapper around the Condition. I didn't ask it to do this, but it makes sense ... because we want the Flow to loop through all the items, looking for Tasks that have a Deadline that falls inside our two week window, right? So, I'm happy with that.</span>
<p></p>
<p><span style="font-family: arial;"></span></p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgL7fjzx3uQ1a3HeS-uBoQbuwRsY8pAMyJQJ-gy3Ccl7KFRqMv7xCEsHWzWB6mhs2jqHfMiRowagQ-SMPicjbhMj3QRgkFNdG1PbUU4bTmt2Gu8w71eoMuWOReghek4PvfBueB17VplSwA/s1274/pic06_AddConditionApplyEach.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="615" data-original-width="1274" height="193" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgL7fjzx3uQ1a3HeS-uBoQbuwRsY8pAMyJQJ-gy3Ccl7KFRqMv7xCEsHWzWB6mhs2jqHfMiRowagQ-SMPicjbhMj3QRgkFNdG1PbUU4bTmt2Gu8w71eoMuWOReghek4PvfBueB17VplSwA/w400-h193/pic06_AddConditionApplyEach.JPG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>The value we're going to filter on first is the Deadline. As soon as we add that value in the left-hand field, we automatically get an <b>Apply to each</b> wrapper ...</i></td></tr></tbody></table>
<span style="font-family: arial;">Now we'll need to set two boundaries for our two-week window - one for the start and one for the end. Again, this can be tricky if you're new to Flow, but pretty easy to discover via Google as I did.</span>
<p></p>
<p><span style="font-family: arial;">We set the first parameter to the following formula, like this:</span></p>
<blockquote style="border: none; margin: 0 0 0 40px; padding: 0px;"><p style="text-align: left;"><span style="font-family: courier;">addDays(utcNow(), -7)</span></p></blockquote>
<p><span style="font-family: arial;">This means take today's date and subtract seven days. We add the formula as an Expression to the condition, saying that if the Task's Deadline is Greater to or Equal to the above value, then act.</span></p>
<p><span style="font-family: arial;"></span></p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvSb75bawr85kMP7JK94_UikqkUpVPFjCReAKzxRvS7bThkwqxv4YHWUDP0Qty9RtiAnhWexrQ63wkRv7kS-cja-dXHU7empa2MuOIBYdQmIKG8OcA1VM_bejs33bgiMnuKHgpmjIpkj8/s1276/pic07_DeadlineGreaterThan.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="636" data-original-width="1276" height="199" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvSb75bawr85kMP7JK94_UikqkUpVPFjCReAKzxRvS7bThkwqxv4YHWUDP0Qty9RtiAnhWexrQ63wkRv7kS-cja-dXHU7empa2MuOIBYdQmIKG8OcA1VM_bejs33bgiMnuKHgpmjIpkj8/w400-h199/pic07_DeadlineGreaterThan.JPG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>Apply the filter value for Deadline as a calculated Expression ...</i></td></tr></tbody></table>
<span style="font-family: arial;">Next, we have to define the future parameter for the condition. We do that by adding a second condition that defines a Deadline date seven days from now, using this formula:</span><p></p><blockquote style="border: none; margin: 0 0 0 40px; padding: 0px;"><p style="text-align: left;"><span style="font-family: courier;">addDays(utcNow(), 7)</span></p></blockquote>
<p><span style="font-family: arial;">You could also add a "+" in front of the 7, but it's not necessary. Add the parameter, like this:</span></p>
<p><span style="font-family: arial;"></span></p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeqY_rZ5KxJNVluUngJFB5R88_o51bm-9OnfoFQ3pUEtE3rcJDeayOOVndIaVjXpiFVw100-yVfWMKWeuECmyU-Rcol0y0d94H18LGlLyT8Y4q3L90OyGXGEnKRuxpwUZ-ugfr1zP2a70/s1318/pic08_DeadlineLessThan.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="708" data-original-width="1318" height="215" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeqY_rZ5KxJNVluUngJFB5R88_o51bm-9OnfoFQ3pUEtE3rcJDeayOOVndIaVjXpiFVw100-yVfWMKWeuECmyU-Rcol0y0d94H18LGlLyT8Y4q3L90OyGXGEnKRuxpwUZ-ugfr1zP2a70/w400-h215/pic08_DeadlineLessThan.JPG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>Having two Deadline filter values is how we bracket a two week window. Adjust the number of days to change the beginning and end of the trigger time period.</i></td></tr></tbody></table>
<span style="font-family: arial;">Finally, we don't want alerts to trigger on Tasks that have been marked completed, so we add a third parameter to the Condition, saying if the Complete box is not ticked, you can continue to issue an alert on that item.</span>
<p></p>
<p><span style="font-family: arial;"></span></p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3Gd2qYhR8M8ost5WBVgGAH1mQZsSsLnZdq-u3pzK3b6jOZw66JvmqkOc9M_QDMB1U-JIN63945uP1cJ0dZ9aqTGItg-1SS2rtTjOX86qmWw_gR6f7iHiITgQ_YoOvEd8vy7aHQS7lBZw/s1315/pic09_CompletedFalse.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="625" data-original-width="1315" height="190" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3Gd2qYhR8M8ost5WBVgGAH1mQZsSsLnZdq-u3pzK3b6jOZw66JvmqkOc9M_QDMB1U-JIN63945uP1cJ0dZ9aqTGItg-1SS2rtTjOX86qmWw_gR6f7iHiITgQ_YoOvEd8vy7aHQS7lBZw/w400-h190/pic09_CompletedFalse.JPG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>Finally, we need a filter value that prevents Task already marked as Complete from triggering a Flow response.</i></td></tr></tbody></table>
<span style="font-family: arial;">The final completed Condition panel should look like this:</span>
<p></p>
<p><span style="font-family: arial;"></span></p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhek6B-IEcLjYsRdP2kjUJl-Z0iuGcxYw7Y-iRhOFDkm_UabZkd2YK5NR6SsBbR1ECX_VQtLR_kmCmAko3C6Z-pbp7YX8g_HGYHNJjJTrSa8Nwv5Qa4YRuIrm9ujShyM7d3i9-tV85OQSI/s1278/pic10_ConditionPanel.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="493" data-original-width="1278" height="154" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhek6B-IEcLjYsRdP2kjUJl-Z0iuGcxYw7Y-iRhOFDkm_UabZkd2YK5NR6SsBbR1ECX_VQtLR_kmCmAko3C6Z-pbp7YX8g_HGYHNJjJTrSa8Nwv5Qa4YRuIrm9ujShyM7d3i9-tV85OQSI/w400-h154/pic10_ConditionPanel.JPG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>And there we are ... all the Condition filters applied.</i></td></tr></tbody></table>
<span style="font-family: arial;">Right, so that's the easy part done. Things only started to go wrong for me when I tried to set up an Alert Email that would tell the Owners and the Responders that their Task was due for completion.</span><p></p><p><span style="font-family: arial;">I did that by adding a <b>Send Email</b> action to the "If yes" branch of the Condition. But the minute I add the Responder data to the "To" field, helpful ol' Microsoft added an enclosing <b>Apply to each</b> function.</span></p>
<p><span style="font-family: arial;"></span></p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqfdTrMSj6oeGNnRclmfAuQLfRx6KbJad5GAl9TTWJGYzNCAn37X3RkuQuBJzDQAgK9VHeZR5xwcIQd5yJ2cPp65A1P5zt-G44-xF6OlbFwGUB7I3P1jcZDExShTdh_Kc6rtwsXplj3wE/s644/pic11_SendEmail-Responder.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="356" data-original-width="644" height="221" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqfdTrMSj6oeGNnRclmfAuQLfRx6KbJad5GAl9TTWJGYzNCAn37X3RkuQuBJzDQAgK9VHeZR5xwcIQd5yJ2cPp65A1P5zt-G44-xF6OlbFwGUB7I3P1jcZDExShTdh_Kc6rtwsXplj3wE/w400-h221/pic11_SendEmail-Responder.JPG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>I was beginning to see a pattern emerging. Every time I added a value from the list, Flow added an <b>Apply to each</b> wrapper ... which I assumed was necessary.</i></td></tr></tbody></table>
<span style="font-family: arial;">Again, that's a good thing, right? Because I want the Flow to loop through all the Responders that I added to the Responder field in the list.</span><p></p><p><span style="font-family: arial;">And when I tested the Flow at this stage, each of the Responders receives an email so, again, that's good and what I intended. But it was when I added the Owners as a CC to the email that the problems started.</span></p>
<p><span style="font-family: arial;">Go to the <b>Send an email</b> action and click the link at the bottom of the panel that says, "Show advanced options", and add a dynamic value for the Owners into the CC field.</span></p>
<p><span style="font-family: arial;"></span></p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGZMLuTuUmOv_0TBpDFfQDJG0cpWUTm1yV3SthyphenhyphenFtuw7fbX3viKWWuGS43TlAVMbNhf85KTdWrR-R3EhhuLey710NGxARW1eh743blBnJ5RNsL02T2NOPlOb_tOD4WPkg28SeeY55oO4M/s1034/pic12_SendEmail-Owner.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="356" data-original-width="1034" height="138" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGZMLuTuUmOv_0TBpDFfQDJG0cpWUTm1yV3SthyphenhyphenFtuw7fbX3viKWWuGS43TlAVMbNhf85KTdWrR-R3EhhuLey710NGxARW1eh743blBnJ5RNsL02T2NOPlOb_tOD4WPkg28SeeY55oO4M/w400-h138/pic12_SendEmail-Owner.JPG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>I wanted the add the Owners on the notification as a CC, as they didn't have to do anything, except be aware that the notification had gone to the Responders.</i></td></tr></tbody></table>
<span style="font-family: arial;">And, predictably, Flow then wraps your <b>Send an email</b> action in another <b>Apply to each</b>, this time for retrieving the Owners values for each email. The thing is, this addition doesn't work like you expect it to.</span>
<p></p>
<p><span style="font-family: arial;">What happens is that the Flow creates several emails for each task as it loops through the Responders and the Owners ... so for Responders A & B and Owners C & D, you get four emails for the same task, like this:</span></p>
<p></p>
<ul style="text-align: left;"><li><span style="font-family: arial;">Responder A + Owner C</span></li><li><span style="font-family: arial;">Responder A + Owner D</span></li><li><span style="font-family: arial;">Responder B + Owner C</span></li><li><span style="font-family: arial;">Responder B + Owner D</span></li></ul><p></p>
<p><span style="font-family: arial;">... meaning that The Responder is getting two emails for each task and the Owners are getting two emails for each task. And if you had <i>three</i> Owners and Three Responders, then there would <i>nine</i> emails going out, and so on. We <i>definitely</i> don't what that to be happening. We're going to need a different approach.</span></p><p><span style="font-family: arial;">I don't mind each Responder getting their own email for a given task, but I don't want that to be multiplied by each Owner also getting an email. So what if we roll up all the Owners for a given task into a single string of email addresses? This is a job for Variables ...</span></p>
<p><span style="font-family: arial;">First, we have to declare a Variable for Owner Email Addresses. And that has to be done that outside the <b>Apply to each</b> action, like this:</span></p>
<p><span style="font-family: arial;"></span></p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXVEp9Drf_vImmIdQ5g6AIRhGNGEnCwOE0U-cGtNUGDnhy0dirtJnxnCOLWBw7xIV8r5700wnXa3gVRVIPdLTzBNx3OCtEyf7FJ01exhEL3JsHvlau6je4rY951z36kewVTdvOoYD34CI/s615/pic13_InitialiseVariable.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="360" data-original-width="615" height="234" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXVEp9Drf_vImmIdQ5g6AIRhGNGEnCwOE0U-cGtNUGDnhy0dirtJnxnCOLWBw7xIV8r5700wnXa3gVRVIPdLTzBNx3OCtEyf7FJ01exhEL3JsHvlau6je4rY951z36kewVTdvOoYD34CI/w400-h234/pic13_InitialiseVariable.JPG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>I added the Initialize variable action after the <b>Get items</b> action, as it has to be listed in the main section of the Flow, outside of any <b>Conditions</b> or <b>Apply to each</b> actions.</i></td></tr></tbody></table>
<span style="font-family: arial;"><br />Add the action <b>Initialise variable</b>. The Variable Type is String. Leave the Value field blank. Now, I needed to rearrange the way the <b>Apply to each</b> actions were nested, so I unpicked them (by removing any dependent values in the enclosed Actions) and laid them out like this:</span>
<p></p>
<p><span style="font-family: arial;"></span></p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_A5UiTIJE2Dyb1FNA9MarvVSH3mAdsU3Iw1r0RzHWxmruGHcbS6Ta7-L8ddG-2NVLN3wzN8iOzlzfxFSw2afJ0RLhFDC7Q6Jw3pFyNpgTpHP56_bSSrvm5uaU6Us_tZfxP-kGm9f29i8/s734/pic14_AppendStringVariable.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="734" data-original-width="654" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_A5UiTIJE2Dyb1FNA9MarvVSH3mAdsU3Iw1r0RzHWxmruGHcbS6Ta7-L8ddG-2NVLN3wzN8iOzlzfxFSw2afJ0RLhFDC7Q6Jw3pFyNpgTpHP56_bSSrvm5uaU6Us_tZfxP-kGm9f29i8/w356-h400/pic14_AppendStringVariable.JPG" width="356" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>To rearrange the Apply to each actions, you first need to remove any dynamic values in the enclosed actions. Then you can drag the Apply to each actions to the correct positions and re-instate any dynamic values in the child actions.</i></td></tr></tbody></table>
<p style="font-family: arial;"><span style="font-family: arial;">... adding the <b>Append to string variable</b> action that will compile a string of Owners' email addresses for each email as the Flow loops through <b>Apply to each 3</b>.</span></p>
<p style="font-family: arial;"><span style="font-family: arial;"><b>Really important</b> - do not forget to add the semi-colon after the Owners Email value in the Value field. This is to ensure the string of email addresses are separated correctly.</span></p>
<p style="font-family: arial;"><span style="font-family: arial;">When we run this Flow, a curious thing happens. All the Owners' email addresses in the group of tasks that qualify under the filter are compiled into an ever-growing string ...</span></p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="font-family: arial; margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeOKB0hjX2KePu56tQXHP5CJ2k9qBc7gWGc4__DaIu9ZbG0hfn7n0K5_MLQzkplJ8OgREE6fC0PM40FCLodVCH7siuCS9sPGB50VssgwgA6wZYDz4Fu082gEIqhDyqEHK7gyRpr1bCozE/s1288/pic15_EmailNotification.jpg" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="308" data-original-width="1288" height="96" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeOKB0hjX2KePu56tQXHP5CJ2k9qBc7gWGc4__DaIu9ZbG0hfn7n0K5_MLQzkplJ8OgREE6fC0PM40FCLodVCH7siuCS9sPGB50VssgwgA6wZYDz4Fu082gEIqhDyqEHK7gyRpr1bCozE/w400-h96/pic15_EmailNotification.jpg" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>What on earth is going on here? The Flow has compiled all the Owner email addresses from every qualifying task and added them to the CC field of the notification. By the time we get to the fourth notification, every Task Owner is getting the notification, even though they're not an Owner on the fourth task.</i></td></tr></tbody></table>
<p style="font-family: arial;"><span style="font-family: arial;"> ... until by the end of the cycle, all Owners are CCed into the last notification.</span></p>
<p style="font-family: arial;"><span style="font-family: arial;">I tried a few things to fix this - including changing the order of the <b>Apply to each</b> actions - but nothing seemed to work and I wasn't able to find a solution via Google.</span></p>
<p style="font-family: arial;"><span style="font-family: arial;">The next day, I had a flash of inspiration ... I added another <b>Set variable</b> action before the <b>Apply to each 3</b> (that appends and holds the Owner emails), and configured it to give the variable a value of "null". This would clear the Owner variable after each notification is sent, preventing a build-up of Owner email addresses in the CC field of the notification.</span></p>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEip-n2vuLO9MX-WtEG4Xzrse_VCp7biv3Gr9CnPAgXiamhqKu-25LBfxGIIkZh-Jy5JzNS7GQ-LYZHfDf4tA_iJ9Emo0UEXIksD9X4roPAprFyA1zkG7WVUwzXCt0o0FBItZoRlIEXFr78/s618/pic16_SetVariableToNull.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="278" data-original-width="618" height="180" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEip-n2vuLO9MX-WtEG4Xzrse_VCp7biv3Gr9CnPAgXiamhqKu-25LBfxGIIkZh-Jy5JzNS7GQ-LYZHfDf4tA_iJ9Emo0UEXIksD9X4roPAprFyA1zkG7WVUwzXCt0o0FBItZoRlIEXFr78/w400-h180/pic16_SetVariableToNull.JPG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>And that seemed to do the trick. No longer were Owner email addresses from previous notifications being copied into subsequent notifications.</i></td></tr></tbody></table>
<p style="font-family: arial;">And when I ran a test, there was no more build-up of emails and, as I'd wanted, there was one notification for each Responder with all appropriate Owners for that task CCed on each of the notifications.</p>
<p style="font-family: arial;"><span style="font-family: arial;">There may well be a better way of doing this, but I'm just happy I got a solution that works.</span></p>
<h3 style="font-family: arial; text-align: left;"><span style="font-family: arial;">SOME FINAL THOUGHTS</span></h3>
<p style="font-family: arial;"><span style="font-family: arial;">Because Flow can sometimes be a bit difficult to wrangle, here's some extra hints and tips to make this solution better.</span></p>
<p style="font-family: arial;"><span style="font-family: arial;">Sometimes, when I add an email value to a notification it displays strangely. For example in the below image, you can see that the salutation of the notification displays as "Owners DisplayName" ... but I had actually added the Responders DisplayName, and the notification does show the Responders name on arrival. I don't lose much sleep over this, but I just wondered if anyone else sees this glitch when they use Flow.</span></p>
<p style="font-family: arial;"><span style="font-family: arial;"></span></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="font-family: arial; margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBnrvOe-n7H7HDJfQoPMwo0cKJVD9oPtsAJoHymB25EL0eyVjOKhv643jjq-nfnO-94ZHyIgmBnfWGDZv7v8g3WFgYXEoGXZo3ZyRnntGD9E6laWm6hevvFUdJs_xiyyotWEbXxkWn0gY/s614/pic16_EmailSetup.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="520" data-original-width="614" height="339" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBnrvOe-n7H7HDJfQoPMwo0cKJVD9oPtsAJoHymB25EL0eyVjOKhv643jjq-nfnO-94ZHyIgmBnfWGDZv7v8g3WFgYXEoGXZo3ZyRnntGD9E6laWm6hevvFUdJs_xiyyotWEbXxkWn0gY/w400-h339/pic16_EmailSetup.JPG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>Here's what the final Send an email action in Flow should look like. I had put in the Owner and Responder email values for testing purposes, so I could see what Flow was writing into the emails without actually having to send the emails.</i></td></tr></tbody></table>
<p style="font-family: arial;"></p>
<p style="font-family: arial;"><span style="font-family: arial;">Next, if you just put the "Deadline" in the body of the notification, the date displays backwards in the final delivered email, like this: 2021/04/14. To get it to display the right way round and in the right format, add the Deadline as an Expression, like this:</span></p>
<blockquote style="border: none; margin: 0 0 0 40px; padding: 0px;"><p style="text-align: left;"><span style="font-family: courier;">formatDateTime(items('Apply_to_each_2')?['Deadline'],'dd/MM/yyyy')</span></p></blockquote>
<p style="font-family: arial;"><span style="font-family: arial;">You can change the "dd/MM/yyyy" bit to a format that suits you, if you prefer.</span></p><p style="font-family: arial;"><span style="font-family: arial;">You can also see, for testing purposes, I had the Responders Email (mislabelled by Flow here as "Owners Email") and the Owners variable in the body of the notification. This saves me peppering my colleagues with emails while I'm testing. However, it's tricky to add the Responders Email value directly into the body of the notification - Flow doesn't offer me that option. So what I did was first add the Responders Email value as an expression, like this:</span></p>
<blockquote style="border: none; margin: 0 0 0 40px; padding: 0px;"><p style="text-align: left;"><span style="font-family: courier;">items('Apply_to_each_2')?['Email']</span></p></blockquote>
<p style="font-family: arial;"><span style="font-family: arial;">On saving, Flow converted it to an actual dynamic value (though it still managed to mislabel it as "Owners Email").</span></p>
<p style="font-family: arial;"><span style="font-family: arial;">I hope this has helped someone ...</span></p>
<p style="font-family: arial;"><br /></p>
<p style="font-family: arial;"><br /></p>
<p></p>AirPiratePresshttp://www.blogger.com/profile/13136561512898563240noreply@blogger.com0tag:blogger.com,1999:blog-3023476837266527744.post-68063377492317215652020-10-11T05:50:00.008-07:002024-01-28T06:54:22.655-08:00Create a Word brochure generator with Power Apps and Power Automate: Part Two<p><span style="font-family: arial;"><b>YOU'LL RECALL THAT LAST TIME</b> we covered adding metadata columns to the Document Library and the building of cascading menus in Power Apps to manage that metadata ...</span></p><p><span style="font-family: arial;">So ... now we're going to create the Word Template, insert the Quick Parts that will hold the data or text from the Library metadata columns, then attach it to the Content Type.</span></p><p><span style="font-family: arial;">I'm not going to spend too much time telling you how to style the Word document here. There's plenty of places where you can look that up online. But what we <i>will</i> cover here is how we add in the Quick Parts that will hold the text that you entered into the Library's metadata columns, and how we style those.</span></p><p><span style="font-family: arial;">The trick to creating a Word document template with working Quick Parts is to upload it to the Library first. Though this will form the basis of our online template, <b>DO NOT</b> create the Word document as a template, just a simple Word document. You can style up the Word document ahead of loading it up to the system. I did a bit of work on the Word document so it looks a little better than a blank white page.</span></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9vvvZPKdJcUqLyxVp6AToZC2i1BXnhZMhx6fKXMPlrEqHWGwVtpuPe8iFIDCDA_wRG-g2MAIOilgdj0s6tQHi5Rs8Hx3Q0xY9QJQuF0wXB3n0dShHHX8rama-PUpnO1xD4wNHvZxLKW8/s780/pic30_Word-OpenInApp.jpg" style="margin-left: auto; margin-right: auto;"><span style="font-family: arial;"><img border="0" data-original-height="186" data-original-width="780" height="95" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9vvvZPKdJcUqLyxVp6AToZC2i1BXnhZMhx6fKXMPlrEqHWGwVtpuPe8iFIDCDA_wRG-g2MAIOilgdj0s6tQHi5Rs8Hx3Q0xY9QJQuF0wXB3n0dShHHX8rama-PUpnO1xD4wNHvZxLKW8/w400-h95/pic30_Word-OpenInApp.jpg" width="400" /></span></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><span style="font-family: arial;"><i>Opening the document in desktop Word. If you can't see clearly, <br /><b>click on any image to enlarge it</b>.</i><br /></span></td></tr></tbody></table><p><span style="font-family: arial;">Once you have the Word document loaded into the Library, open the Word document in the desktop version of Word. This is important, as Quick Parts don't work in the browser version of Word.</span></p><p><span style="font-family: arial;">Once you have the Word doc open, click on the <b>Insert</b> tab and find the <b>Quick Parts</b> drop-down on the right side of the ribbon. Click on <b>Quick Parts</b> to display the drop-down, hover over <b>Document Property</b> to see the fly-out menu of all the Site Columns you can select to insert as a Quick Part.</span></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3FLC3qB-B2dufDQd7tmvFBbqiUToIOooW5j9cZJ-42JimidqSZvajKER-ajrN1YXcXpBufLHz6XMp_mGByirICvSN7B0iljTNzsFKU9uuKk4YL9BCXBGemSDYoxBnkQLcVFQeM2u-wYk/s468/pic32_Word-InsertQuickParts.jpg" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="280" data-original-width="468" height="239" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3FLC3qB-B2dufDQd7tmvFBbqiUToIOooW5j9cZJ-42JimidqSZvajKER-ajrN1YXcXpBufLHz6XMp_mGByirICvSN7B0iljTNzsFKU9uuKk4YL9BCXBGemSDYoxBnkQLcVFQeM2u-wYk/w400-h239/pic32_Word-InsertQuickParts.jpg" width="400" /></span></a></div><span style="font-family: arial;"><br />For the first Quick Part we'll be choosing the Client name. Select that and the Client name is inserted into the document as a Quick Part. Now we'll need to add some styling. Highlight the Quick Part in the document by clicking on it.</span><p></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhARaZ_ZH57y8B8ykvsV_JZoUlWPVOdKV8Y4Lj-wA_lTQ7qDp8-DN7HAcxBxVI9-Qa3iV6v10iAEEQeJWGEC1PsqDcfziLmYjtbNtG9Xp2v-NTMNNZ3C3cbDpuOK1YPvfeQu5pXdfoLViE/s468/pic33_Word-SelectQuickPart.jpg" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="280" data-original-width="468" height="239" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhARaZ_ZH57y8B8ykvsV_JZoUlWPVOdKV8Y4Lj-wA_lTQ7qDp8-DN7HAcxBxVI9-Qa3iV6v10iAEEQeJWGEC1PsqDcfziLmYjtbNtG9Xp2v-NTMNNZ3C3cbDpuOK1YPvfeQu5pXdfoLViE/w400-h239/pic33_Word-SelectQuickPart.jpg" width="400" /></span></a></div><span style="font-family: arial;"><br />Now, with the Quick Part selected, click on the <b>Home</b> tab and then on the <b>Title</b> option in the Styles section of the ribbon (this might not be the style you want, but this is just for demo purposes).</span><p></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_RUs8p8aMVMcUDFvWEaPPaf1wDMtXZG_V2Q4aol3X1jHIPk4IuAr1SKHKRRcsex6biw6ZcCH0N6Vq0CU8V3ot8-1ioLxHd5CC7Hqc7b7JBBaR7b-2VWGfBOvfW5eKzMLfYJLzEcsqm9Q/s468/pic34_Word-StyleQuickPart.jpg" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="280" data-original-width="468" height="239" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_RUs8p8aMVMcUDFvWEaPPaf1wDMtXZG_V2Q4aol3X1jHIPk4IuAr1SKHKRRcsex6biw6ZcCH0N6Vq0CU8V3ot8-1ioLxHd5CC7Hqc7b7JBBaR7b-2VWGfBOvfW5eKzMLfYJLzEcsqm9Q/w400-h239/pic34_Word-StyleQuickPart.jpg" width="400" /></span></a></div><span style="font-family: arial;"><br />Now the type looks bigger, but a little wan ... let's add some focus to it by selecting a colour. You might want navy blue... so select a strong colour from the Type Colour drop-down.</span><p></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8fahlq4Cdit3sN42eO1D2Z5IHVxb7KLb9JzAAvsqxx9VDLQQGxKtv4yZXQXj_slbBnr3Cm5g97rnji_IJa5EvRxAZz44fSjyI_V5kCuczWR8eodWgAdRYshNfuGuvBDb38hhsnwRzxCc/s468/pic35_Word-SelectColour.jpg" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="280" data-original-width="468" height="239" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8fahlq4Cdit3sN42eO1D2Z5IHVxb7KLb9JzAAvsqxx9VDLQQGxKtv4yZXQXj_slbBnr3Cm5g97rnji_IJa5EvRxAZz44fSjyI_V5kCuczWR8eodWgAdRYshNfuGuvBDb38hhsnwRzxCc/w400-h239/pic35_Word-SelectColour.jpg" width="400" /></span></a></div><span style="font-family: arial;"><br />Feel free to add a bold if you want to.</span><p></p><p><span style="font-family: arial;">On the next line, let's add the <i>type</i> of brochure we're creating, in the same way as we did with the Client name. Finally, you're going to need a date ... add the Date QuickPart in the same way. Your document should look like this:</span></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3ZRznH_gheG4W_ghEcB_jgAF-vyEiqRaAzfwASiYRPgEV_yMW416t1t_JfRLcXL-jW4b9u6oOdxCdzXlyaBqVz5k69SC6fZ3EoEld6TySrgLe-HonSGF8n8oLkKdOqmUraKVE0rJNXwk/s468/pic36_Word-QuickParts.jpg" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="280" data-original-width="468" height="239" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3ZRznH_gheG4W_ghEcB_jgAF-vyEiqRaAzfwASiYRPgEV_yMW416t1t_JfRLcXL-jW4b9u6oOdxCdzXlyaBqVz5k69SC6fZ3EoEld6TySrgLe-HonSGF8n8oLkKdOqmUraKVE0rJNXwk/w400-h239/pic36_Word-QuickParts.jpg" width="400" /></span></a></div><span style="font-family: arial;"><br />One more thing, we're going to add the Client name to the legal disclaimer on the back cover. Scroll down the Word document until you can see the Disclaimer text at the end of the document and click to place the cursor at the right place in the text (I put in a bit of holding text, so I'd know where the Quick Part goes).</span><p></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyaE6za8O2tOR2gcQ8QdVFG_2AAXECSuBpsueBfZQ1Tn8kt7vxZnH_Ip7aVeEzX3qpOEx04r-eEraUQj9jGPpn6a-cahctvJoBheiEdTNWy2WMcTb7nU9MpbUGXaEK369m_pOk-P_G_MY/s710/pic37_Word-DisclaimerQuickPart.JPG" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="115" data-original-width="710" height="65" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyaE6za8O2tOR2gcQ8QdVFG_2AAXECSuBpsueBfZQ1Tn8kt7vxZnH_Ip7aVeEzX3qpOEx04r-eEraUQj9jGPpn6a-cahctvJoBheiEdTNWy2WMcTb7nU9MpbUGXaEK369m_pOk-P_G_MY/w400-h65/pic37_Word-DisclaimerQuickPart.JPG" width="400" /></span></a></div><span style="font-family: arial;"><br />If you've done it right, you won't even need to apply any styling, as the Quick Part should pick up the styling of the surrounding text.</span><p></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidjUpzeB6WqWyr10nlqZQlE5XlrxPRn8GYQ-PpjnHNyPMFwsiaNo50sWOsvEIqxpvnpCpoOOIfktgcqwk2DW2JumHFCi7JsmplI_nMgyzfPcpBqvErApHENcY5WSPSHgTSlE7xGPLwA6c/s710/pic38_Word-DisclaimerQuickPart.jpg" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="154" data-original-width="710" height="86" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidjUpzeB6WqWyr10nlqZQlE5XlrxPRn8GYQ-PpjnHNyPMFwsiaNo50sWOsvEIqxpvnpCpoOOIfktgcqwk2DW2JumHFCi7JsmplI_nMgyzfPcpBqvErApHENcY5WSPSHgTSlE7xGPLwA6c/w400-h86/pic38_Word-DisclaimerQuickPart.jpg" width="400" /></span></a></div><span style="font-family: arial;"><br />Cool, eh?</span><p></p><p><span style="font-family: arial;">You can keep on going, adding Quick Parts to headers and footers if you want, it's up to you. For example, if you're filling the rest of the document with standard text, you can mention the client every so often by dropping in the Client Quick Part, to give the whole brochure more of a personalised feel.</span></p><p><span style="font-family: arial;">When you're done, <b>Save</b> your document (just in case the AutoSave hasn't worked or hasn't run in the last couple of minutes).</span></p><p><span style="font-family: arial;">If you haven't done it already, give your document the same name as the Content Type you'll be attaching it to. If you click on the Document's link in the Library window, the document will open in the browser version of Word and you can rename it, like this:</span></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiL9je7cC55nPbP7dcgh89J34mKadMYTT2MX9oDM7cxh4rg2xwL8WC4TJcZXbVnZhm1q35Zsvn9r8RaCtZaRg0u4urmzq6Wczu_dTzBCoxfeBPXdMFub5Glz20PCFjslpvdRdF3V64MC14/s554/pic39_Word-RenameDoc.jpg" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="307" data-original-width="554" height="221" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiL9je7cC55nPbP7dcgh89J34mKadMYTT2MX9oDM7cxh4rg2xwL8WC4TJcZXbVnZhm1q35Zsvn9r8RaCtZaRg0u4urmzq6Wczu_dTzBCoxfeBPXdMFub5Glz20PCFjslpvdRdF3V64MC14/w400-h221/pic39_Word-RenameDoc.jpg" width="400" /></span></a></div><span style="font-family: arial;"><br />That's it. Your template is ready. </span><p></p><p><span style="font-family: arial;">The next task is to add the Content Type to your Document Library. I was pretty sure I had done this earlier, but after having some trouble attaching the template to the Content type in the following steps, I investigated and found my Content Type hadn't been added to my Library. </span></p><p><span style="font-family: arial;">... so double-check, and if it's missing in your set-up, go to Library Settings, find the Content Type section and click on <b>Add</b> from existing Content Types.</span></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgimTM0pmJnrvCc5NtOVnyPTICSqC7vImq64kwiBYn1uoT29j2VQG_1JdWZaQHH-WdfdRaM6U9UrsMbv_Q_KheVrHFZvxeb2QxQJkZBNmD6uWOTHAuPkdp_i9QRV-UFJkPq4e6RcXEH3kY/s709/pic44_AddContentType.JPG" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="220" data-original-width="709" height="124" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgimTM0pmJnrvCc5NtOVnyPTICSqC7vImq64kwiBYn1uoT29j2VQG_1JdWZaQHH-WdfdRaM6U9UrsMbv_Q_KheVrHFZvxeb2QxQJkZBNmD6uWOTHAuPkdp_i9QRV-UFJkPq4e6RcXEH3kY/w400-h124/pic44_AddContentType.JPG" width="400" /></span></a></div><span style="font-family: arial;"><br />Find the Content Type in the Available Site Content Types window, select and click the <b>Add</b> button. Then click on <b>OK</b>.</span><p></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhD1a3t0S3U5E1f6F_fFxgq3JNCgf9y83Zs4_3oDmLRMsSyaDzIXgnqCjmscrQj4f8DJngh9jefmOMVlDRYQMyxe7tAJ1uRwGK5yAJ7-crka3V48oUUu1Yl3uiRA2XkDMjDb2bUdFn7syk/s693/pic45_AddContentType.jpg" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="326" data-original-width="693" height="189" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhD1a3t0S3U5E1f6F_fFxgq3JNCgf9y83Zs4_3oDmLRMsSyaDzIXgnqCjmscrQj4f8DJngh9jefmOMVlDRYQMyxe7tAJ1uRwGK5yAJ7-crka3V48oUUu1Yl3uiRA2XkDMjDb2bUdFn7syk/w400-h189/pic45_AddContentType.jpg" width="400" /></span></a></div><span style="font-family: arial;"><br />Now you can attach the Word Template to the Content Type. So, first download it from the Library to your desktop.</span><p></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4sVVbpQun_A7S83991uYODO4ThH8p_Od59mfT1lTe8cwVooi0ih7xt_LAFexH0kFErNr-vrGWexa_Wuh-bq3qcFTRjdEX7hz3_qTZHAseZDYQ8k-ppju48RF-_p35YRGOB1syM9Kes_c/s640/pic40_Word-Download.jpg" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="338" data-original-width="640" height="211" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4sVVbpQun_A7S83991uYODO4ThH8p_Od59mfT1lTe8cwVooi0ih7xt_LAFexH0kFErNr-vrGWexa_Wuh-bq3qcFTRjdEX7hz3_qTZHAseZDYQ8k-ppju48RF-_p35YRGOB1syM9Kes_c/w400-h211/pic40_Word-Download.jpg" width="400" /></span></a></div><span style="font-family: arial;"><br />Now, navigate to the Site Content Type via <b>Library Settings</b>. Find the link for <b>Advanced Settings</b> and click it.<br /></span><span style="font-family: arial;"><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOm6IeYWHnBMoACl-3Lo6sS-wj08OMzAZ-hgt0NaCoZK4tq2fMrhxCkaZ71mGg45vLllvBqss-YSxfGQ97YdmMk0vPfUDo1E5sJDTUhds9UynJyeMKDzFveG2n1iVIiLvPlrOnCOm__CHR8SV_i4OLemoGq30aQgUxeTWDd5te4s1BtXojAlxstTiH7q4/s489/pic41b_LibrarySettings_Advanced.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="354" data-original-width="489" height="232" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOm6IeYWHnBMoACl-3Lo6sS-wj08OMzAZ-hgt0NaCoZK4tq2fMrhxCkaZ71mGg45vLllvBqss-YSxfGQ97YdmMk0vPfUDo1E5sJDTUhds9UynJyeMKDzFveG2n1iVIiLvPlrOnCOm__CHR8SV_i4OLemoGq30aQgUxeTWDd5te4s1BtXojAlxstTiH7q4/s320/pic41b_LibrarySettings_Advanced.png" width="320" /></a></div><br />Use the <b>Browse</b> button to find the Word Document you saved to your desktop. </span><span style="font-family: arial;">Then click <b>OK</b> to add the Word document to your Content Type.<br /></span><span style="font-family: arial;"><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieJkCaGFoiqCWPDoTxd198EKaIvJRlJm4SFiAvBDuDZ2kWtWWqS_yJvQtNbOQcsWeDJn4icVmvDlVE8wK3I0lG5Jr3SUBoNcwQWQO5SuY4lVFgOev3FRico_6etorjdSlHKRhakrGPzGeNeIFdjkcoEojvS7-fxK_5NX3iECup0OL-KGkXMveysQtl2n0/s896/pic41c_LibrarySettings_AddTemplate.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="312" data-original-width="896" height="139" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieJkCaGFoiqCWPDoTxd198EKaIvJRlJm4SFiAvBDuDZ2kWtWWqS_yJvQtNbOQcsWeDJn4icVmvDlVE8wK3I0lG5Jr3SUBoNcwQWQO5SuY4lVFgOev3FRico_6etorjdSlHKRhakrGPzGeNeIFdjkcoEojvS7-fxK_5NX3iECup0OL-KGkXMveysQtl2n0/w400-h139/pic41c_LibrarySettings_AddTemplate.png" width="400" /></a></div><br />Now if you navigate back to the "AllItems" view of your Document Library, you should be able to select your template from the <b>New</b> drop-down menu.</span><p></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6hW2G_BqXJWgLsNDE3vixytZY7OybUvLhX-a8lRQ_4h0-n1QSnnxGUXAsBMqAZJPhbOn3CZbb6C45NaNqT2-KmHwbYTD5YyfFGoQqjwDPwGJD9NbP29ozjThQGVGg8tMITNneqHNeKTU/s664/pic46_ChooseContentType.jpg" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="348" data-original-width="664" height="210" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6hW2G_BqXJWgLsNDE3vixytZY7OybUvLhX-a8lRQ_4h0-n1QSnnxGUXAsBMqAZJPhbOn3CZbb6C45NaNqT2-KmHwbYTD5YyfFGoQqjwDPwGJD9NbP29ozjThQGVGg8tMITNneqHNeKTU/w400-h210/pic46_ChooseContentType.jpg" width="400" /></span></a></div><span style="font-family: arial;"><br />When you open the Brochure template, you want it to open in the browser version of Word. Don't worry that it doesn't look quite right. Browser Word is funny like that. You're only opening in browser Word so you can easily change the name of the brochure. Like this:</span><p></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4WEMTIkodxJcp05N9TfQ0t5LU7F3U1VV8bvW_6nBW5yGoGmAcD7z8bDCaibGnJr-1FhRyyVIPmnz7GoKBEpfrAZ2UfGNiMnNls3e_vILKx5dKASt2sfmlMuxjA7p7H0uNOPsqSThv5s4/s590/pic47_NameBrochure.jpg" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="242" data-original-width="590" height="164" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4WEMTIkodxJcp05N9TfQ0t5LU7F3U1VV8bvW_6nBW5yGoGmAcD7z8bDCaibGnJr-1FhRyyVIPmnz7GoKBEpfrAZ2UfGNiMnNls3e_vILKx5dKASt2sfmlMuxjA7p7H0uNOPsqSThv5s4/w400-h164/pic47_NameBrochure.jpg" width="400" /></span></a></div><span style="font-family: arial;"><br />Once you've changed the name from "Document" you can close the tab. You can see your new Brochure sitting in the "All Items" view of the library.</span><p></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLXoxES_1RVRxcpeLST-1u6i5Dp_AK2JWzKqfrSa8xxzOQ1CoGuNbTrrz-_JR3dRjO-hhyDi2Z6d0JFzGMXzHXg0zg9F7qm21Gtg0BTie_xjzPdZeNGIqqMvI2RJEDDFJC9ABcern17rg/s647/pic48_NewBrochure.JPG" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="160" data-original-width="647" height="99" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLXoxES_1RVRxcpeLST-1u6i5Dp_AK2JWzKqfrSa8xxzOQ1CoGuNbTrrz-_JR3dRjO-hhyDi2Z6d0JFzGMXzHXg0zg9F7qm21Gtg0BTie_xjzPdZeNGIqqMvI2RJEDDFJC9ABcern17rg/w400-h99/pic48_NewBrochure.JPG" width="400" /></span></a></div><span style="font-family: arial;"><br />The next job would be to add the metadata to that new brochure, thereby updating the QuickParts. To do that, click on the new document's Properties ... this will bring up the wonderful Power Apps input form you created earlier.</span><p></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEir2j9KqCcbmqsCngi7keBgDMIJ1LjHmr6MAElXAMYPWGp7xqLpdL7QIah5j_AuMUgMA0wWfXtff3F3sKUV6xnSCdars-XPmgw_EOSveI5kqvPt5ZtAwpg2R5Cy9Yy1CF-7sF-mJX4Rvv8/s1681/pic49_Properties.JPG" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="706" data-original-width="1681" height="168" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEir2j9KqCcbmqsCngi7keBgDMIJ1LjHmr6MAElXAMYPWGp7xqLpdL7QIah5j_AuMUgMA0wWfXtff3F3sKUV6xnSCdars-XPmgw_EOSveI5kqvPt5ZtAwpg2R5Cy9Yy1CF-7sF-mJX4Rvv8/w400-h168/pic49_Properties.JPG" width="400" /></span></a></div><span style="font-family: arial;"><br />I still haven't hidden the text input fields in the Power Apps form, but that's so you can see how it all works. When I start changing the values of the drop-downs, you can see the cascade in action.</span><p></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhOfJf-01IxMRA_8Xk7DmywOmEd2BKaNZdQzT0RLIOyYXqvn7KjX2wMU5j4nBcwZVZaXcq_Cm6BlqhzqnIpUYiPWJpwhopT9bqElas6A0aBVXdOW-vWf_R7MZbEzlqP9r7I4Lpf1lpWGY/s542/pic50_Cascade.jpg" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="464" data-original-width="542" height="343" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhOfJf-01IxMRA_8Xk7DmywOmEd2BKaNZdQzT0RLIOyYXqvn7KjX2wMU5j4nBcwZVZaXcq_Cm6BlqhzqnIpUYiPWJpwhopT9bqElas6A0aBVXdOW-vWf_R7MZbEzlqP9r7I4Lpf1lpWGY/w400-h343/pic50_Cascade.jpg" width="400" /></span></a></div><span style="font-family: arial;"><br />Set the values as you need to, then <b>Save</b> to lock the changes in</span><p></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqdcPY3xH76EQ0ECbZ1Dmx2xOivZtHOSCMNE3JZkQT5pYcRTZtG5k5LWMTUmefF-1I5oFFFm1MYSR71f751ze5rU463FgLO6r-VLIKYHu7MEK6HBkmTU03_0JXh71i0NqvAreRFn95Dhg/s715/pic51_SaveProperties.JPG" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="715" data-original-width="442" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqdcPY3xH76EQ0ECbZ1Dmx2xOivZtHOSCMNE3JZkQT5pYcRTZtG5k5LWMTUmefF-1I5oFFFm1MYSR71f751ze5rU463FgLO6r-VLIKYHu7MEK6HBkmTU03_0JXh71i0NqvAreRFn95Dhg/w248-h400/pic51_SaveProperties.JPG" width="248" /></span></a></div><span style="font-family: arial;"><br />Now, if we open in the desktop version of Word, we'll see that the data from the Properties form has filled in the QuickParts in the document. Not unlike magic.</span><p></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgo2Ys_PcsNGpupPmp-ThieqLzVtrTzD4AD6KrLKHoNpcZmospHtHiJDhRgATuMckT5RZooEiz434ESGwX1Qz9xoa1txrqgI-4wS9i2CNuNrsdxQk6LbDiTmllX6Uml6U9MTSfxXV_6i4A/s710/pic52_QuickParts.jpg" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="183" data-original-width="710" height="103" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgo2Ys_PcsNGpupPmp-ThieqLzVtrTzD4AD6KrLKHoNpcZmospHtHiJDhRgATuMckT5RZooEiz434ESGwX1Qz9xoa1txrqgI-4wS9i2CNuNrsdxQk6LbDiTmllX6Uml6U9MTSfxXV_6i4A/w400-h103/pic52_QuickParts.jpg" width="400" /></span></a></div><span style="font-family: arial;"><br />So, that's all working fine, then.</span><p></p><p><span style="font-family: arial;">Right ... on to the next bit. Setting up the Flow to get manager sign-off and to convert the final Word document into a PDF form mailing out to the client.<br /><br /></span></p><h3 style="text-align: left;"><span style="font-family: arial;">SETTING UP THE FLOW</span></h3><p><span style="font-family: arial;">Navigate back to the "All Items" view of your library. You should see the <b>Automate</b> menu option sitting above the list of documents. Click on that and select:</span></p><p><span style="font-family: arial;">Power Automate > See your Flows</span></p><p><span style="font-family: arial;">I prefer <b>See your Flows</b>, as it's less restricting than the Create a flow option.</span></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhzm7yitwq8RwYkx-O1jdlejMNL7s8q6nWeULobM8MNihhOaQYSt5BKVmeFZIptDv9Dhf83TX7o4yIvwuF9MupPs_xwBH7PzTKMEw0f8HBWDAo1O6wwQpQnRsWV4_GL-5bDgXNUbueKWg/s386/pic60_SeeYourFlows.jpg" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="198" data-original-width="386" height="205" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhzm7yitwq8RwYkx-O1jdlejMNL7s8q6nWeULobM8MNihhOaQYSt5BKVmeFZIptDv9Dhf83TX7o4yIvwuF9MupPs_xwBH7PzTKMEw0f8HBWDAo1O6wwQpQnRsWV4_GL-5bDgXNUbueKWg/w400-h205/pic60_SeeYourFlows.jpg" width="400" /></span></a></div><span style="font-family: arial;"><br />From the <b>New</b> menu, select <b>Automated from blank</b>, as this is the type of Flow we're going to use.</span><p></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlHV_EE182pYrDB5aHAjr6Fs87yJBZqn1y56nODHx9Dhy4-pzneiDJJElb4kENxp8cYssPDV8H2UOHSLzRWt9Ht_SyHhEQ3dvpeu8czstcVNvHhD1hMWM7OaTVBlpiOEzC_N7RI3M6zWU/s466/pic61_AutomatedFromBlank.jpg" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="340" data-original-width="466" height="291" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlHV_EE182pYrDB5aHAjr6Fs87yJBZqn1y56nODHx9Dhy4-pzneiDJJElb4kENxp8cYssPDV8H2UOHSLzRWt9Ht_SyHhEQ3dvpeu8czstcVNvHhD1hMWM7OaTVBlpiOEzC_N7RI3M6zWU/w400-h291/pic61_AutomatedFromBlank.jpg" width="400" /></span></a></div><span style="font-family: arial;"><br />In the popup window, give your new Flow a name and select the trigger for the Flow ... we're using <b>When an item is created or modified</b>.</span><p></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYNfRqkro5577DVmRPDkSnWTsPs4CyJWQZyiv6Jo41YlwkY-j3h1jaoiJSmcVLKQkvdMnxcGSEWtY6Zn7epX7FWYbGeOqdgtoKx1THgyGRgs0n2SQds2MillCI6xacvcvDhhZaR6SWI_E/s912/pic62_NameAndTrigger.JPG" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="582" data-original-width="912" height="255" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYNfRqkro5577DVmRPDkSnWTsPs4CyJWQZyiv6Jo41YlwkY-j3h1jaoiJSmcVLKQkvdMnxcGSEWtY6Zn7epX7FWYbGeOqdgtoKx1THgyGRgs0n2SQds2MillCI6xacvcvDhhZaR6SWI_E/w400-h255/pic62_NameAndTrigger.JPG" width="400" /></span></a></div><span style="font-family: arial;"><br />Well done for getting this far. Now the real work can start.</span><p></p><p><span style="font-family: arial;">If you have had some experience of creating SharePoint Designer WorkFlows, then much of this will be familiar to you. The principles are the same. WorkFlows and Flows are all about the conditions and the actions. It's just some of the terminology that's changed in Flows. But, of course, not everything is the same ...</span></p><p><span style="font-family: arial;">Your stage for your new Flow should look like this.</span></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQp95dPAvD8MWX1jSRtlrLP0nbEbi08rHQXI_1BGGnlRUC0fCopYeB4RvF2nsiiRTn4UjU9kCKnV__f8O9Tdtzi6jAwMV8aMiDk94tMn9xPhLPRyJvHT6tFXLo7Ni0PEbI1wNRmClOzSE/s623/pic63_FlowStage.JPG" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="281" data-original-width="623" height="180" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQp95dPAvD8MWX1jSRtlrLP0nbEbi08rHQXI_1BGGnlRUC0fCopYeB4RvF2nsiiRTn4UjU9kCKnV__f8O9Tdtzi6jAwMV8aMiDk94tMn9xPhLPRyJvHT6tFXLo7Ni0PEbI1wNRmClOzSE/w400-h180/pic63_FlowStage.JPG" width="400" /></span></a></div><span style="font-family: arial;"><br />Your first task will be to choose the Site where your Library sits ... </span><p></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJWc1nvYu3YGyVMDEdKG7R4Qzc6S_4vp48k38Iq-nFRH4X54jRsToWIQkgnXuCLyzOO4sY1rKB0k3aS1KtKj5EAEFzpjiziH7GajRssfkV6zyo8-BmpEAsu-OeBoMRiT2pGgX3P54_fDo/s622/pic64_SelectSite.jpg" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="338" data-original-width="622" height="217" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJWc1nvYu3YGyVMDEdKG7R4Qzc6S_4vp48k38Iq-nFRH4X54jRsToWIQkgnXuCLyzOO4sY1rKB0k3aS1KtKj5EAEFzpjiziH7GajRssfkV6zyo8-BmpEAsu-OeBoMRiT2pGgX3P54_fDo/w400-h217/pic64_SelectSite.jpg" width="400" /></span></a></div><span style="font-family: arial;"><br />If you can't see your site listed, scroll to the foot of the drop-down, where you'll find <b>Enter custom value</b>.</span><p></p><p><span style="font-family: arial;">... then in the second drop-down, the name of your Library.</span></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwcgoRkjVLDy_zZERrR3-KhyphenhyphenUD1S_3-yM0nOkaODZ3KAjte_g2-mYlBbLm5dQqtTvx3Hv7ssTg1bL-M75o1_m4h35LiqLY8BpdNl1RfJTOXTwD1X0vl_BV0vEjqJiU5Yr6Evh7TeFztcU/s625/pic65_SelectLibrary.JPG" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="316" data-original-width="625" height="203" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwcgoRkjVLDy_zZERrR3-KhyphenhyphenUD1S_3-yM0nOkaODZ3KAjte_g2-mYlBbLm5dQqtTvx3Hv7ssTg1bL-M75o1_m4h35LiqLY8BpdNl1RfJTOXTwD1X0vl_BV0vEjqJiU5Yr6Evh7TeFztcU/w400-h203/pic65_SelectLibrary.JPG" width="400" /></span></a></div><span style="font-family: arial;"><br />Now we need to set up some conditions, so we're not firing off random alerts every time something changes in the Library. So ...</span><p></p><p><span style="font-family: arial;"><span>First row - </span><span>Approved = false</span></span></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUybz0dqJwP1apWmcB2ayO4-xJa42nU2CUEOmGzl9jOVEnYrXoFqwesWQXK-2ClQf8m20TOc6zLk5PXPOQ8mL6BnEnE6oqH1fa1_KTq7C2Gt1vmzuasTSvIrKvAzZE-q2aPXaggViXE94/s691/pic66_Approved.JPG" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="691" data-original-width="653" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUybz0dqJwP1apWmcB2ayO4-xJa42nU2CUEOmGzl9jOVEnYrXoFqwesWQXK-2ClQf8m20TOc6zLk5PXPOQ8mL6BnEnE6oqH1fa1_KTq7C2Gt1vmzuasTSvIrKvAzZE-q2aPXaggViXE94/w378-h400/pic66_Approved.JPG" width="378" /></span></a></div><span style="font-family: arial;"><br />Second row - <span>Approver_txt is not = Null</span></span><p></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><span style="font-family: arial;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiTGMF4G7NVGIEU0w_xYGFIMVw6fR1Di4OAVHTdA0s4rEDg_s_jkOnbKwZYolQ37uxsW184u-_mDejdMaK1IhCEePjKmEVsrStfcNoGLH-_H4zdvRNMDgOO-rauTsWckUBS3ejZZdb71M/s717/pic67_ApproverTxt.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="545" data-original-width="717" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiTGMF4G7NVGIEU0w_xYGFIMVw6fR1Di4OAVHTdA0s4rEDg_s_jkOnbKwZYolQ37uxsW184u-_mDejdMaK1IhCEePjKmEVsrStfcNoGLH-_H4zdvRNMDgOO-rauTsWckUBS3ejZZdb71M/s320/pic67_ApproverTxt.JPG" width="320" /></a><br /><br /></span></div><span style="font-family: arial;"><br /></span><div class="separator" style="clear: both; text-align: center;"><span style="font-family: arial;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtXm0IbGY6_pQ4N-mkS6DhyphenhyphenlPJ9uXEp_dlasQ9e1jFlk_fqTxgAD7v5rR9cXbCGXgOk1CC6RedUWMZ3W4xQKhyZrdDR24_HL0FU2BVvNRUDEWqMcUpo-0PLSmtM6zQds5wONbMQoTQNZU/s1006/pic68_ApproverTxtNotNull.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="478" data-original-width="1006" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtXm0IbGY6_pQ4N-mkS6DhyphenhyphenlPJ9uXEp_dlasQ9e1jFlk_fqTxgAD7v5rR9cXbCGXgOk1CC6RedUWMZ3W4xQKhyZrdDR24_HL0FU2BVvNRUDEWqMcUpo-0PLSmtM6zQds5wONbMQoTQNZU/s320/pic68_ApproverTxtNotNull.jpg" width="320" /></a><br /><br /></span></div><span style="font-family: arial;"><br /></span><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7Cf2W4mBVRRxnnw55ynPF-1KFoJ8qQtTy03SBKL7iF2AFhzP3XebRvRtLLoVOs74gVSNbNcIB6sms67SeKl0oOZuuf0HNZwejZqdR3qS0VD29KzDFRPfRvgV1J8y__ygDGGPr4AxSIm4/s634/pic68a_ApproverTxtNotNull.jpg" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="346" data-original-width="634" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7Cf2W4mBVRRxnnw55ynPF-1KFoJ8qQtTy03SBKL7iF2AFhzP3XebRvRtLLoVOs74gVSNbNcIB6sms67SeKl0oOZuuf0HNZwejZqdR3qS0VD29KzDFRPfRvgV1J8y__ygDGGPr4AxSIm4/s320/pic68a_ApproverTxtNotNull.jpg" width="320" /></span></a></div><span style="font-family: arial;"><br />Third row - <span>Checked Out = false</span></span><p></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzJKhRW2VAcjY8i055k918K1nRDZUz3vx5Fu26kBBRewHeo8vytDz08hQP-cCJfJiUfDtlk6j4EwCREpfkEZfhZbo7IjEu5jCnL6U8jUF4mf2DWGcVv5Rg_fY6RPViTQj5mhgrHHtOFeQ/s715/pic69_CheckedOut.jpg" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="498" data-original-width="715" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzJKhRW2VAcjY8i055k918K1nRDZUz3vx5Fu26kBBRewHeo8vytDz08hQP-cCJfJiUfDtlk6j4EwCREpfkEZfhZbo7IjEu5jCnL6U8jUF4mf2DWGcVv5Rg_fY6RPViTQj5mhgrHHtOFeQ/s320/pic69_CheckedOut.jpg" width="320" /></span></a></div><span style="font-family: arial;"><br />When you're done, your Conditions panel should look like this.</span><p></p><p></p><p></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOENgzIsd89EvqJNjpQiYcvSA_oUUSbqNv2obrO6GJUgz_aLCoWevwtlz5h10kC3RYI-UwoX5f2HWI3j0GREAVQyGi43m61r5BfRKOs1FJpM_koTtNYsPyXdIOiO0RAtfOOalkowJq0KE/s1246/pic70_SetConditions.JPG" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="715" data-original-width="1246" height="230" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOENgzIsd89EvqJNjpQiYcvSA_oUUSbqNv2obrO6GJUgz_aLCoWevwtlz5h10kC3RYI-UwoX5f2HWI3j0GREAVQyGi43m61r5BfRKOs1FJpM_koTtNYsPyXdIOiO0RAtfOOalkowJq0KE/w400-h230/pic70_SetConditions.JPG" width="400" /></span></a></div><span style="font-family: arial;"><br />So what we're saying is: If the document <i>hasn't</i> been approved, and the Approver email address <i>isn't </i>empty, and the document <i>has</i> been checked in, the Flow can run. If any one of those conditions isn't met, the Flow goes down the empty <b>If no</b> branch and essentially does nothing. So that's what we want to happen.</span><p></p><p><span style="font-family: arial;">Next, we're going to turn our attention to the <b>If yes</b> branch, and start loading up actions.</span></p><p><span style="font-family: arial;">So ... we need to <b>Get file properties</b> so we can identify (by its ID) the file the Flow is working on. So <b>Add an action</b> and find <b>Get file properties</b>. </span></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZx0Waacrtzv3qyTi5OmYa2qEWc5j_8lFbCGGcopgziw4ho9hMRYF7H2vgWtoToQlCBF_MFuVCI8mdCEjHyNY6RrCwZSsMP9HYNuAKrvi84TFW_7Z5eWPUYDY2xWlKUdpWz5r7q1ZASAA/s659/pic71_GetFileProp.JPG" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="488" data-original-width="659" height="296" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZx0Waacrtzv3qyTi5OmYa2qEWc5j_8lFbCGGcopgziw4ho9hMRYF7H2vgWtoToQlCBF_MFuVCI8mdCEjHyNY6RrCwZSsMP9HYNuAKrvi84TFW_7Z5eWPUYDY2xWlKUdpWz5r7q1ZASAA/w400-h296/pic71_GetFileProp.JPG" width="400" /></span></a></div><span style="font-family: arial;"><br />Then as before, select the Site and the Library, then add the item ID, like this:</span><p></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXUetf_dxYGf85PiP2fFh3YuyjbsWnPOwhdaizPyymsMZyAT7RAL5LL6mbkOHtZfEcuiKmUz8C358nESnk8YMdpxJl4XPyHHLzu7TKClZNY9ZzKTVbT4b-XjFj4KAOZ2FpzFqpL2kY6zg/s1044/pic72_GetID.JPG" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="463" data-original-width="1044" height="178" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXUetf_dxYGf85PiP2fFh3YuyjbsWnPOwhdaizPyymsMZyAT7RAL5LL6mbkOHtZfEcuiKmUz8C358nESnk8YMdpxJl4XPyHHLzu7TKClZNY9ZzKTVbT4b-XjFj4KAOZ2FpzFqpL2kY6zg/w400-h178/pic72_GetID.JPG" width="400" /></span></a></div><span style="font-family: arial;"><br />Then I added another condition, to check the status of the Approval (that we've not yet asked for), like this.</span><p></p><p><span style="font-family: arial;">Approved = false</span></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhO4Y9e41rikFQP46GG0rw1V7LuofpuPl2ED791V6wFvl3ghssqYgPIOoBB_sRhI9EPhxr855dC3HvgZOZ5ya0T1OgZ63jZdexS8jeoFv1xcKa-zZhuc7f7WEVpz4YX1bvBr_Cr4rri0wU/s868/pic73_RenameCondition.jpg" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="318" data-original-width="868" height="146" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhO4Y9e41rikFQP46GG0rw1V7LuofpuPl2ED791V6wFvl3ghssqYgPIOoBB_sRhI9EPhxr855dC3HvgZOZ5ya0T1OgZ63jZdexS8jeoFv1xcKa-zZhuc7f7WEVpz4YX1bvBr_Cr4rri0wU/w400-h146/pic73_RenameCondition.jpg" width="400" /></span></a></div><span style="font-family: arial;"><br />I would recommend that you start giving your Conditions and Actions descriptive names at this point. Otherwise, things will start to get confusing if all you've got to go on is "Condition 2", "Condition 3" and so on.</span><p></p><p><span style="font-family: arial;">So now we have it set up to only continue if the Approval status of the document is "No".</span></p><p><span style="font-family: arial;">Next, we have to ask the Approver to approve the document. Flow makes that easy for us, as there's a built-in function to ask for approval. Much better than the old SharePoint Designer way of doing things.</span></p><p><span style="font-family: arial;">So <b>Add an action</b>, <b>Start and wait for an approval</b>.</span></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoui8oEEHd7sRtiWNnYBvICstEBlLsH_avmQho0zPU3McWCB8RxQC6w4fHT61J8ifb6rPL0SIGW_WbzLAUFy8SGpWxoKtMj_-GDIIZdFpCzGDq3o9WEXZrOJT_d8rkOW5VSQoKWuqNUn8/s617/pic73_StartWaitApproval.JPG" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="404" data-original-width="617" height="263" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoui8oEEHd7sRtiWNnYBvICstEBlLsH_avmQho0zPU3McWCB8RxQC6w4fHT61J8ifb6rPL0SIGW_WbzLAUFy8SGpWxoKtMj_-GDIIZdFpCzGDq3o9WEXZrOJT_d8rkOW5VSQoKWuqNUn8/w400-h263/pic73_StartWaitApproval.JPG" width="400" /></span></a></div><span style="font-family: arial;"><br />I used Approve/Reject - Everyone must approve</span><p></p><p><span style="font-family: arial;">You'll need to fill in the details of the approval request. Here's how I set mine up:</span></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBKK5dzlTg3RWachp606MOlXpDrvp9uFhbnd4lW_tbveLZcBb2jksF_tjMrytgce3bqYmRT7VRE1PkuF2XCiWaVl_eat-X9dMxhpw_62pspobzeSdMIO4vw9ER-FMfc6xTfBgymygd-tY/s617/pic74_SetupApproval.JPG" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="347" data-original-width="617" height="225" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBKK5dzlTg3RWachp606MOlXpDrvp9uFhbnd4lW_tbveLZcBb2jksF_tjMrytgce3bqYmRT7VRE1PkuF2XCiWaVl_eat-X9dMxhpw_62pspobzeSdMIO4vw9ER-FMfc6xTfBgymygd-tY/w400-h225/pic74_SetupApproval.JPG" width="400" /></span></a></div><span style="font-family: arial;"><br /><b>Title</b> is the subject line of the Approval request email</span><p></p><p><span style="font-family: arial;"><b>Assigned to</b> will ask the Flow to grab the value from the Approver_txt</span></p><p><span style="font-family: arial;"><b>Details</b> is the message in the body of the email. I personalised it by inserting the <b>Name</b> of the document.</span></p><p><span style="font-family: arial;"><b>Item link</b> is useful as it gives the Approver a quick and easy way to open the document for inspection before approving. Use this format: SiteURL + Full Path</span></p><p><span style="font-family: arial;"><b>Item link description</b> is the text in the Approval email that the Approver will click on to open the document.</span></p><p><span style="font-family: arial;">Now we need another Condition ... this time to see if the document has been approved before moving on to the next (lengthy) sequence.</span></p><p><span style="font-family: arial;">So, add a Condition and set the single row to:</span></p><p><span style="font-family: arial;">Outcome = Approve</span></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEho1lKQ0kLIOj5kk4fa0NGfS5dOaOk-uLlIlbYq-EAY8nXTZg16oVioyQEPVXBR4w6o_TFxFIn0VGmwXqwvXSUbnwc4ebd8gM6rJRC8jHgEoYVNfXQcisHOcoCIdaJTO4heHpcdTmAqjGU/s671/pic75_OutcomeCondition.JPG" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="398" data-original-width="671" height="238" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEho1lKQ0kLIOj5kk4fa0NGfS5dOaOk-uLlIlbYq-EAY8nXTZg16oVioyQEPVXBR4w6o_TFxFIn0VGmwXqwvXSUbnwc4ebd8gM6rJRC8jHgEoYVNfXQcisHOcoCIdaJTO4heHpcdTmAqjGU/w400-h238/pic75_OutcomeCondition.JPG" width="400" /></span></a></div><span style="font-family: arial;"><br />Right, now we're ready for the meat of this Flow. In this series of Actions, if the Document is Approved by the Approver, we'll:</span><p></p><p></p><ol style="text-align: left;"><li><span style="font-family: arial;">Check out the file so we can have the Flow make changes to the metadata (so make sure documents need to be checked out to make changes in the Library Settings)</span></li><li><span style="font-family: arial;">Update the File Properties, setting the <b>Approved</b> value to true</span></li><li><span style="font-family: arial;"><b>Check in</b> the file</span></li><li><span style="font-family: arial;"><b>Get the file content</b>, ready for creating a PDF</span></li><li><span style="font-family: arial;"><b>Create a New</b> Word Doc and add the file content</span></li><li><span style="font-family: arial;">Convert the file to a PDF</span></li><li><span style="font-family: arial;">Give the new PDF the same File Properties (metadata) as the original Word Doc</span></li><li><span style="font-family: arial;"><b>Check in</b> the PDF (we don't want to send that to the Approver for Approval, as they've already Approved that content)</span></li><li><span style="font-family: arial;"><b>Delete</b> the copy of the Word Doc we stored in OneDrive</span></li><li><span style="font-family: arial;"><b>Send an Email</b> with the PDF attached (for the convenience of the original author, the PDF has also been stored in the Document Library.</span></li></ol><p></p><p><span style="font-family: arial;"><br /></span></p><h3 style="text-align: left;"><span style="font-family: arial;">STEP-BY-STEP</span></h3><p><span style="font-family: arial;">First, check out the Word Document so we can make changes to the metadata field, specifically the Approved field, which we're going to change to Yes.</span></p><p><span style="font-family: arial;"><b>Add an action</b>, type "Check Out" to narrow the options, and select <b>Check Out File</b>. Once you've done that select the Site URL and the Document library (as you did for earlier Get File Properties actions. In the ID field, add ID from the Dynamic Content list - we need to know what document we're working on.</span></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizfpXIyn57Ei3MtNrBpptY2MInSiGBk_AZppDFut_5iS3h1JV1IBuDqH7IVCZwY-ornojL5j-jLqrR33z6X_qWTBCpzQczm0GcdoLETDWSWYimKZQQJZYccWVcIQNkTYswb8Rq0g53rEI/s617/pic76_CheckOut.jpg" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="192" data-original-width="617" height="125" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizfpXIyn57Ei3MtNrBpptY2MInSiGBk_AZppDFut_5iS3h1JV1IBuDqH7IVCZwY-ornojL5j-jLqrR33z6X_qWTBCpzQczm0GcdoLETDWSWYimKZQQJZYccWVcIQNkTYswb8Rq0g53rEI/w400-h125/pic76_CheckOut.jpg" width="400" /></span></a></div><span style="font-family: arial;"><br /><b>Add an action</b>, <b>Update file properties</b>. Select the Site, the Document Library and the ID again. Leave everything else blank, except for <b>Approved</b>, which you should set to <b>Yes</b>. You could blank out DocType Value and Successful by selecting Custom value and leaving it blank. Or you could maintain the DocType Value by inserting DocType Value from the Dynamic Content listing (I did the latter, last time round).</span><p></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJ053A50MxfMjhPAeT4Y3cZBa0vxfM-OgRzZQ_oBj3izjVDoqDetp-Jrj0kM3xpBt2aiyhr16oFkwO4QMnIEawWRP3BSXmPtY-cVWY0ZsbydFYboQ2ErpDX-rx5c9f9Z2K-E6K4mw8bWc/s672/pic77_UpdateFileProp.JPG" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="672" data-original-width="618" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJ053A50MxfMjhPAeT4Y3cZBa0vxfM-OgRzZQ_oBj3izjVDoqDetp-Jrj0kM3xpBt2aiyhr16oFkwO4QMnIEawWRP3BSXmPtY-cVWY0ZsbydFYboQ2ErpDX-rx5c9f9Z2K-E6K4mw8bWc/w368-h400/pic77_UpdateFileProp.JPG" width="368" /></span></a></div><span style="font-family: arial;"><br />Now we've done that, we should Check In the file. So <b>Add an action</b> of <b>Check In File</b>, then fill in the form presents with Site, Library, ID, a comment and the version type, Major Version.</span><p></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTOtdhpvtsAbujEi-sDZMvU9dvI7MNvlcht3fKvsg92QwEg-haCrZ2HopPUywIbp6Kp-8dzrzOBIO_-eziyh_sSC4BGGrRlF6DPO-D_VANrkqnYIb-qG-QUP-jRX7NLFwVaVaEwK6FrbY/s620/pic78_CheckInFile.jpg" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="283" data-original-width="620" height="183" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTOtdhpvtsAbujEi-sDZMvU9dvI7MNvlcht3fKvsg92QwEg-haCrZ2HopPUywIbp6Kp-8dzrzOBIO_-eziyh_sSC4BGGrRlF6DPO-D_VANrkqnYIb-qG-QUP-jRX7NLFwVaVaEwK6FrbY/w400-h183/pic78_CheckInFile.jpg" width="400" /></span></a></div><span style="font-family: arial;"><br />That's the sequence for updating the Document's status to Approved. Now we're going to create the PDF. This is a bit clunky, and I'm sure we really should be using a generic access to OneDrive, but I just used my own, since we're deleting the copy of the Document right after we've PDFed it.</span><p></p><p><span style="font-family: arial;">So first, we need to hoover up all the content from the document. <b>Add an action</b> and select <b>Get file content</b> from the Dynamic Content list - make sure you choose the SharePoint one, not the OneDrive one!</span></p><p><span style="font-family: arial;">Fill in the Site URL (again!), and for File Identifier, choose Identifier from the Dynamic Content listing.</span></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjm4UqANSa0oAlkgyDLkDzHsYT0q-GwpMuokwHhO6Z5hbinfDTSFYD9xzY3MuzNgy3LKGyqEv-DiTzXtRuE3Tk9iXITIP5XyuhzFxVLQJP2hL5Lvx9YkSaXQlgsaNoKOck1fkw7Ik4xNDc/s610/pic79_GetFileContent.jpg" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="228" data-original-width="610" height="150" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjm4UqANSa0oAlkgyDLkDzHsYT0q-GwpMuokwHhO6Z5hbinfDTSFYD9xzY3MuzNgy3LKGyqEv-DiTzXtRuE3Tk9iXITIP5XyuhzFxVLQJP2hL5Lvx9YkSaXQlgsaNoKOck1fkw7Ik4xNDc/w400-h150/pic79_GetFileContent.jpg" width="400" /></span></a></div><span style="font-family: arial;"><br />Now we have the file content, we need somewhere to put it, so we'll create a new document on OneDrive. <b>Add an action</b> of <b>Create file</b> (this time choose the OneDrive version and not the SharePoint one).</span><p></p><p><span style="font-family: arial;">I created a new folder on my OneDrive to hold these temporary documents. And because I'd already created it, it was available as a choice option on the fly-out menu.</span></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCAZzOjT4fdtFTEIRBbKTuA7S2Qa3eVIVSogC6dwxnnKe2PaUcfEQ4IXnjlWo7PxpdXCGykVDHdd4s0bp29gqS7HaTCluxhlojFEW1y7aw0y_2lgYt76moAE-f0PIPwdhmAogC9HoVRT8/s924/pic80_OneDrivePath.JPG" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="247" data-original-width="924" height="108" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCAZzOjT4fdtFTEIRBbKTuA7S2Qa3eVIVSogC6dwxnnKe2PaUcfEQ4IXnjlWo7PxpdXCGykVDHdd4s0bp29gqS7HaTCluxhlojFEW1y7aw0y_2lgYt76moAE-f0PIPwdhmAogC9HoVRT8/w400-h108/pic80_OneDrivePath.JPG" width="400" /></span></a></div><span style="font-family: arial;"><br />Make the name of the file the same as the source Document (don't forget the ".docx" suffix of the new doc won't be recognised) and add the File Content from the earlier <b>Get file content</b> action.</span><p></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMUMhrWi0ytRu_PBuof9DdrENOu02wY6oN90i8Rwik3PvG_vlrVrFeZxmV_fNt-vdiUy_oHia3WTxdBTndCbav_8zROgLX5JLPwCk3YCo5dKHUHdAzmYb2htL9siyikF-jMHoi49B9XNI/s616/pic81_CreateFile.JPG" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="212" data-original-width="616" height="138" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMUMhrWi0ytRu_PBuof9DdrENOu02wY6oN90i8Rwik3PvG_vlrVrFeZxmV_fNt-vdiUy_oHia3WTxdBTndCbav_8zROgLX5JLPwCk3YCo5dKHUHdAzmYb2htL9siyikF-jMHoi49B9XNI/w400-h138/pic81_CreateFile.JPG" width="400" /></span></a></div><span style="font-family: arial;"><br />Now we just have to convert the file to a PDF. <b>Add an action</b> and choose <b>Convert File (Preview)</b>. In the File field add ID (from the OneDrive options). Leave the Target type as PDF.</span><p></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIbGRPJMSKYzVqb2Ir6BdKVd3jpzqD8S2MNvXUp1XLDcnWjm0vtAVPOm7Xedk47bI9-JFZ0Pg9ik8MpXMApgMEXeYSZqcDydE2oDZyaZ97awZrFJkYMmSez6HK74TSIDjePyz3Um93Xug/s612/pic82_ConvertFile.JPG" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="187" data-original-width="612" height="122" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIbGRPJMSKYzVqb2Ir6BdKVd3jpzqD8S2MNvXUp1XLDcnWjm0vtAVPOm7Xedk47bI9-JFZ0Pg9ik8MpXMApgMEXeYSZqcDydE2oDZyaZ97awZrFJkYMmSez6HK74TSIDjePyz3Um93Xug/w400-h122/pic82_ConvertFile.JPG" width="400" /></span></a></div><span style="font-family: arial;"><br />So, we have a PDF of the original Word Document stored on our OneDrive. We need to bring it back to the SharePoint Document Library, so we do the reverse of how we created the PDF.</span><p></p><p><span style="font-family: arial;"><b>Add an action</b> to <b>Create a file</b>, choosing the SharePoint version. Select the site URL (yet again!), choose the Library in the Folder Path, Name the file using Name from the Dynamic Content listing and get the File Content from the previous Convert File (Preview) step. It should look like this:</span></p><span style="font-family: arial;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEJgjYACJkU9GL8kRKS3yN1P0lOn_2Ko1iYyrW3uqtO0dDjc09BxlEb8At_U8XHXS6Skkzx5W1gf7wTWmQc15ok7pCkuDnhKy3Hi6BALtJdjG9clOmd9NnErXxIbiHYX-IeUUYQbFrH18/s618/pic83_CreateFile.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="236" data-original-width="618" height="153" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEJgjYACJkU9GL8kRKS3yN1P0lOn_2Ko1iYyrW3uqtO0dDjc09BxlEb8At_U8XHXS6Skkzx5W1gf7wTWmQc15ok7pCkuDnhKy3Hi6BALtJdjG9clOmd9NnErXxIbiHYX-IeUUYQbFrH18/w400-h153/pic83_CreateFile.jpg" width="400" /></a></div><br />Now we need to Update the properties of the new PDF in the SharePoint Library with the same metadata as the source document. So <b>Add an action</b> and select <b>Update file properties</b>. Fill it in like this:<br /></span><span style="font-family: arial;"><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_BBe_3i6JYh2qYlj-2XFJQk_hAG8OMX0Wk5IQokwaEwNcvdxUzHgqsH7i_PssDQ2QDcH7EX3wLzYx0Wa5prpQ2Zzjokb9My9tZo3oxKZK27EOCuHk3U0Q-xP27X0JyHbfZU4LCCIMw70/s718/pic84_UpdateFileProp.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="718" data-original-width="617" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_BBe_3i6JYh2qYlj-2XFJQk_hAG8OMX0Wk5IQokwaEwNcvdxUzHgqsH7i_PssDQ2QDcH7EX3wLzYx0Wa5prpQ2Zzjokb9My9tZo3oxKZK27EOCuHk3U0Q-xP27X0JyHbfZU4LCCIMw70/w344-h400/pic84_UpdateFileProp.JPG" width="344" /></a></div><br />These should all be from the <span><b>Update file properties - to Approved</b></span> action.</span><p></p><p><span style="font-family: arial;">Now check your new PDF in (<i><b>Note:</b> Make sure the Library requires documents to be checked out before editing, otherwise, this Action will cause an error</i>). <b>Add an action</b>, select <b>Check in file</b>. Add Site URL and Library. Get the ID from the previous action - <b>Update file properties - PDF</b>.</span></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipug8ubvTJpmg7m8_ifutHNi76WydYvBrnrgBvooS24OkMdJnXu9l55BXwIQOve_CNiYAOdoWyK36YpblFOK7pJKl5K1UcKioGVpo72X5Bv6DG_Vsw_4lePf_V0gewCplJFWE9T50gU_Q/s614/pic85_CheckInFile.JPG" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="279" data-original-width="614" height="181" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipug8ubvTJpmg7m8_ifutHNi76WydYvBrnrgBvooS24OkMdJnXu9l55BXwIQOve_CNiYAOdoWyK36YpblFOK7pJKl5K1UcKioGVpo72X5Bv6DG_Vsw_4lePf_V0gewCplJFWE9T50gU_Q/w400-h181/pic85_CheckInFile.JPG" width="400" /></span></a></div><span style="font-family: arial;"><br />And as we don't want our OneDrive getting cluttered with old Word documents, let's delete the copy file. <b>Add an action</b> and select <b>Delete file</b> from the OneDrive options. Choose the ID from the OneDrive Create file action.</span><p></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxHWfMQ3jJUe4Ktj4zzJ5i3Abnj2KzmaBxYrBKpGq_UH88A2sCgPNWyfBwKjHiluF39xCsWmUH50yI2bqGyEI6U0eQbWR1IKnfOyFsGfxmbFph9ma_N6Z7MnXLVRVa23lHnrqtJNHeI3E/s618/pic86_DeleteFile.JPG" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="125" data-original-width="618" height="81" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxHWfMQ3jJUe4Ktj4zzJ5i3Abnj2KzmaBxYrBKpGq_UH88A2sCgPNWyfBwKjHiluF39xCsWmUH50yI2bqGyEI6U0eQbWR1IKnfOyFsGfxmbFph9ma_N6Z7MnXLVRVa23lHnrqtJNHeI3E/w400-h81/pic86_DeleteFile.JPG" width="400" /></span></a></div><span style="font-family: arial;"><br />All that remains now is to send an email notification the the original document author to let them know their brochure has been approved and to let them have a PDF of the final document.</span><p></p><p><span style="font-family: arial;">Use <b>Send an email (V2)</b>. Set it up like this:</span></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhe-AT3R1T2uf7dEUZnEw771OVjUNhAFBCX8orQu36bXE-RKJqTslCgRffw3nQ_cInULTRLBR_yj2HN9BTHgIEnpIVviFu9uDS8vRiUeVriwxIu49VrCOX8TzO64c2CmJXt6L2LxJJuQEQ/s874/pic87_SendEmailAttach.JPG" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="874" data-original-width="619" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhe-AT3R1T2uf7dEUZnEw771OVjUNhAFBCX8orQu36bXE-RKJqTslCgRffw3nQ_cInULTRLBR_yj2HN9BTHgIEnpIVviFu9uDS8vRiUeVriwxIu49VrCOX8TzO64c2CmJXt6L2LxJJuQEQ/w284-h400/pic87_SendEmailAttach.JPG" width="284" /></span></a></div><span style="font-family: arial;"><br />And that's it.</span><p></p><p><span style="font-family: arial;">You may want to create a couple of new views in your document library, perhaps separating completed and approved Word Docs and finished PDFs into different views, just to keep things tidy. Otherwise, you have a working system,</span></p><p><span style="font-family: arial;">All that remains is to do some testing.</span></p><p><span style="font-family: arial;">When I had some time, I was going to look into tracking which brochures led to successful pitches and how I could track the resulting revenues. But that's for another post and another time.</span></p><p><span style="font-family: arial;">I hope that's helped someone.</span></p><p><span style="font-family: arial;"><br /></span></p><p><span style="font-family: arial;"><br /></span></p><p><span style="font-family: arial;"><br /></span></p>AirPiratePresshttp://www.blogger.com/profile/13136561512898563240noreply@blogger.com0tag:blogger.com,1999:blog-3023476837266527744.post-46453405253194552522020-09-25T08:51:00.010-07:002024-01-26T08:53:49.796-08:00Create a Word brochure generator with Power Apps and Power Automate: Part One<p><span style="font-family: arial;"><b>I was asked by my Marketing colleagues whether I could build an application in SharePoint that would generate and store marketing brochures from Word templates and organise them by region and line of business.</b></span></p><p><span style="font-family: arial;">In the old world of SharePoint Designer I would be able to do that quite easily, but as we're all aware, Microsoft started deprecating core SPD functions, like custom input forms, around the beginning of June 2020, leaving us SPD workers a bit stranded.</span></p><p><span style="font-family: arial;">Though I haven't seen any posting about it anywhere, my work was further limited by being unable to connect Data View Web Parts to Data Sources in SPD. This may be an internal problem at my company, but the effects are just as real.</span></p><p><span style="font-family: arial;">So, with no DVWPs, no custom forms in SPD and 2010 workflows being turned off in November 2020 I didn't have a lot to work with. My company was able to arrange a course for me on Power Platform and Power Automate, though these turned out to be quite entry-level and lacking the depth I'd need for this brochure project. But with the help of some more knowledgeable colleagues, I was able to find a way through and create quite an effective application.</span></p><h3 style="text-align: left;"><span style="font-family: arial;">How it works</span></h3><p><span style="font-family: arial;">Here's how the marketing team wanted the Brochure Generator to work.</span></p><p></p><ol style="text-align: left;"><li><span style="font-family: arial;">The user creates a new document from a template</span></li><li><span style="font-family: arial;">A form pops up for the User to add the customer's name, the date of the brochure as well as region, Line of Business and, behind the scenes, the name of the Supervising Manager. </span></li><li><span style="font-family: arial;">The user then adds the sales pitch into the Word document and saves and checks in. This initiates an automated approval process</span></li><li><span style="font-family: arial;">The Supervising Manager receives an alert that a new brochure has been created. They review and approve (or not approve)</span></li><li><span style="font-family: arial;">If approved, the system converts the Word doc to a PDF</span></li><li><span style="font-family: arial;">The user receives notification of the manager's approval, with the PDF as an attachment, ready to send out to the customer</span></li><li><span style="font-family: arial;">If not approved, the user makes amendments and saves and checks in and the Approval process kicks off again (repeat until approval obtained).</span></li></ol><p></p><h3 style="text-align: left;"><span style="font-family: arial;">What you need</span></h3><p></p><ul style="text-align: left;"><li><span style="font-family: arial;">A SharePoint Modern Experience Teamsite</span></li><li><span style="font-family: arial;">A Document Library (set to "Require documents to be checked out before they can be edited", in versioning settings)</span></li><li><span style="font-family: arial;">A Custom List with four columns - Region, Dept, Line of Business, Approving Manager</span></li><li><span style="font-family: arial;">One or more Word templates, configured with Quick Parts to hold the dynamic data</span></li><li><span style="font-family: arial;">Access to Power Apps and Power Automate</span></li><li><span style="font-family: arial;">Access to OneDrive</span></li></ul><p></p><h3 style="text-align: left;"><span style="font-family: arial;">How I did it</span></h3><p><span style="font-family: arial;">I started with a Modern Experience Teamsite. You may be able to use an old-school Classic Teamsite, but I was told on my course that some Power Platform functions don't work properly on Teamsites that were created in Classic mode.</span></p><p><span style="font-family: arial;"></span></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAZ73ReIkU3MXUw2H8eJuyKxyiEC5Is4mUDNaAPwVUQoyhcKCRTkOZqTyR2G4QS7QHqOwettTrgkJcT_5z0bSkxOUgpVf3fi5M_srw5QbJYOPyIHktXjJXBTMpWWktamyw59xOrs1mGz0/s1551/pic01_ModernExperience.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="886" data-original-width="1551" height="229" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAZ73ReIkU3MXUw2H8eJuyKxyiEC5Is4mUDNaAPwVUQoyhcKCRTkOZqTyR2G4QS7QHqOwettTrgkJcT_5z0bSkxOUgpVf3fi5M_srw5QbJYOPyIHktXjJXBTMpWWktamyw59xOrs1mGz0/w400-h229/pic01_ModernExperience.JPG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>You don't have to have a nice-looking Landing Page, but it does give the whole thing more of a professional look, don't you think?</i><br /></td></tr></tbody></table><span style="font-family: arial;"><br />I believe all Teamsites come with some basic components, like a Document Library. In our site farm, they do, anyway. </span><p></p><p><span style="font-family: arial;"></span></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifVS0F6kVQYjEaa_GHsv61e5l6tbdk3AdqfgXAFyxAnksO0ff1mPq5yGG1Ykrj4oMoh5ossS_Nht6VU2r4UukCnXkByL9BE6BPuggDPeqmhfVu40wpZ_pSZ6nCt5-JN91PuIqK9zuZ_sc/s839/pic02_CreateContentType.jpg" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="355" data-original-width="839" height="169" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifVS0F6kVQYjEaa_GHsv61e5l6tbdk3AdqfgXAFyxAnksO0ff1mPq5yGG1Ykrj4oMoh5ossS_Nht6VU2r4UukCnXkByL9BE6BPuggDPeqmhfVu40wpZ_pSZ6nCt5-JN91PuIqK9zuZ_sc/w400-h169/pic02_CreateContentType.jpg" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>Navigate to Site Content Types, click on create and follow the onscreen prompts. If you need detailed instructions for this, a quick Goggle search will help.</i><br /></td></tr></tbody></table><span style="font-family: arial;"><br />My first task was to create custom Content Types to hold the metadata for the Documents in the Document Library. I think it's possible to use List/Library Columns in Content types, but why do that? Using Site Columns means the Content Types can be used with other Libraries in the site, something that saved me a bunch of work later, as you'll see. In addition, since we're planning to import list column values into the Word Document, I believe that the Quick Parts we'll be using for that only recognise Content Types and not List Columns.</span><p></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><img border="0" data-original-height="558" data-original-width="1024" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwMtDmYNHokF0uJ4tknL7gvlUkit1li-DMgFrizV7XSLh1nirPr1Zclj-8LRmmBWZHZ5k72_o8m533zWNt04WfktSnkWFMhP6Jhn0C6L2Ehadmpbu7y2rzXdE_DARwkxszmCejZufMST4/s320/pic03_CreateContentType.JPG" style="margin-left: auto; margin-right: auto;" width="320" /></td></tr><tr><td class="tr-caption" style="text-align: center;"><span style="font-family: arial;"><i>You may want to use more than one template, so make sure you give your Content Types simple and descriptive names, so your users know what they're getting. </i></span><br /></td></tr></tbody></table><p><span style="font-family: arial;">So I got to work to create some Site Columns that would make up my first Content Type.</span></p><p><span style="font-family: arial;">As an inexperienced Power Platform student, my first thought was to create Site Columns as Lookups. That's what we'd do if we were using SharePoint Designer, right? Then add a bit of JQuery to get the cascades to work? You don't do that with Power Apps.</span></p><p><span style="font-family: arial;">I wasted a whole lot of time searching via Google to find a way to do cascading menus in Power Apps. I found several "solutions". None of them worked. That could have been my fault, but I don't think so. I'm fairly good at following instructions. The working solution came from my friend and colleague Ernani, who showed me how to do great drop-down cascades in Power Apps ... but I'll get to that later.</span></p><p><span style="font-family: arial;">So, like I say, normally, I'd do Look-Up columns to achieve a cascading menu set. But in this case, we're going to Single Line of Text columns to hold the cascade info. Bear with me, it'll become plain.</span></p><p><span style="font-family: arial;"></span></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMY2uxkD5K5MgpPpX8fKgQ6ZnWfi6qjAftifKmFd30GfINflIxNQHBseb1te7WxbbgAiGLD18QTeltfcuOD6s53zsp3DIVZqqXCP62dHQIJd2-ZCSlOPzCd_Hsy9ah55gHWuwMsTgPSYE/s1130/pic04_ContentTypes.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="365" data-original-width="1130" height="129" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMY2uxkD5K5MgpPpX8fKgQ6ZnWfi6qjAftifKmFd30GfINflIxNQHBseb1te7WxbbgAiGLD18QTeltfcuOD6s53zsp3DIVZqqXCP62dHQIJd2-ZCSlOPzCd_Hsy9ah55gHWuwMsTgPSYE/w400-h129/pic04_ContentTypes.JPG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>This is what my finished Content Type looked like when I added all the necessary Site Columns.<br /></i></td></tr></tbody></table><span style="font-family: arial;"><br />Once you've added all the new Site Columns to the Content Type, navigate to the Library Settings and add the Content Type to your Library.</span><p></p><p><span style="font-family: arial;"></span></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_A5OUMaRgd48gSmUTFQS_0miiB4DW3MAoNVUe9j3E64K1x25-in5MCyGsB6ozvh1COXuXDsz0lAU39yoeQn-lCcAnbXDPOfK9ctfl3ogJYACvtq_U3NdjG0OfUOtf80vc7fUjcsw12_A/s1015/pic05_AddContentTypeToLib.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="276" data-original-width="1015" height="109" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_A5OUMaRgd48gSmUTFQS_0miiB4DW3MAoNVUe9j3E64K1x25-in5MCyGsB6ozvh1COXuXDsz0lAU39yoeQn-lCcAnbXDPOfK9ctfl3ogJYACvtq_U3NdjG0OfUOtf80vc7fUjcsw12_A/w400-h109/pic05_AddContentTypeToLib.JPG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>This is what it looks like with your Content Type in place. Note that I've used two different Content Types to handle two different templates - you can only attach one Word Template to a Content Type.</i><br /></td></tr></tbody></table><span style="font-family: arial;"><br />Now we can create the Custom List (I called mine "metadata") that will power the cascading drop-downs. The columns I used were:</span><p></p><p></p><ul style="text-align: left;"><li><span style="font-family: arial;">Geography (single line of text)</span></li><li><span style="font-family: arial;">Dept (single line of text)</span></li><li><span style="font-family: arial;">Line of Business (using the Title Column, single line of text)</span></li><li><span style="font-family: arial;">Approver (name field)</span></li></ul><p></p><p><span style="font-family: arial;"></span></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLUFriAZJCX9UoW838YVUczd_spRKXfwDxS6CTuYLtOnbQI6uwyWfEwUbGLxzIwKO6UrTj_AaM6kbbohpqYmze1T7AEPhM27-EkdzM5sRw09IrislRSHRWrfWe2cuRbM3hwMx4wX311jk/s724/pic07_metadataListSettings.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="322" data-original-width="724" height="178" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLUFriAZJCX9UoW838YVUczd_spRKXfwDxS6CTuYLtOnbQI6uwyWfEwUbGLxzIwKO6UrTj_AaM6kbbohpqYmze1T7AEPhM27-EkdzM5sRw09IrislRSHRWrfWe2cuRbM3hwMx4wX311jk/w400-h178/pic07_metadataListSettings.JPG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>This is how I set my metadata list up. Make sure you use the same column types.</i><br /></td></tr></tbody></table><span style="font-family: arial;"><br />The final list looks like this, though obviously, I'm not showing all the rows here.</span><p></p><p><span style="font-family: arial;"></span></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjN3xlfTwsKfkVmmlBHC0Ig3l7sLulNO8UZ6luUTNJ6cgJ0WRtcDK6fYnG_Q8tLaD1lh5VSaVZD9nODezNhIJ76b7tKaer1DysbPH8F8iFj_Ky4nm3dLWvU_GPkFg1MuuUBIw_sTNFhcJo/s797/pic08_metadataColumns.jpg" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="330" data-original-width="797" height="165" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjN3xlfTwsKfkVmmlBHC0Ig3l7sLulNO8UZ6luUTNJ6cgJ0WRtcDK6fYnG_Q8tLaD1lh5VSaVZD9nODezNhIJ76b7tKaer1DysbPH8F8iFj_Ky4nm3dLWvU_GPkFg1MuuUBIw_sTNFhcJo/w400-h165/pic08_metadataColumns.jpg" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>Here's a snapshot of the populated metadata list. I used the Title column for the unique "Line of Business" values, but it doesn't matter if you want to create a new column.</i><br /></td></tr></tbody></table><span style="font-family: arial;"><br />We'll use Power Apps to make the Custom List and the Document Library talk to each other.</span><p></p><p><span style="font-family: arial;"></span></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnOtcUXkkvzYxDud-5u8zra5XvQ-yK89W_q4z1MeqjF-7Vd35EKH6WUe8gZqw-PWPaoloUlfd0YF-qQlpTxnMccC3l08AVMUwm8Ofb7F2W_ZUGXJYU6RDtzRjKfG_dfobOC8sIZf-QY1o/s1566/pic09_LibraryProperties.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="464" data-original-width="1566" height="119" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnOtcUXkkvzYxDud-5u8zra5XvQ-yK89W_q4z1MeqjF-7Vd35EKH6WUe8gZqw-PWPaoloUlfd0YF-qQlpTxnMccC3l08AVMUwm8Ofb7F2W_ZUGXJYU6RDtzRjKfG_dfobOC8sIZf-QY1o/w400-h119/pic09_LibraryProperties.JPG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>This is what the Properties input form (EditForm.aspx) looks like at this stage of the build. Quite a few of the fields/Content Types are missing.</i><br /></td></tr></tbody></table><span style="font-family: arial;"><br />Even though the Content Type has been added to the Library and the Site Columns should be available, when you try to amend the Properties of an uploaded document, you don't get all the fields in the default Properties window, so the next thing I did was to start up PowerApps to create a custom input form. </span><p></p><p><span style="font-family: arial;"></span></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjojs02KcdH4a8dsrp3kOtt8ph_olnCR1y_QYH6CSor2mWQgAbNM_38ApgoT-nw-voZaOP2WgioUJsn0mwDSKsVVuKueq18VSkUkzLMwCHf7_i_Irt_fOWU7pRgaG8rcS2jSak_9ITj7MQ/s1024/pic10_OpenPowerApps.jpg" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="456" data-original-width="1024" height="178" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjojs02KcdH4a8dsrp3kOtt8ph_olnCR1y_QYH6CSor2mWQgAbNM_38ApgoT-nw-voZaOP2WgioUJsn0mwDSKsVVuKueq18VSkUkzLMwCHf7_i_Irt_fOWU7pRgaG8rcS2jSak_9ITj7MQ/w400-h178/pic10_OpenPowerApps.jpg" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>It's pretty easy to fire up Power Apps from your main Library. You may prefer to work from a Canvas App, but that's up to you.</i><br /></td></tr></tbody></table><span style="font-family: arial;"><br />I chose <b>Customise Forms</b> so that I had a basis to work on. Even so, what's available is a bit sparse. All I had on the EditForm stage was "Title". </span><p></p><p><span style="font-family: arial;"></span></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjWHTwNtGYMqLBE3RSDk4B5CF02s5mBa1JuowD6aF04v8P8jvj7MaAQFoQNmCCb3eN9j1XBZFMcrhiHSXm-Sd2k73uDEffHr7a-hVnxIDWHKHBGeepbLy02A0lUKk9w4h8ezPoJ2BkIc8/s1565/pic11_PowerAppsStage.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="774" data-original-width="1565" height="198" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjWHTwNtGYMqLBE3RSDk4B5CF02s5mBa1JuowD6aF04v8P8jvj7MaAQFoQNmCCb3eN9j1XBZFMcrhiHSXm-Sd2k73uDEffHr7a-hVnxIDWHKHBGeepbLy02A0lUKk9w4h8ezPoJ2BkIc8/w400-h198/pic11_PowerAppsStage.JPG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>A bit of a blank canvas, really ... </i><br /></td></tr></tbody></table><span style="font-family: arial;"><br />Before we can go any further, we'll need to add the custom list to the Power Apps form so that any custom field we add can pick up the data from the list. This is essential to get our cascades working. So, click on the <b>Data</b> icon in the very far left of your screen</span><div><span style="font-family: arial;"><br /></span></div><div><span style="font-family: arial;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhF_jHNOS7Nt8T7iKpIVhyphenhyphen4j8MwVJlMOfFdDUgobKwHcZ74VRmNhCo5fuzpZfUiuVGCdM6S2w4uLrdxgHFt3mGZrdBnzXefI9Oq0aB3Ib6zdK3Rlj4aEehn9UtD6wZmSzQaoXtrM1SP5Dk/s331/pic11_DataPanel.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="291" data-original-width="331" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhF_jHNOS7Nt8T7iKpIVhyphenhyphen4j8MwVJlMOfFdDUgobKwHcZ74VRmNhCo5fuzpZfUiuVGCdM6S2w4uLrdxgHFt3mGZrdBnzXefI9Oq0aB3Ib6zdK3Rlj4aEehn9UtD6wZmSzQaoXtrM1SP5Dk/s320/pic11_DataPanel.JPG" width="320" /></a></div><br />Now click on </span><b style="font-family: arial;">Connectors</b><span style="font-family: arial;"> and select </span><b style="font-family: arial;">SharePoint</b><span style="font-family: arial;">. Sign in as yourself, if prompted.</span><p></p><p></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="font-family: arial; margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1yuQdirXuU2ndp0-JyefEXGHdTUB2w5OfXsVkB-i-XKSe7zhuzWl_pOGA15YLjJmeG5Gdnl5Q-EAoqyNMOUYfY8SZxGPTU67gaDiESBdPSb47ylcA-83-y3-95cjf_S4CaDtoQK_b2Lg/s621/pic11_SignIn.jpg" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="358" data-original-width="621" height="230" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1yuQdirXuU2ndp0-JyefEXGHdTUB2w5OfXsVkB-i-XKSe7zhuzWl_pOGA15YLjJmeG5Gdnl5Q-EAoqyNMOUYfY8SZxGPTU67gaDiESBdPSb47ylcA-83-y3-95cjf_S4CaDtoQK_b2Lg/w400-h230/pic11_SignIn.jpg" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><br /></td></tr></tbody></table><span style="font-family: arial;">Over on the right hand side, you'll now see a list of all the SharePoint sites available to you. Click on the appropriate site to select it. </span><p></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjneGKhh3jvE3T1e4Ue2BI235VSsNyY7HniPu1YLToTTaUJ3Ffui0vahSV81vzvFoNs1KnFaSShlRGHDY4FGfJs_2dSO_ZELRgqbT7y8ST6N94j0GljezDYkAAgvIxB0vgzE-lxPEIq2cc/s351/pic11_ConnectData.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="351" data-original-width="341" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjneGKhh3jvE3T1e4Ue2BI235VSsNyY7HniPu1YLToTTaUJ3Ffui0vahSV81vzvFoNs1KnFaSShlRGHDY4FGfJs_2dSO_ZELRgqbT7y8ST6N94j0GljezDYkAAgvIxB0vgzE-lxPEIq2cc/s320/pic11_ConnectData.jpg" /></a></div><br /><span style="font-family: arial;">The view now switches to display all the Libraries and Lists in the selected site. Choose the List to connect to, in my case, I chose the list "metadata" that holds my cascade options.</span><p></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2uoXhpmTKFIJr6Y4plvdV8aT-kxrbCl87xP70lVTViLxEdHQNDKjbPQq5Qqp5iCs0xC1_fMjnMMoBYtfQDTseGYLc-OErjPwZublhR7fAChs0F_qCR9sly0pf7dMrAPjXwKOAr2owlBo/s473/pic11_ChooseList.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="473" data-original-width="342" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2uoXhpmTKFIJr6Y4plvdV8aT-kxrbCl87xP70lVTViLxEdHQNDKjbPQq5Qqp5iCs0xC1_fMjnMMoBYtfQDTseGYLc-OErjPwZublhR7fAChs0F_qCR9sly0pf7dMrAPjXwKOAr2owlBo/s320/pic11_ChooseList.JPG" /></a></div><br /><span style="font-family: arial;">So, that done, we can now begin adding some more fields to get the cascades working. This is how it's done.</span><p></p><p><span style="font-family: arial;">If you can't see the Fields panel, then click on the text link <b>Edit Fields</b> in the right hand panel. (I spent ages looking for this!)</span></p><p></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="font-family: arial; margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAbrPfBIkaVdtteaj9ixKkRovDl5K76KIm4EudfyYGHzB0W9VNxiUl1rgPpsvqQxPdSVrel7FXUI6G4OmOaGU1kSSRX0qx2pVj01IKVEGnJK4MxkS7YC-9NIu0uHQhX3L6mkgIPK7IpPw/s1281/pic13_PowerAppsStage_EditFields.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="339" data-original-width="1281" height="106" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAbrPfBIkaVdtteaj9ixKkRovDl5K76KIm4EudfyYGHzB0W9VNxiUl1rgPpsvqQxPdSVrel7FXUI6G4OmOaGU1kSSRX0qx2pVj01IKVEGnJK4MxkS7YC-9NIu0uHQhX3L6mkgIPK7IpPw/w400-h106/pic13_PowerAppsStage_EditFields.JPG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>This was a tricky little sucker to find, if you're new to Power Apps. If you get lost, just highlight the <b>SharePointForm1</b> heading in the left hand column first, then on the <b>Properties</b> link in the right-hand column.</i><br /></td></tr></tbody></table><br /><span style="font-family: arial;">Once the <b>Fields</b> panel displays, you can click on the <b>Add Fields</b> link to grab more columns from your Doc Library and place them on the EditForm stage.</span><p></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijU5fI5sTqqTUzKY6aLrno1pgXqg4CQQICeaKbctOTKcvETOatqIptEjlOkGoYf9VIxd-nU97GEDEHPfGGt6zJrsOK9NxTpcIMw1TbXIzIB1rl4FKmCfhWsMhLyQNnh37J6Do1uSmgu7U/s1275/pic12_PowerAppsStage_EditFields.JPG" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="306" data-original-width="1275" height="96" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijU5fI5sTqqTUzKY6aLrno1pgXqg4CQQICeaKbctOTKcvETOatqIptEjlOkGoYf9VIxd-nU97GEDEHPfGGt6zJrsOK9NxTpcIMw1TbXIzIB1rl4FKmCfhWsMhLyQNnh37J6Do1uSmgu7U/w400-h96/pic12_PowerAppsStage_EditFields.JPG" width="400" /></span></a></div><span style="font-family: arial;"><br />Once the field is on the stage, you can manipulate it as required. For example, you can access the ellipsis in the Field's panel and select the <b>Move Up</b> action to change the field's position on the stage. I'll be removing the <b>Title</b> field at some point in the process, but for now, I'll just move the "Geography_txt" field up to sit above the Title field.</span><p></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzI3fN7Z8LtzoT_dZ5RNa2pnWS5rlcs2UkJnpN1h7jFkuNU47GTvcXh6EyAppohXFW6UODh5pH_oNC0Ctpm1ezYzinzIeuDIX9eVWd95G8Xf1WhDVjHjMVRcVZAbbR_bJYvHXHbjxQ3Qc/s1284/pic014_MoveFieldUp.jpg" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="438" data-original-width="1284" height="136" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzI3fN7Z8LtzoT_dZ5RNa2pnWS5rlcs2UkJnpN1h7jFkuNU47GTvcXh6EyAppohXFW6UODh5pH_oNC0Ctpm1ezYzinzIeuDIX9eVWd95G8Xf1WhDVjHjMVRcVZAbbR_bJYvHXHbjxQ3Qc/w400-h136/pic014_MoveFieldUp.jpg" width="400" /></span></a></div><span style="font-family: arial;"><br />I'm not going to make you sit through the entire process, but I'll do enough so that you can see how the cascade works. So the first thing to do is to make the text field for <b>Geography_txt</b> a little smaller, as we're going to squeeze another custom "Drop down" input in this "card". To do that, highlight the card by clicking in it, then select <b>Insert</b> tab at the top left of the page. Click on <b>Input</b> and select <b>Drop down</b> from the drop-down menu.</span><p></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_nlweD3xFxelu9W0IKpeG4c7-y5yCUeKCMzVcobJ95AiBNCcm97CaDjHQogizWQhU7KEyrfsgvcA0rL2rPHtKa3jVeDB4rYDhPo5Q4C4fWUvkh1iUKPeKn7ZT06yWBi4tR2IRpcBMGu4/s1284/pic015_InsertDropDown.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="438" data-original-width="1284" height="136" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_nlweD3xFxelu9W0IKpeG4c7-y5yCUeKCMzVcobJ95AiBNCcm97CaDjHQogizWQhU7KEyrfsgvcA0rL2rPHtKa3jVeDB4rYDhPo5Q4C4fWUvkh1iUKPeKn7ZT06yWBi4tR2IRpcBMGu4/w400-h136/pic015_InsertDropDown.jpg" width="400" /></a></div><br /><span style="font-family: arial;">The new Drop down input should appear within your card. If it doesn't, then you didn't have your card selected correctly. Delete the rogue Drop down and try again. A successful insert should look like this.</span><p></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmYb8WbdT70hH_ToHWf9LnmePYVgCcb7glDv2j0rQdSd2rwP64ZvBDf8UIoWMQIGtEQYcKET1NCPlU5mYJC55_S-82nt36LaUDRIKBcRfSjwS_QDSvhqLrb7F73HadWPoOqRI2B-Q2wnM/s714/pic016_InsertDropDown.JPG" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="241" data-original-width="714" height="135" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmYb8WbdT70hH_ToHWf9LnmePYVgCcb7glDv2j0rQdSd2rwP64ZvBDf8UIoWMQIGtEQYcKET1NCPlU5mYJC55_S-82nt36LaUDRIKBcRfSjwS_QDSvhqLrb7F73HadWPoOqRI2B-Q2wnM/w400-h135/pic016_InsertDropDown.JPG" width="400" /></span></a></div><span style="font-family: arial;"><br />You can resize the new Drop down field so it doesn't overlap the existing text box. Before you can make any changes to the new field you first have to unlock the card in the <b>Advanced</b> panel on the right.</span><p></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEii4eVfcasgMvpUK1fRphYzgVDjxbUMtjtHP6Ls9PRkQpO0V0dezIPAKKEjMo0aUb6yShPtQJVUlfjuPVE6gvS9lcuSNzPXSaCaIeJ_XR2iJe8oaCRXCIsxqFT84WMwCAkM-PZLXrjaoVc/s340/pic017_UnlockCard.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="207" data-original-width="340" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEii4eVfcasgMvpUK1fRphYzgVDjxbUMtjtHP6Ls9PRkQpO0V0dezIPAKKEjMo0aUb6yShPtQJVUlfjuPVE6gvS9lcuSNzPXSaCaIeJ_XR2iJe8oaCRXCIsxqFT84WMwCAkM-PZLXrjaoVc/s320/pic017_UnlockCard.JPG" width="320" /></a></div><br /><span style="font-family: arial;">Now you can start making changes. First, rename the label of the card from "Geography_txt" to "Region". Power Apps is picking up the label "Geography_txt" from the list. To change the text, we simply over-write the "Parent.DisplayName" call in the fx field with "Region" (include the quotes).</span><p></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXj3WaZbAx2FKRUR-L8VrO23aD6jVRc7YvA1zilwrtSVMhxAxJ6r6fwJQ2jhDt9of7fmeYpBTLkb5oK9XhZuwfFI_72cRgUTJu4N61YQnenuTG0znj5EVvKUl38xDlRXBWYLWhMnPL_3w/s719/pic019_EditFieldLabel.JPG" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: arial;"><img border="0" data-original-height="160" data-original-width="719" height="89" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXj3WaZbAx2FKRUR-L8VrO23aD6jVRc7YvA1zilwrtSVMhxAxJ6r6fwJQ2jhDt9of7fmeYpBTLkb5oK9XhZuwfFI_72cRgUTJu4N61YQnenuTG0znj5EVvKUl38xDlRXBWYLWhMnPL_3w/w400-h89/pic019_EditFieldLabel.JPG" width="400" /></span></a></div><span style="font-family: arial;"><br />Next - and this is where it starts to get a bit more complex, we're going to change the underlying programming of the card so that the custom Drop down picks up data from the custom list "Metadata" and sends it to the "Geography_txt" text field.</span><p></p><p><span style="font-family: arial;">Highlight the custom drop-down field by clicking on it. Click on the <b>Advanced</b> tab. Add this code into the <b>Items</b> window:</span></p><p><span style="font-family: courier;">Distinct(metadata,Geography)</span></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZ9H3OHlH8MmM-feCPto3NlLmyTAwDPqt9pgfPesGskr-f7jLXqnf1AtI50UTm7Xt6wfXRhUwDZyR56pxwKTJMiav-uBteZgp3G06lUkh3hOX7jkd7Ut9S7M-lcqWI_zz8ppWrQugSTjI/s1285/pic20_EditItems.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="600" data-original-width="1285" height="186" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZ9H3OHlH8MmM-feCPto3NlLmyTAwDPqt9pgfPesGskr-f7jLXqnf1AtI50UTm7Xt6wfXRhUwDZyR56pxwKTJMiav-uBteZgp3G06lUkh3hOX7jkd7Ut9S7M-lcqWI_zz8ppWrQugSTjI/w400-h186/pic20_EditItems.JPG" width="400" /></a></div><br /><span style="font-family: arial;">Now add this code to the <b>Default</b> window:</span><p></p><p><span style="font-family: courier;">ThisItem.Geography_txt</span></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgc4Ktr_BC179sQYwX1AvojwbnlW9eNKYYFxC2d2Nnb3k7b6RhAo8i_rfDFI619QJIgXA5Ry4z2Q0o9-px_QTd4msgV9WYoEPVl84H8016Ee2Q6KrYXYLDuIgu530bKYf9T6miy3wkW8jY/s1258/pic21_EditDefault.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="666" data-original-width="1258" height="211" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgc4Ktr_BC179sQYwX1AvojwbnlW9eNKYYFxC2d2Nnb3k7b6RhAo8i_rfDFI619QJIgXA5Ry4z2Q0o9-px_QTd4msgV9WYoEPVl84H8016Ee2Q6KrYXYLDuIgu530bKYf9T6miy3wkW8jY/w400-h211/pic21_EditDefault.jpg" width="400" /></a></div><br /><span style="font-family: arial;">Finally, to complete the sequence, you need to click the entire card to highlight it and then add this code:</span><div><br /></div><div><span style="font-family: courier;">Dropdown2.SelectedText.Result</span><p></p><p><span style="font-family: arial;"></span></p></div><div><span style="font-family: arial;">... to the <b>Update</b> field in the <b>Advanced</b> section (you may have to click the <b>More options</b> button to see the <b>Update</b> field):</span><p></p><p></p><div class="separator" style="clear: both; font-family: arial; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibjbrg_CdcLALsf2G9TRNxx-IUg4uDhRDgjzWApKxyn9wo6YjPRNpgs0GQrwO7PrCcyehEkKXOz6egCwSsQa1VcmT19dA8-UjsZo6WmNJq3XEIflIgO2zcnJg4xe5k3tbyS61GfZ4xxMA/s308/pic22_MoreOptions.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="175" data-original-width="308" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibjbrg_CdcLALsf2G9TRNxx-IUg4uDhRDgjzWApKxyn9wo6YjPRNpgs0GQrwO7PrCcyehEkKXOz6egCwSsQa1VcmT19dA8-UjsZo6WmNJq3XEIflIgO2zcnJg4xe5k3tbyS61GfZ4xxMA/s0/pic22_MoreOptions.JPG" /></a></div><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEim7H6tV3zmurRJSBTsvJHGELtfXkrf65FFp7HhLW6BGtWXROJp8K6ZgTOuvDZXLUDQlVRHZnrj6pJPVenv-j5S7BXyEnIsXGBR4QW8boCKikEN2vQv9ngrs3LEfFdS9F7tdxcFeQHyfGY/s1258/pic23_Update.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="586" data-original-width="1258" height="186" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEim7H6tV3zmurRJSBTsvJHGELtfXkrf65FFp7HhLW6BGtWXROJp8K6ZgTOuvDZXLUDQlVRHZnrj6pJPVenv-j5S7BXyEnIsXGBR4QW8boCKikEN2vQv9ngrs3LEfFdS9F7tdxcFeQHyfGY/w400-h186/pic23_Update.jpg" width="400" /></a></div><br /><span style="font-family: arial;">I'll leave it entirely up to you whether you rename the field "Dropdown2" to something a bit more friendly and descriptive. I didn't do that when I built my original application, but in hindsight, I probably should have. For this example, I'm renaming the field to "ddGeog". Even if I do it at this stage, Power Apps automatically updates the above formula to "</span><span style="font-family: courier;">ddGeog.SelectedText.Result</span><span style="font-family: arial;">".</span><p></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgclbnkRKFxckrSdrKzpvpTODE9caxX5HPsJ48yzM0nXEFXp8ho_trzZyEyoA_5kyNAvAKXNCRuuGtDBQPy8oNC94-A2guYRZjIcw3kkh6wcD6eNZhfsvVqUnzkSEZkZsCP5Yb2w1-qCFg/s434/pic24_RenameField.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="334" data-original-width="434" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgclbnkRKFxckrSdrKzpvpTODE9caxX5HPsJ48yzM0nXEFXp8ho_trzZyEyoA_5kyNAvAKXNCRuuGtDBQPy8oNC94-A2guYRZjIcw3kkh6wcD6eNZhfsvVqUnzkSEZkZsCP5Yb2w1-qCFg/s320/pic24_RenameField.jpg" width="320" /></a></div><br /><span style="font-family: arial;">Next, we have to add the dependent drop-down, "Department". So, same method as before. Click on the <b>Add Fields</b> link, and select "Dept_txt".</span><p></p><p><span style="font-family: arial;">Highlight the card by clicking in it, then select <b>Insert</b> tab at the top left of the page. Click on <b>Input</b> and select <b>Drop down</b> from the drop-down menu. Highlight the custom drop-down field by clicking on it. Click on the <b>Advanced</b> tab. Add this code into the <b>Items</b> window:</span></p><p><span style="font-family: courier;">Distinct(Filter(metadata,Geography =ddGeog.Selected.Result),Dept)</span></p><p><span style="font-family: arial;">And add this code to the <b>Update</b> window:</span></p><p><span style="font-family: courier;">ddDept.SelectedText.Value</span></p><p><span style="font-family: arial;">I found as I went through adding these formulae that the <b>Default</b> field usually seems to default to the appropriate formula. In this case it would be </span><span style="font-family: courier;">"ThisItem.Dept_txt"</span><span style="font-family: arial;">. But if it doesn't, you'll have to add it manually</span></p><p><span style="font-family: arial;">At this point, it'd be a good idea to test the form and make sure your cascade is working as expected.</span></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZloWIM7JEzqaBVP_S0YYs1eBjHN8vtPA_4YTnmsxQgciDx2j8GoxDvJjYoFc28C6NYpwF-ogC36Fyw1-6XWb-1pwgJxmBlZxdlug8ZMPG3noZu-kf2VHhiTN71Y0vMAI5602w8qoGzlg/s1826/pic25_TestForm.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="724" data-original-width="1826" height="159" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZloWIM7JEzqaBVP_S0YYs1eBjHN8vtPA_4YTnmsxQgciDx2j8GoxDvJjYoFc28C6NYpwF-ogC36Fyw1-6XWb-1pwgJxmBlZxdlug8ZMPG3noZu-kf2VHhiTN71Y0vMAI5602w8qoGzlg/w400-h159/pic25_TestForm.jpg" width="400" /></a></div><br /><span style="font-family: arial;">Right, final cascading drop-down for this form. But before we do, let's just hide that <b>Title</b> field, as it's getting in the way:</span><p></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWYle-6snTxbl1GK7gWw_JH0JhunUNy_cNgQHJX-5MslMJsHo9TwDO4lyJbMO6kr8yU8RrvWtdXOZU8px4IE0C22PYHqIXrVks41dI3_XcgOMcGytzDBtFUDzDuJ87cxETnSNjkKZ4REE/s1175/pic26_HideField.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="464" data-original-width="1175" height="158" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWYle-6snTxbl1GK7gWw_JH0JhunUNy_cNgQHJX-5MslMJsHo9TwDO4lyJbMO6kr8yU8RrvWtdXOZU8px4IE0C22PYHqIXrVks41dI3_XcgOMcGytzDBtFUDzDuJ87cxETnSNjkKZ4REE/w400-h158/pic26_HideField.jpg" width="400" /></a></div><br /><p><span style="font-family: arial;">Now add the final cascading drop down in the same way. I've called my "LOB" (Line of Business), and changed the name of the field to ddLOB. Use these formulae to bind the drop-down to the main library:</span></p><p><span style="font-family: arial;"><b>Items</b>: </span><span style="font-family: courier;">Distinct(Filter(metadata,Dept =ddDept.Selected.Result),Title)</span></p><p><span style="font-family: arial;"><b>Default</b>: </span><span style="font-family: courier;">ThisItem.LOB_txt</span><span style="font-family: arial;"> (usually filled in by default)</span></p><p><span style="font-family: arial;"><b>Update</b>: </span><span style="font-family: courier;">ddLOB.Selected.Result</span></p><p><span style="font-family: arial;">So that's the cascade sorted out. What I did was add another field - which I'll make invisible - to automatically select the Manager responsible for approving each request according to the Line of Business they are responsible for. This is neat, because it prevents users making mistakes and sending Approval requests to the wrong manager.</span></p><p><span style="font-family: arial;">So we add another field, for "Approver" and add the following formulae:</span></p><p><span style="font-family: arial;"><b>Items</b>: </span><span style="font-family: courier;">Distinct(Filter(metadata,Title =ddLOB.Selected.Result),Approver.Email)</span></p><p><span style="font-family: arial;"><b>Default</b>: </span><span style="font-family: courier;">ThisItem.Approver_txt</span></p><p><span style="font-family: arial;"><b>Update</b>: </span><span style="font-family: courier;">ddApprover.Selected.Result</span></p><p><span style="font-family: arial;">It's a little trickier if you have a choice of two or more approvers, but I didn't have that requirement and won't be covering it here.</span></p><p><span style="font-family: arial;">Test and make sure it works. You could hide this field now, but I would leave it visible so you know it's working. Plenty of time to hide it at the end of the build.</span></p><p><span style="font-family: arial;">It'd probably be a good idea to <b>Save</b> at this point.</span></p><p><span style="font-family: arial;">The rest of the fields are pretty straight forward to add, and will work fine out-of-the-box. These are:</span></p><p></p><ul style="text-align: left;"><li><span style="font-family: arial;">DocType (renamed as "Brochure" in the form)</span></li><li><span style="font-family: arial;">Client</span></li><li><span style="font-family: arial;">Due Date</span></li><li><span style="font-family: arial;">Revenue</span></li></ul><p></p><p><span style="font-family: arial;">One useful tip I have is to add a currency sign to the Revenue field. Simply change the <b>Hint Text</b>.</span></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHEL1SyC9Wm2wTYvRnMQ5L6JePA91dB3-YT5gfX6pdIrRFWnWLt43Zz8L3FpmXyqzC6WhbqzEGcEflNqC8OfBxgXES2_-KGQgjKx2ZhOZZS3X6G-PyToSlWMLuYNTVcJnHaAsBHQiOHyU/s819/pic28_HintText.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="172" data-original-width="819" height="84" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHEL1SyC9Wm2wTYvRnMQ5L6JePA91dB3-YT5gfX6pdIrRFWnWLt43Zz8L3FpmXyqzC6WhbqzEGcEflNqC8OfBxgXES2_-KGQgjKx2ZhOZZS3X6G-PyToSlWMLuYNTVcJnHaAsBHQiOHyU/w400-h84/pic28_HintText.jpg" width="400" /></a></div><br />OK ... so we're all done on the Input Form. Time to <b>Publish</b> the form and test it in the Library.<p></p><p><span style="font-family: arial;">Ready for the next bit? Well, you'll have to wait a few days for that. Pop back soon and find out how to:</span></p><p></p><ul style="text-align: left;"><li><span style="font-family: arial;">create the Word Template</span></li><li><span style="font-family: arial;">attach it to the Content Type</span></li><li><span style="font-family: arial;">then insert the Quick Parts that will hold the data or text from the Library columns</span></li><li><span style="font-family: arial;">... and lots more.</span></li></ul><p></p><p><span style="font-family: arial;"><br /></span></p><p><span style="font-family: arial;"><b>Next: Word shenanigans and building the Approval Flow in Power Automate</b></span></p></div></div>AirPiratePresshttp://www.blogger.com/profile/13136561512898563240noreply@blogger.com0tag:blogger.com,1999:blog-3023476837266527744.post-3796854856532922052020-02-18T10:15:00.005-08:002021-04-17T00:49:39.021-07:00How to append comments to a multi-line text column in a document library<span face=""arial" , "helvetica" , sans-serif">I recently needed to create a Document Library in SharePoint Online with a text field that could append blocks of text against each document to track progress of several workflows. Of course, the first task is to check Google to see whether there was a workaround for not being able to select an "Append" option on the Multiple lines of text field in a Document Library. After about an hour of trying different search terms I had to conclude that there wasn't an easy, out-of-the-box way of doing this. But there's always a workaround, right?</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<span face=""arial" , "helvetica" , sans-serif">The secret lies in workflow variables.</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<span face=""arial" , "helvetica" , sans-serif">But first, create a Multiple lines of text field. I called mine "Actions Log", because I'm logging the workflow actions. Then you'll need to use either an existing workflow or - if append text is the only action you need to take - create a new workflow.</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<span face=""arial" , "helvetica" , sans-serif">Within the workflow, you're going to need two variables. One to hold any existing text in your Multiple lines of text field and one to hold a copy of the original text plus any appended text.</span><br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhj6xLu-bZZ7i-bAsVPRazzcnzn-o3joXe-diNVV_YsXM7Qigmk5s2L5H473nuJc2BXN-4pG6uBY-vy5r0jYfSe9H451YnVrdggUtxwRwyZfw4ILzeZznFaqQ-OvJp99VLNnvM47uHvcl4/s1600/pic01_Set-Variable.jpg" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="485" data-original-width="662" height="292" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhj6xLu-bZZ7i-bAsVPRazzcnzn-o3joXe-diNVV_YsXM7Qigmk5s2L5H473nuJc2BXN-4pG6uBY-vy5r0jYfSe9H451YnVrdggUtxwRwyZfw4ILzeZznFaqQ-OvJp99VLNnvM47uHvcl4/s400/pic01_Set-Variable.jpg" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span face=""arial" , "helvetica" , sans-serif"><i>To create a Workflow variable, you need to first select "Set Workflow Variable" from the Actions drop-down.</i></span></td></tr>
</tbody></table>
<span face=""arial" , "helvetica" , sans-serif">So create your first workflow variable ... I've put some conditions in my workflow, but of course you don't have to. Click on the Action drop-down and find <b>Set Workflow Variable</b>. If you can't see that option, start typing the text "set workflow variable" and it should appear.</span><br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhivcQp0N_TokJqLG9PEMx4UDDSyo8BKjBLN9_Pt7wWo7LpfGW7F2SOWdq69f2JelizLXwago6unDPg-vo3abRluNRbu0BZyXeSuNiFvuxiuhlU_KLvyxjTGeZ3qRXKrseSjSoDDBNoP3Q/s1600/pic02_Create-Variable.jpg" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="322" data-original-width="616" height="208" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhivcQp0N_TokJqLG9PEMx4UDDSyo8BKjBLN9_Pt7wWo7LpfGW7F2SOWdq69f2JelizLXwago6unDPg-vo3abRluNRbu0BZyXeSuNiFvuxiuhlU_KLvyxjTGeZ3qRXKrseSjSoDDBNoP3Q/s400/pic02_Create-Variable.jpg" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span face=""arial" , "helvetica" , sans-serif"><i>Having selected "Set Workflow Variable" you're now prompted to create a new variable.</i></span></td></tr>
</tbody></table>
<span face=""arial" , "helvetica" , sans-serif">I'm calling my new Variable "ActionLog" (dropping the "s" so I can easily distinguish between the two), and I'm setting (content) Type to "String".</span><br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUqCxHQT1nO7GkciYj1tUzUOL-sntU5iBNby8m3DYgA9zn7dfNtgOYJHjLMI7Km2OJ5oOkEvm26hLyc8w5YynFj-8iTE0IW9kCDnaBCb5WygIhhaM3YwqrU303S_bjDf3uY-3Qja_RC1s/s1600/pic03_Name-Variable.jpg" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="322" data-original-width="616" height="208" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUqCxHQT1nO7GkciYj1tUzUOL-sntU5iBNby8m3DYgA9zn7dfNtgOYJHjLMI7Km2OJ5oOkEvm26hLyc8w5YynFj-8iTE0IW9kCDnaBCb5WygIhhaM3YwqrU303S_bjDf3uY-3Qja_RC1s/s400/pic03_Name-Variable.jpg" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span face=""arial" , "helvetica" , sans-serif"><i>Naming the new variable and setting the content type are both done in the same dialogue box.</i></span></td></tr>
</tbody></table>
<span face=""arial" , "helvetica" , sans-serif">Next, set the Variable to hold the contents of the ActionsLog field. This will copy the existing text - if any - in the <b>ActionsLog</b> field to the <b>ActionLog</b> variable.</span><br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOx2tpq6GPjIjmN6hPt-jhyIq1EA-Buj2PAdIKFXOXIcO8OpT8ABsQfRO89KbCRqFWjX_lSSPftJ5yIeO5zKKpxaR-SgOLlIZw2xetonpiHa_W-u7o_GorFLDccxLjvIvGLXXX6LqPfPs/s1600/pic04_Set-Variable.jpg" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="322" data-original-width="616" height="208" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOx2tpq6GPjIjmN6hPt-jhyIq1EA-Buj2PAdIKFXOXIcO8OpT8ABsQfRO89KbCRqFWjX_lSSPftJ5yIeO5zKKpxaR-SgOLlIZw2xetonpiHa_W-u7o_GorFLDccxLjvIvGLXXX6LqPfPs/s400/pic04_Set-Variable.jpg" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span face=""arial" , "helvetica" , sans-serif"><i>This step causes the value in the <b>Action Log</b> text column to be copied into the <b>ActionsLog</b> variable.</i></span></td></tr>
</tbody></table>
<span face=""arial" , "helvetica" , sans-serif">Now you're ready to create your second variable. I called this one </span><b style="font-family: arial, helvetica, sans-serif;">ActionsLogAppend</b><span face=""arial" , "helvetica" , sans-serif">, also set as a string. So just repeat the above steps ...</span><br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi09Luv13O4R41P72TNt-USd0naR96Nt8WoLg7IDZU3FN7o1o0JFgggTdxm1iQ92_ap88i3EGa9kHK1n6agOZH1SUAuofm7tEdt9d65hpxJ6AzrXKd4rpVGMh9w1zAEPXdavAk9pueiNeo/s1600/pic05_Set-Another-Variable.jpg" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="348" data-original-width="616" height="225" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi09Luv13O4R41P72TNt-USd0naR96Nt8WoLg7IDZU3FN7o1o0JFgggTdxm1iQ92_ap88i3EGa9kHK1n6agOZH1SUAuofm7tEdt9d65hpxJ6AzrXKd4rpVGMh9w1zAEPXdavAk9pueiNeo/s400/pic05_Set-Another-Variable.jpg" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span face=""arial" , "helvetica" , sans-serif"><i>Create a second variable called <b>ActionsLogAppend</b> which will hold the original <b>Action Log</b> text and any new appended text. </i></span></td></tr>
</tbody></table>
<span face=""arial" , "helvetica" , sans-serif">Now you're ready to build the actual machinery of the Append Text function. In the example here, I'm having the Workflow append predetermined text into the existing Multiple Lines of Text field. And I do that by opening up the Parameter Builder to create a value for the second variable.</span><br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8XyXtofwbsyozPuonbmB7-9RpZCPk99tw2ArQdeuFxnbN-nYwZA6KFb3mVYeux0KSEZEv_YC7oHAzKIVQa9fE9luIty5RiL3FBl2DDQaVIV9FpOUBv06-YAJ2ZMBlFmjxXNZVTGLSq28/s1600/pic06_Select-Variable-Builder.jpg" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="360" data-original-width="616" height="233" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8XyXtofwbsyozPuonbmB7-9RpZCPk99tw2ArQdeuFxnbN-nYwZA6KFb3mVYeux0KSEZEv_YC7oHAzKIVQa9fE9luIty5RiL3FBl2DDQaVIV9FpOUBv06-YAJ2ZMBlFmjxXNZVTGLSq28/s400/pic06_Select-Variable-Builder.jpg" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span face=""arial" , "helvetica" , sans-serif"><i>Click on the ellipsis to launch the String Builder window, which in turn creates the <b>ActionLogAppend</b> value.</i></span></td></tr>
</tbody></table>
<span face=""arial" , "helvetica" , sans-serif">Building the value for the variable is pretty simple. I wanted my appended text to look like this:</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">20/11/2019: 10.55 - 18 months to End of Lease acknowledged by John Smith:</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">[Content of first variable]</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">So in the String-Builder, add a lookup for the Date (and the Time, if you want it), and add the identity of the person who carried out the action (that'll be the value for ModifiedBy).</span><br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_80fFi_TxIcgaaVtFZFFenkHGB56-L5WwzudsvQbOawGNWOeqbstzWuQ5tSbARFDnuiG1ujLXNTWEIzFFY9zCe7KaprCvfSPxxjPD-NAV_T2sd8kBWo9BzJggXwSG3vLB3HgDk4cHLDE/s1600/pic07_Build-Variable.jpg" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="434" data-original-width="616" height="281" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_80fFi_TxIcgaaVtFZFFenkHGB56-L5WwzudsvQbOawGNWOeqbstzWuQ5tSbARFDnuiG1ujLXNTWEIzFFY9zCe7KaprCvfSPxxjPD-NAV_T2sd8kBWo9BzJggXwSG3vLB3HgDk4cHLDE/s400/pic07_Build-Variable.jpg" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span face=""arial" , "helvetica" , sans-serif"><i>I set the <b>Date</b> and <b>Time</b> to "Short Date" and "Short Time" content types, but you may prefer a different setting.</i></span></td></tr>
</tbody></table>
<span face=""arial" , "helvetica" , sans-serif">Then I just copied the combined text of the two variables into the Actions Log variable of the Workflow.</span><br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGY5Wx-kQgGcqxzpfu5jbmm4AWvdvKN0m4l0jopD60JKIbOTe8AehB8qiMW6LBNeR9WhtjlHdra8nghHBXjoi9uphnRa5FwTIZBkqv4qNN4jLQNT6rGFBmT25WP9Idj-AKVY3utQnpTj8/s1600/pic08_Variable-Built.jpg" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="434" data-original-width="616" height="281" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGY5Wx-kQgGcqxzpfu5jbmm4AWvdvKN0m4l0jopD60JKIbOTe8AehB8qiMW6LBNeR9WhtjlHdra8nghHBXjoi9uphnRa5FwTIZBkqv4qNN4jLQNT6rGFBmT25WP9Idj-AKVY3utQnpTj8/s400/pic08_Variable-Built.jpg" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span face=""arial" , "helvetica" , sans-serif"><i>This is what the string looks like in the String Builder window. I put a line return after the <b>ModifiedBy</b> call for clarity, putting the appended text on a new line ...</i></span></td></tr>
</tbody></table>
<span face=""arial" , "helvetica" , sans-serif">The final String in the String-Builder would look like this - </span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">[ModifiedDate]: [ModifiedTime] - 18 months to End of Lease acknowledged by [ModifiedBy]:</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">[Variable:ActionLog]</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<span face=""arial" , "helvetica" , sans-serif"></span>
<span face=""arial" , "helvetica" , sans-serif">But if you wanted to, you could copy this combined text back into the Multiple Lines of Text field via the workflow.</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><h3 style="text-align: left;"><span face=""arial" , "helvetica" , sans-serif">POWER AUTOMATE AND SHAREPOINT ONLINE</span></h3><div>Of course, old-school workflows don't last forever - Microsoft has probably turned off 2010 WorkFlows by the time you read this. You could just use a 2013 WorkFlow without too much hassle ... but it's better to switch to Power Automate and use a Flow - it's a steep learning curve, but not if you're already familiar with WorkFlows.</div><div><br /></div><div>Using a Flow to append text in a document library is, if anything, even easier than messing with SharePoint Designer variables.</div><div><br /></div><div>In the Flow that you have set up to manage changes to your library metadata, insert an <b>Update File Properties</b> action (if there's not one in there already), then find the Multiple Line Text field and add this to it:</div><div><br /></div><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCYEIlE05gfvSY5DAqE2k6AqKXEIWvjqTEUP91CeSvyVkHselwhoV4Xa7xAEd3adb0cEvhlAlv64QUf8cuhISsPvcTD7ZMSoGoE049KeGm0rOq_6ygj3KIYMpeSxPkdkLCsopcu4bxTQs/s595/ActionLogUpdate.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="147" data-original-width="595" height="99" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCYEIlE05gfvSY5DAqE2k6AqKXEIWvjqTEUP91CeSvyVkHselwhoV4Xa7xAEd3adb0cEvhlAlv64QUf8cuhISsPvcTD7ZMSoGoE049KeGm0rOq_6ygj3KIYMpeSxPkdkLCsopcu4bxTQs/w400-h99/ActionLogUpdate.JPG" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>The method is remarkably similar to how we achieved the WorkFlow version above, with a couple of small differences.</i></td></tr></tbody></table><div>The "formatDateTime" expression captures the date when this latest update was made. I used this bit of code (in an Expression) to grab the date that the "Start and Wait for Approval" action earlier in the Flow was completed ... then formatted it to omit the time, which wasn't so important. Like this:<br /><br /></div><span style="font-family: courier;">formatDateTime(outputs('Start_and_wait_for_an_approval_-_End_Date_18')?['body/completionDate'], 'dd/MM/yyyy')</span><div><div><span face=""arial" , "helvetica" , sans-serif"><br /></span></div><div><span face=""arial" , "helvetica" , sans-serif">Then a bit of explanatory text, then the name of the person who made the Approval ("Responder Display Name") ... then a semicolon as a separator from earlier Log Actions.</span></div><div><span face=""arial" , "helvetica" , sans-serif"><br /></span></div><div><span face=""arial" , "helvetica" , sans-serif">To put the earlier Log Actions on a separate line, I added a Shift-Return, then just inserted a Dynamic Content call for the previous value in the <b>ActionsLog</b> field from the <b>Get Files (properties only)</b> call at the top of the Flow.</span></div><div><span face=""arial" , "helvetica" , sans-serif"><br /></span></div><div><span face=""arial" , "helvetica" , sans-serif">Pretty, simple, right?</span></div><div><span face=""arial" , "helvetica" , sans-serif"><br /></span></div><div><span face=""arial" , "helvetica" , sans-serif">That's it ... I hope this helps someone.</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div></div>AirPiratePresshttp://www.blogger.com/profile/13136561512898563240noreply@blogger.com0tag:blogger.com,1999:blog-3023476837266527744.post-4694145353261091922019-08-06T03:15:00.007-07:002022-06-04T02:00:43.657-07:00Can’t use Calculated Column to generate a URL?<span face=""arial" , "helvetica" , sans-serif"><b>ANYBODY WHO HAS WORKED WITH SHAREPOINT ONLINE</b> will know that Microsoft love to turn off functions we rely on. A recent casualty was the facility to use List Calculated Columns to concatenate a URL to a customised Display or Edit Form.</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhl1hI9EZvpohRew0H5oBJglo0P0T8CAc78AnB3ajYlrG_HGapn7nTipGPt3WYbUSVYYcTAs_FTV5DEHM1SmgDO_Vl1aGYTQPtZdtihNnq3GksmvnVMyWP8OUtNwk7cZm9frEs5dkQDgWU/s1600/pic01_Calculated+column.JPG" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="437" data-original-width="587" height="238" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhl1hI9EZvpohRew0H5oBJglo0P0T8CAc78AnB3ajYlrG_HGapn7nTipGPt3WYbUSVYYcTAs_FTV5DEHM1SmgDO_Vl1aGYTQPtZdtihNnq3GksmvnVMyWP8OUtNwk7cZm9frEs5dkQDgWU/s320/pic01_Calculated+column.JPG" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span face=""arial" , "helvetica" , sans-serif"><i>Oh, how I love to concatenate. And how sad I was when Microsoft decided <br />they didn't like me concatenating links.</i></span></td></tr>
</tbody></table>
<span face=""arial" , "helvetica" , sans-serif">How we would have done it in the past would be to create a Calculated column in a list, then add a formula like this:</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">=CONCATENATE("<A HREF='/sites/SiteName/Lists/ListName/DispForm00.aspx?ID=",[ID]'>Display Form</A>")</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<span face=""arial" , "helvetica" , sans-serif">Or if you wanted to be really smart, you could include a redirect to take your user to a particular destination after they’d finished with the form, like this:</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">=CONCATENATE("<A HREF='/sites/SiteName/Lists/ListName/DispForm00.aspx?ID=",[ID],"&Source=https://xxx.sharepoint.com/sites/SiteName/Lists/ListName/'>Display Form</A>")</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<span face=""arial" , "helvetica" , sans-serif">The problem is that Microsoft have now disabled that functionality, so that while the Calculated column will compile the link, the list will display the HTML line of code, and not a link as you intended.</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<span face=""arial" , "helvetica" , sans-serif">I went trawling around Google, looking for a workaround for this “undocumented feature” and came up empty. There’s quite a few folks who suggest many different JavaScript and JQuery solutions, but I couldn’t get any of them to work. JavaScript is okay and can solve some of your problems in SharePoint, but I can’t help feeling it’s a bit of a hack. Far better to use in-built SharePoint technology to solve SharePoint problems where possible.</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<span face=""arial" , "helvetica" , sans-serif">So I resolved to come up with a workable solution myself, something simpler than fiddling around with a JavaScript function that would magically transform a string of HTML into a working link.</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<span face=""arial" , "helvetica" , sans-serif">Everything was pointing to a workflow. (You can also use a Flow, which I've documented at the foot of this posting.)</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<span face=""arial" , "helvetica" , sans-serif">I set one up to copy the calculated HTML code into a simple text column, but of course that didn’t work.</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<span face=""arial" , "helvetica" , sans-serif">My next attempt was to copy the concatenated string into a Hyperlink column. That kind of did work, but displayed both the link URL and the link text as the full line of HTML … and it <i>seemed</i> to be clickable, but it didn't quite work as I thought it would.</span><br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgRxqfLaVDVfj6jw0-P-Wn3aLcM-lX49p8gl5Z4al6o8Dw3_Vj5iXVzEh8DdGvI5zB8ygjx46glYasYQhMKpBi2bDmQ7-J-kMdzsN6xMLBssB88SrqDQhz-kTbNa1sUmLzw66DLdiy2kA/s1600/pic02_Hyperlink-column_01.jpg" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="101" data-original-width="548" height="58" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgRxqfLaVDVfj6jw0-P-Wn3aLcM-lX49p8gl5Z4al6o8Dw3_Vj5iXVzEh8DdGvI5zB8ygjx46glYasYQhMKpBi2bDmQ7-J-kMdzsN6xMLBssB88SrqDQhz-kTbNa1sUmLzw66DLdiy2kA/s320/pic02_Hyperlink-column_01.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span face=""arial" , "helvetica" , sans-serif"><i>Even though it appeared to produce a functioning link, the "gotcha" <br />was that the call to the item's ID didn't work, so I had a rethink.</i></span></td></tr>
</tbody></table>
<span face=""arial" , "helvetica" , sans-serif">But that roadblock led me to a simpler, more elegant solution anyway ... use a Workflow Variable to compile and copy the URL string into a Hyperlink column.</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<span face=""arial" , "helvetica" , sans-serif">From there, it was a straightforward task to fire up SharePoint Designer and add a simple workflow to copy the contents of a Variable to your Hyperlink Column.</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<span face=""arial" , "helvetica" , sans-serif">In your new Workflow - I used a 2010 Workflow - under <b>Actions</b>, select "Set Workflow Variable".</span><br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieBhLAVTKa1nllqHpmhasHTj-Py5fasfb7YcFZ1ONMkulV0CIb98zhKdsYAFAjRt71dQcQDXNvoijGkRkMGIRQTEVqO5QPHyeZl1Tc74eXKyn8ePOaiCYpCBJAg3vubu2Rr0xDMWfgJKg/s1600/pic01_SetVariable.jpeg" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="315" data-original-width="328" height="307" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieBhLAVTKa1nllqHpmhasHTj-Py5fasfb7YcFZ1ONMkulV0CIb98zhKdsYAFAjRt71dQcQDXNvoijGkRkMGIRQTEVqO5QPHyeZl1Tc74eXKyn8ePOaiCYpCBJAg3vubu2Rr0xDMWfgJKg/s320/pic01_SetVariable.jpeg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span face=""arial" , "helvetica" , sans-serif"><i>Add your first action ...</i></span></td></tr>
</tbody></table>
<span face=""arial" , "helvetica" , sans-serif">In the following window, click on Workflow variable and select 'Create a new variable". Give a useful name and select "String" for the <b>Type</b>. The click on Value, and select the ellipsis to open the String Builder.</span><br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLRuzp8K-WZ29cN4NuIdplnklABqLdHJoSsZbdX0KyD9Q1g5BxqiPjYG_FIWSXW6nsymwnC-k4x7H4WQGru9QhnfUNxi9CCHAZhdn_Bsqz1UYcmThbsYkLqKSXY7SeXD9HPklJBPWfWkM/s1600/pic04_SetVariable.jpeg" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="419" data-original-width="494" height="271" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLRuzp8K-WZ29cN4NuIdplnklABqLdHJoSsZbdX0KyD9Q1g5BxqiPjYG_FIWSXW6nsymwnC-k4x7H4WQGru9QhnfUNxi9CCHAZhdn_Bsqz1UYcmThbsYkLqKSXY7SeXD9HPklJBPWfWkM/s320/pic04_SetVariable.jpeg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span face=""arial" , "helvetica" , sans-serif"><i>Make sure you set up the URL string in a format <br />that the Hyperlink column will accept.</i></span></td></tr>
</tbody></table>
<span face=""arial" , "helvetica" , sans-serif">The string should be in this format:</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">https://xxx.sharepoint.com /sites/SiteName/Lists/ListName/DispForm00.aspx?ID=[ID]&Source=https://xxx.sharepoint.com/sites/SiteName/Lists/ListName/, Display Form</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<span face=""arial" , "helvetica" , sans-serif">Replace the "[ID]" in the above string with the "Current Item:ID" value from the <b>Add or Change Lookup</b> function.</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<span face=""arial" , "helvetica" , sans-serif">The comma and the word space after the URL (but before the link text) is vital to ensure the string transfers to the Hyperlink field correctly.</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<span face=""arial" , "helvetica" , sans-serif">I also set up my Workflow to check whether the Hyperlink Column was populated then, if not, copy the contents of the Variable into the Hyperlink Column, like this:</span><br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEit-GKEKpUrgT7JJ-lWBnWQUldk6ThkXFzvz-7x7KB4WspnveaPivJFkJ9wmtbLpXxqy0JYDV_rKZeIYV1vUB-ndsLQTobQhJLQmgf9G_yj32JJ7nJfTnKI71QV2iCE2BHbE7MJajrzmUI/s1600/pic03b_Workflow.jpg" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="185" data-original-width="607" height="97" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEit-GKEKpUrgT7JJ-lWBnWQUldk6ThkXFzvz-7x7KB4WspnveaPivJFkJ9wmtbLpXxqy0JYDV_rKZeIYV1vUB-ndsLQTobQhJLQmgf9G_yj32JJ7nJfTnKI71QV2iCE2BHbE7MJajrzmUI/s320/pic03b_Workflow.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span face=""arial" , "helvetica" , sans-serif"><i>Having the Condition place to check whether the Hyperlink column is populated or not <br />saves triggering the whole workflow process unnecessarily.</i></span></td></tr>
</tbody></table>
<span face=""arial" , "helvetica" , sans-serif">Then set the Workflow to trigger when a new item is created and that should be it.</span><br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkFuHx9MVygIrCXFeDkyztQ9rvO4G0gEXkHBpzvYJsU5j0sp-XfDtxVGRWJE90P1Fvzh5n2x8TQct9NYHDDHA9n1W3U4E1ubP481RIgmxrjcFv8CT7zkih8hTD-Eks5c_o0JcKXiyW66I/s1600/pic02_Hyperlink-column_02.jpg" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="101" data-original-width="548" height="58" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkFuHx9MVygIrCXFeDkyztQ9rvO4G0gEXkHBpzvYJsU5j0sp-XfDtxVGRWJE90P1Fvzh5n2x8TQct9NYHDDHA9n1W3U4E1ubP481RIgmxrjcFv8CT7zkih8hTD-Eks5c_o0JcKXiyW66I/s320/pic02_Hyperlink-column_02.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span face=""arial" , "helvetica" , sans-serif"><i>This is how you want your Hyperlink column to look after the Workflow has done its job.</i></span></td></tr>
</tbody></table>
<span face=""arial" , "helvetica" , sans-serif"><br /></span><h3 style="text-align: left;"><span face=""arial" , "helvetica" , sans-serif">USING POWER AUTOMATE WITH SHAREPOINT ONLINE</span></h3><div><span face=""arial" , "helvetica" , sans-serif">So, someone asked in the comments if I'd gotten this to work with Flow ... and I can now reply, "Yes, I have."</span></div><div><span face=""arial" , "helvetica" , sans-serif"><br /></span></div><div><span face=""arial" , "helvetica" , sans-serif">I've had so much work converting all my existing 2010 WorkFlows to Flow that I haven't had any time to do bits of research explicitly for The SharePoint Hive, but I've just had to wait until one of my remediations called for me to do a Flow version of a WorkFlow action before posting the solution here.</span></div><div><span face=""arial" , "helvetica" , sans-serif"><br /></span></div><div><span face=""arial" , "helvetica" , sans-serif">It turns out that populating a SharePoint list URL field is a little fiddly in Flow, but works fine once you have it set up. Here's how ...</span></div><div><span face=""arial" , "helvetica" , sans-serif"><br /></span></div><div><span face=""arial" , "helvetica" , sans-serif">First we're going to add in an action - <b>Send an HTTP Request to SharePoint</b>. The way I used this, it was the only action in the Flow, as I needed it to create the appropriate dynamic link each time I added an item to a list. But you can use this method in any Flow where you need to create a dynamic link on the fly.</span></div><div><span face=""arial" , "helvetica" , sans-serif"><br /></span></div><div><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_2ZIyF9-Td6vf_1sVQodXZbjfjz7KB8nuz5k6bcfyRE4Yj4p0U_jJvWJ6ATZtkftG10OkiP9YLy5j9fomX1_O1VqaPYxhXoj1S7WrJKTpyQgUJ-Dgdmfm_JlNrT1eL0TgRLO0N-Mh5BQ/s619/Send-HTTP-Request-to-SharePoint.jpg" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="515" data-original-width="619" height="333" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_2ZIyF9-Td6vf_1sVQodXZbjfjz7KB8nuz5k6bcfyRE4Yj4p0U_jJvWJ6ATZtkftG10OkiP9YLy5j9fomX1_O1VqaPYxhXoj1S7WrJKTpyQgUJ-Dgdmfm_JlNrT1eL0TgRLO0N-Mh5BQ/w400-h333/Send-HTTP-Request-to-SharePoint.jpg" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>This Action is already set up, but check below for the changes you should make and any relevant code ...</i></td></tr></tbody></table>So, first add your site address to the first field. Set the <b>Method</b> to POST. In the <b>Uri</b> field, add this:</div><div><br /></div><div><span style="font-family: courier;">_api/web/lists/GetByTitle('<b>Reward Training</b>')/items({ID})</span><br /><span face=""arial" , "helvetica" , sans-serif"><br /></span></div><div><span face=""arial" , "helvetica" , sans-serif">... but make the <span style="font-family: courier;">{ID}</span> bit a Dynamic Content call to the item ID. <b>Reward Training</b> is the name of my list</span></div><div><span face=""arial" , "helvetica" , sans-serif"><br /></span></div><div><span face=""arial" , "helvetica" , sans-serif">Next, click on the icon to the right of the <b>Headers</b> field and add this script:</span></div><div><span face=""arial" , "helvetica" , sans-serif"><br /></span></div><div><span face=""arial" , "helvetica" , sans-serif"><div style="font-family: courier;"> {</div><div style="font-family: courier;"> "Content-Type": "application/json;odata=verbose",</div><div style="font-family: courier;"> "X-HTTP-Method": "MERGE",</div><div style="font-family: courier;"> "IF-MATCH": "*"</div><div style="font-family: courier;"> }</div><div><span style="font-family: arial;"><br /></span></div><div><span style="font-family: arial;">The in the <b>Body</b> field, add this script:</span></div><div style="font-family: courier;"><br /></div><div style="font-family: courier;"><div>{'__metadata': {'type':'SP.Data.<b>NAMEOFYOURLIST</b>ListItem'},'<b>NameOfColumn</b>':</div><div> {'Description': '<b>Book this slot</b>',</div><div> 'Url': 'https://<b>YourSite</b>.sharepoint.com/sites/eo-event-registrations/Lists/Reward%20Training/EditForm.aspx?ID=[ID]&Source=https://<b>YourSite</b>.sharepoint.com/sites/eo-event-registrations/Lists/Reward%20Training/'}</div><div>}</div></div><div style="font-family: courier;"><br /></div></span></div><div><span face=""arial" , "helvetica" , sans-serif">It took me a couple of goes to understand what was going on here. I hope I've made it clear ... but the bit after SP.Data is the Name of Your List + "ListItem", no spaces. If your list name has spaces (best avoided, but on this occasion I didn't listen to my own advice) you'll need to use <span style="font-family: courier;"><b>_x0020_</b></span> for the space.</span></div><div><span face=""arial" , "helvetica" , sans-serif"><br /></span></div><div><span face=""arial" , "helvetica" , sans-serif">(Weirdly, you can use a regular word space in the <b>Uri</b> field, and a %20 in the link you paste into the <b>Body</b> field. You have the whole set with this Flow Action!)</span></div><div><span face=""arial" , "helvetica" , sans-serif"><br /></span></div><div><span face=""arial" , "helvetica" , sans-serif">My link is a call to an Edit Form. This can be the standard out-of-the-box Edit Form or something you've customised in Power Apps - makes no difference.</span></div><div><span face=""arial" , "helvetica" , sans-serif"><br /></span></div><div><span face=""arial" , "helvetica" , sans-serif">And the Description value "<b>Book this slot</b>" is what will appear in the list as the link text.</span></div><div><span face=""arial" , "helvetica" , sans-serif"><br /></span></div><div><span face=""arial" , "helvetica" , sans-serif">I also added a "Source" reference so that users are taken back to the main List page once they've finished with the EditForm, but that's not mandatory.</span></div><div><span face=""arial" , "helvetica" , sans-serif"><br /></span></div><div><span face=""arial" , "helvetica" , sans-serif">I hope this has helped someone.</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>AirPiratePresshttp://www.blogger.com/profile/13136561512898563240noreply@blogger.com3tag:blogger.com,1999:blog-3023476837266527744.post-9299730905389569432018-11-16T01:19:00.000-08:002018-11-16T01:19:38.998-08:00Add File Name field to custom EditForm<span style="font-family: "arial" , "helvetica" , sans-serif;">It's been a while since I posted here. Maybe this is because I've now switched to using SharePoint Online, and I'm finding it needs fewer workarounds than SP2007.</span><br />
<br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">Okay ... that sounds a bit unlikely.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">So here's a challenge I had recently. One of my clients asked that they get a File Name edit field in a custom EditForm I'd created for a Document Library.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">The out-of-the-box EditForm included a File Name field as standard.</span><br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgi6m_xE0JufYwb82Zoe7H2lBAZoE7PQ6138NkxsIU7ntk7biJL6m-6Pm7PuN0QvNjqlvaLRyffzC5JqbwiZbrwSOKAAsHydhY3Qvub6pyFVckqOUhTED0xOSVhBROfdRtPDRzzBMvlkCA/s1600/pic00_RegularEditForm.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="209" data-original-width="593" height="112" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgi6m_xE0JufYwb82Zoe7H2lBAZoE7PQ6138NkxsIU7ntk7biJL6m-6Pm7PuN0QvNjqlvaLRyffzC5JqbwiZbrwSOKAAsHydhY3Qvub6pyFVckqOUhTED0xOSVhBROfdRtPDRzzBMvlkCA/s320/pic00_RegularEditForm.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><i>Here's an example of how a standard EditForm presents its fields. Right at the top, labelled "Name" is the file name field. We can tell it's for a PDF, as Microsoft has helpfully rendered the file suffix outside the editable field.</i></span></td></tr>
</tbody></table>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">It seems that Microsoft disable the File Name field in custom EditForms. So I Googled to find a solution. The only workaround I came across suggested that the File Name field could be added manually by pasting some code into the EditForm in SharePoint Designer.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><asp:TextBox runat="server" id="ff26{$Pos}" ControlMode="Edit" text="{@FileLeafRef}" __designer:bind="{ddwrt:DataBind('u',concat('ff26',$Pos),'Text','TextChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@FileLeafRef')}"/></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Except that this doesn't quite work.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Let me explain.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">If you use the above code - pasted in to the second table cell in the new row you'd create to hold it - you get this result:</span><br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOglySsHbGzbJBSqS_Nh5TsdehzB-mBANu4jZfAJy7P2oC3L5n3tFpG1TTn44uBUEZ4F_FEVJSP72yGbqNIvS5_RLF3RjvDOPmt58Px3NL1GpCoUXZYvFKUfU3D4mSb4BunytoWxFlmVc/s1600/pic01_NoSuffixInCustomEditForm.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="267" data-original-width="616" height="138" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOglySsHbGzbJBSqS_Nh5TsdehzB-mBANu4jZfAJy7P2oC3L5n3tFpG1TTn44uBUEZ4F_FEVJSP72yGbqNIvS5_RLF3RjvDOPmt58Px3NL1GpCoUXZYvFKUfU3D4mSb4BunytoWxFlmVc/s320/pic01_NoSuffixInCustomEditForm.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><i>Spot the difference - this version, the custom EditForm with the above code added doesn't render the file suffix. A bit confusing for end users, I'm thinking.</i></span></td></tr>
</tbody></table>
<span style="font-family: "arial" , "helvetica" , sans-serif;">For me this was a bit of a deal-breaker. Without the visual hint that the file suffix gives the end-user, I didn't think it was obvious what that editable field was doing. Even more alarming, end users might change the file name without realising what they were doing.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">This would explain why Microsoft chose to exclude this feature from the custom forms. Except, in this instance, my client needed it.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">So I took a look at some of the other fields in the code and figured out a solution. Well, more of a lucky guess, really.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">But first, let me say this. Look at the ID value in the above code: "</span><span style="font-family: "courier new" , "courier" , monospace;">ff26</span><span style="font-family: "arial" , "helvetica" , sans-serif;">". SharePoint uses these values to differentiate between input fields. If you have two fields with the same ID, you will get an error: "Unable to display this web part ..." or similar.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">So first make sure that before you add any code to the EditForm page you've scrolled to the end of the form fields section and checked the ID value of the last row in the form. In my case, it had the ID value of </span><span style="font-family: "courier new" , "courier" , monospace;">ff25</span><span style="font-family: "arial" , "helvetica" , sans-serif;">.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Then, because I could see that the code for all the other form fields began with:</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><SharePoint:FormField ...</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">I thought I'd try that instead, and re-wrote the above line of code as this:</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><SharePoint:FormField runat="server" id="ff26{$Pos}" ControlMode="Edit" FieldName="FileLeafRef" __designer:bind="{ddwrt:DataBind('u',concat('ff26',$Pos),'Text','TextChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@FileLeafRef')}"/></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Be aware that the attribute "</span><span style="font-family: "courier new" , "courier" , monospace;">text</span><span style="font-family: "arial" , "helvetica" , sans-serif;">" isn't permissible in the </span><span style="font-family: "courier new" , "courier" , monospace;">SharePoint:FormField</span><span style="font-family: "arial" , "helvetica" , sans-serif;"> tag, so I used </span><span style="font-family: "courier new" , "courier" , monospace;">FieldName</span><span style="font-family: "arial" , "helvetica" , sans-serif;"> instead.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">And it worked.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">The File Name field rendered perfectly and even tagged on a file suffix after the text field.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZOaYEUy4RQOd1OzEz5e7dPmOAX-dFIqU5LAsD1qjeWNjt-SlXVPoOvMBDEhN_StOt5SwXMNw-kfEPay9Twvk6rYHyCNRxUTLMV-7jwFWesPnLMprAdF2aLzqrgx5Sm1X_MgU0c4JQqe4/s1600/pic06_FileNameinCustomEditForm.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="246" data-original-width="619" height="127" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZOaYEUy4RQOd1OzEz5e7dPmOAX-dFIqU5LAsD1qjeWNjt-SlXVPoOvMBDEhN_StOt5SwXMNw-kfEPay9Twvk6rYHyCNRxUTLMV-7jwFWesPnLMprAdF2aLzqrgx5Sm1X_MgU0c4JQqe4/s320/pic06_FileNameinCustomEditForm.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><i>Success ... those small alterations to the code cause the custom EditForm to render in exactly the same way as the out-of-the-box one.</i></span></td></tr>
</tbody></table>
<span style="font-family: "arial" , "helvetica" , sans-serif;">I hope that's helped someone ...</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>AirPiratePresshttp://www.blogger.com/profile/13136561512898563240noreply@blogger.com0tag:blogger.com,1999:blog-3023476837266527744.post-61836497590496540422016-04-22T07:25:00.000-07:002017-05-02T05:31:34.231-07:00Add an "Out of date" alert to SharePoint content pages<span style="font-family: "arial" , "helvetica" , sans-serif;">I was at an Intranet Experts conference last year in Geneva, courtesy of <a href="https://www.advatera.com/">Advatera</a>. During the day, the subject of how we can get Site Builders in a federated content model to ensure they keep their content up to date. One suggestion was to add a banner to the top of any page that hasn't been updated within a certain time period, for example, a year.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Trouble is, no one really knew how to do it.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">So I had a bit of think about it and figured that if I could come up with some way to retrieve the page's Modified value and put that into a JavaScript variable, then it would be easy to get a message to display on the page ... say, like this.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7vpdJea5n_R3f79s9-7q1qqaAEG7vp0MYsAuOlCe0aQVACBP4fxlybrqbUTS5KOBFgeOPPEmIBzNoWpojqSCbhqhFkg8T9bSqj5049td8QZR2Ng1dFLOcmXWsKfg-KOTifmO9la6dVNE/s1600/OutOfDate_edit.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="151" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7vpdJea5n_R3f79s9-7q1qqaAEG7vp0MYsAuOlCe0aQVACBP4fxlybrqbUTS5KOBFgeOPPEmIBzNoWpojqSCbhqhFkg8T9bSqj5049td8QZR2Ng1dFLOcmXWsKfg-KOTifmO9la6dVNE/s320/OutOfDate_edit.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">So ... how do you do it? The key is in the SharePoint control:</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><SharePointWebControls:FieldValue ID="Modified" FieldName="Modified" runat="server"/></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">So, with a lot of help from my colleague David T., this is what we came up with:</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><script></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> $( document ).ready(function() {</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> var shareDate = '<SharePointWebControls:FieldValue ID="Modified" FieldName="Modified" runat="server"/>';</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> var regex = /(\d+)/g;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> </span><span style="font-family: "courier new" , "courier" , monospace;"> </span><span style="font-family: "courier new" , "courier" , monospace;">var dateParts = shareDate.match(regex);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> </span><span style="font-family: "courier new" , "courier" , monospace;"> </span><span style="font-family: "courier new" , "courier" , monospace;">var docDate = new Date(dateParts[2]+"/"+dateParts[1]+"/"+dateParts[0]);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> </span><span style="font-family: "courier new" , "courier" , monospace;"> </span><span style="font-family: "courier new" , "courier" , monospace;">var prevDate = new Date();</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> </span><span style="font-family: "courier new" , "courier" , monospace;"> </span><span style="font-family: "courier new" , "courier" , monospace;">prevDate.setDate(prevDate.getDate() - 365); //This is the number of days in the past to check</span><br />
<span class="Apple-tab-span" style="white-space: pre;"><span style="font-family: "courier new" , "courier" , monospace;"> </span></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> </span><span style="font-family: "courier new" , "courier" , monospace;"> </span><span style="font-family: "courier new" , "courier" , monospace;">if(docDate < prevDate){</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> </span><span style="font-family: "courier new" , "courier" , monospace;"> </span><span style="font-family: "courier new" , "courier" , monospace;">$( ".Breadcrm" ).append("<strong class='OutOfDate'>The content on this page has not been updated in over a year and may be unreliable</strong>");</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> });</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"></script></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">To get this work cleanly, I inserted the script at the end of the </span><span style="font-family: "courier new" , "courier" , monospace;"><div></span><span style="font-family: "arial" , "helvetica" , sans-serif;"> block that holds the breadcrumb trail in the content page's MasterPage (see the screengrab above for what the final (active) alert looks like.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">It's not a foolproof method, because all a content editor has to do is <b>Edit the page</b> then immediately <b>Publish </b>it and the Alert will disappear. But at least it will concentrate the attention of the more diligent content editor.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Hope this helps someone.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>AirPiratePresshttp://www.blogger.com/profile/13136561512898563240noreply@blogger.com0tag:blogger.com,1999:blog-3023476837266527744.post-11244370259836320232016-03-14T09:48:00.000-07:002017-05-02T05:34:50.561-07:00Create dynamic list forms with jQuery and SP Designer<span style="font-family: "arial" , "helvetica" , sans-serif;">In an earlier post, I covered ways to make certain fields in a SharePoint list's input forms invisible, using JavaScript. But recently, I had a request to make input fields appear based on the user selecting a value from a picklist (drop-down list). With quite a bit of help from my colleague David T, I managed to figure out a way to create quite dynamic input forms for a SharePoint list using jQuery. This is how we did it.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">You will need SharePoint Designer access in order to do this. <span style="color: red;"><b>If you don't have SharePoint Designer access then this method will not be possible for you.</b></span></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">So, this is what we'll end up with. When the user wants to create a new item, the NewForm.aspx page will come up looking like this:</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfK3EKGW79faUVgSbZZZZsgH8FhUvibU1PRh96vDDXCudmYJptpwNyG29lRuExyrEbyllTZlE2lq-RURZIO27pl4md3QUSHro_hzEC0tKkU2uRJbguTOvmTGVtDUurJ6VNa_Y2E_iNukM/s1600/pic01_SelectCategory.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="90" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfK3EKGW79faUVgSbZZZZsgH8FhUvibU1PRh96vDDXCudmYJptpwNyG29lRuExyrEbyllTZlE2lq-RURZIO27pl4md3QUSHro_hzEC0tKkU2uRJbguTOvmTGVtDUurJ6VNa_Y2E_iNukM/s320/pic01_SelectCategory.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><i>Select a category and the dynamic input form will change.</i></span></td></tr>
</tbody></table>
<span style="font-family: "arial" , "helvetica" , sans-serif;">The user will then select the category they want and the form will display differently, depending on the category chosen. In this case, the list was designed to hold Service Alerts and Planned Outages for IT systems within our company. Service Alerts happen on an <i>ad hoc</i> basis and don't have Start or End dates. </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjacVj0LNnW_5zvT_9jvUtO0NOw81PnzrkTRYF2SZzoNb39Hn-Y6ECX_ZIYkPXlbKUqlpxg2mal7jWBi120ZHRZ3KAVEOWr6Sz08bAzkiQiiT-2Gu4uf5xow5mChFKpxXV2CN43nHl5pVo/s1600/pic02_SelectAlert.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="268" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjacVj0LNnW_5zvT_9jvUtO0NOw81PnzrkTRYF2SZzoNb39Hn-Y6ECX_ZIYkPXlbKUqlpxg2mal7jWBi120ZHRZ3KAVEOWr6Sz08bAzkiQiiT-2Gu4uf5xow5mChFKpxXV2CN43nHl5pVo/s320/pic02_SelectAlert.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><i>This is how the form displays if you choose "Service alert".</i></span></td></tr>
</tbody></table>
<span style="font-family: "arial" , "helvetica" , sans-serif;">But Planned Outages, by definition, will have a Start and an End date. Thus choosing Outage will reveal the fields for the Beginning and End of the Planned Outage.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDlt_k3s7hAue745-TJpV8rzBtWCV3aafVFKYTyiuw1P5P_INGgc4YorDbwSBIIoO4ivjLv2FhDSNcVARYQsZxto61KjnnkoZDxIq0frhgW4lkt3axr9-mbB2pPFkBuUmywN_Ma0_NlCw/s1600/pic03_SelectOutage.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="295" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDlt_k3s7hAue745-TJpV8rzBtWCV3aafVFKYTyiuw1P5P_INGgc4YorDbwSBIIoO4ivjLv2FhDSNcVARYQsZxto61KjnnkoZDxIq0frhgW4lkt3axr9-mbB2pPFkBuUmywN_Ma0_NlCw/s320/pic03_SelectOutage.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><i>However, Outages require an Start Date/Time and and End Date/Time ...</i></span></td></tr>
</tbody></table>
<span style="font-family: "arial" , "helvetica" , sans-serif;">So, in the browser, set up your list with all the fields you need for either (or all, if you're having more than two choices) situation, and be sure to include a <b>Category</b> field as a Choice, so you can switch between the options in the NewForm.aspx. I started with an Announcements list, as this was essentially a news feed, and customised it slightly.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDs9E6VHkYTqCRU2eK2gbeLkh_ZU1zVIh1f4KA22EGhV-8LFIR6Vl0szIInKDOSR9y67YrbEXXjn0hVN7oDkttzX5s_1ZqsmLGcBLfKOBI3IrxjEcaFp9XzagZ_EUQY9fGp_MSNxXX3oc/s1600/pic00_ListColumns.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="225" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDs9E6VHkYTqCRU2eK2gbeLkh_ZU1zVIh1f4KA22EGhV-8LFIR6Vl0szIInKDOSR9y67YrbEXXjn0hVN7oDkttzX5s_1ZqsmLGcBLfKOBI3IrxjEcaFp9XzagZ_EUQY9fGp_MSNxXX3oc/s320/pic00_ListColumns.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><i>Here's the Announcements list with the added custom fields.</i></span></td></tr>
</tbody></table>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Make sure you have the columns in the order you want them to appear in the NewForm.aspx. If you don't, and you change the order later, this will affect the way the jQuery script works and you'll end up with a broken form.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Next, create a document library in your site, and name it "siteJS". In that, place a blank Notepad document, named "NewForm.js". You'll use this later to hold the script that controls the NewForm.aspx. </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Now, fire up SharePoint Designer and navigate to the Site where you created the List. In the Folder List, find the Lists section and expand it. Now find your target list, and expand that.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhz1oNl03QxjN8-yEoj1udi2ykb1z7i4Wo0cpWw-J9kKCBmG-5v6pCEROMAyXw_-K8DTTLIVXn0lVmf8LwWYt_qyUcKQNSx9QEPzlFpSEbpvrSHEMIkayjc9L992W669OtzmqXNv1nGRIU/s1600/pic05_ExpandList.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhz1oNl03QxjN8-yEoj1udi2ykb1z7i4Wo0cpWw-J9kKCBmG-5v6pCEROMAyXw_-K8DTTLIVXn0lVmf8LwWYt_qyUcKQNSx9QEPzlFpSEbpvrSHEMIkayjc9L992W669OtzmqXNv1nGRIU/s1600/pic05_ExpandList.jpg" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td class="tr-caption" style="font-size: 12.8px;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><i>This is where all the out-of-the-box list forms are stored.</i></span></td></tr>
</tbody></table>
</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
</div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Find the NewForm.aspx under the List and open it. If you get an alert box asking if you want to check the page out, click Yes.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Now somewhere around line 15 in the code for the page, you should see a line that says:</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server"></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Under that, you'll place your calls to the jQuery files. I prefer to store the jQuery files locally (as you can see from the paths in the screengrab). But you can use calls to the remote jQuery files if you want - a quick Google search will throw up a slew of examples.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxga6pUf-aFmSQBq_XE_bcQERRoVudTKRTewUH8erw3ncP4jLSHAySvKP9GkV0mAHoOZk5hyVx3rw6KzaYC4-uz2cYiisHwPBqDUbnDRttnkuNlQ8WV7E7tGnlWHZpuMbyVEUiuPQPu3E/s1600/pic06_add_jQueryCalls.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="150" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxga6pUf-aFmSQBq_XE_bcQERRoVudTKRTewUH8erw3ncP4jLSHAySvKP9GkV0mAHoOZk5hyVx3rw6KzaYC4-uz2cYiisHwPBqDUbnDRttnkuNlQ8WV7E7tGnlWHZpuMbyVEUiuPQPu3E/s320/pic06_add_jQueryCalls.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><i>This is what the code looks like in SP Designer. Make sure you put your JavaScript in the right place or the function won't work.</i></span></td></tr>
</tbody></table>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Once you done that, you can also add a call to your blank Notepad document you saved earlier.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkP3zdoZctAHKqiEPiAbgklsFmiA6IpADifLFCfvrAN8fLSRpTMwW24EhwgfBofJ_opPKrpbu8pFcWebMnNtKDrU-MNeMir6zKQm6jv_TDIqP7bgE42e0s0a5Q1MVwZsXZIJbhnQK7cQ0/s1600/pic08_Add_script_Call.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="113" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkP3zdoZctAHKqiEPiAbgklsFmiA6IpADifLFCfvrAN8fLSRpTMwW24EhwgfBofJ_opPKrpbu8pFcWebMnNtKDrU-MNeMir6zKQm6jv_TDIqP7bgE42e0s0a5Q1MVwZsXZIJbhnQK7cQ0/s320/pic08_Add_script_Call.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><i><span style="font-family: "arial" , "helvetica" , sans-serif;">Add the call to the text file that will hold your custom JavaScript. Relative pathways are fine.</span></i></td></tr>
</tbody></table>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Now, we're more or less ready to start on the real meat of this task. But first, you'll need to fetch the ID's of all the fields in the NewForm.aspx page. You can do this most effectively by bringing the page up in your browser then <b>Viewing Source</b>. Each field will have an ID associated with it. These IDs also reflect the order of the fields in the <b>NewForm</b> page. If you change the order of the fields, the IDs will change. Use <b>Find</b> to speed though the source code of the NewForm page.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">It would save you time if you load each ID into the NewForm.js file as you go along, as this is where they'll end up. I prefer to use NotePad++ over regular Notepad, but either will do. So, open the NewForm.js file and begin entering the field IDs as you copy them from the View Source window. To save yourself a little time, enter them in this format:</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">var trBody = $("#ctl00_m_g_6c609f0f_5ff0_49e3_b8da_0653643109f9_ctl00_ctl04_ctl04_ctl00_ctl00_ctl04_ctl00_ctl00_TextField").closest("tr"); // Field = Body Text</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">You're setting each field up as a variable, which you can use later in the process to control the visibility of the field. For text fields, the above format is fine, but date fields are trickier to manage, because date fields are made up of more than one component. So they require two variables to be set to manage them correctly. I set up the date fields variables like this:</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">var trExpires = $("#ctl00_m_g_6c609f0f_5ff0_49e3_b8da_0653643109f9_ctl00_ctl04_ctl08_ctl00_ctl00_ctl04_ctl00_ctl00_DateTimeField_DateTimeFieldDate").parent().parent().parent().parent().parent().parent().parent(); // Row = Expires </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">var fncExpires = $("#ctl00_m_g_6c609f0f_5ff0_49e3_b8da_0653643109f9_ctl00_ctl04_ctl08_ctl00_ctl00_ctl04_ctl00_ctl00_DateTimeField_DateTimeFieldDate").closest("tr"); //Field = Expires</span><br />
<span class="Apple-tab-span" style="white-space: pre;"><span style="font-family: "arial" , "helvetica" , sans-serif;"> </span></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">The first variable above controls the tables row that the field appears in, and the second variable controls the date function itself.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">When you have all the field IDs added in this way, you're ready to add the rest of the scripting.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Before your list of field variables add this scripting:</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">$(document).ready(function() {</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>// *** START HIDE-SHOW FIELDS BASED ON "CATEGORY" DROP-DOWN SELECTION ***</span><br />
<span class="Apple-tab-span" style="white-space: pre;"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </span></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>// FORM FIELD VARIABLES</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>var selectList1 = $('#ctl00_m_g_6c609f0f_5ff0_49e3_b8da_0653643109f9_ctl00_ctl04_ctl01_ctl00_ctl00_ctl04_ctl00_DropDownChoice'); // Field = Select category</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Commenting is good practice that helps you keep track of what's going on. Notice that I put the <b>Category</b> drop-down variable at the top of the listing of variables and named it slightly differently from the others.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Now ... below the list of variables, add this script:</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>//resets the form</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>function clearAll() {</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span>$('*[id*=5ff0_49e3_b8da_0653643109f9_ctl00_ctl04]:visible').each(function() {</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>$(this).closest("tr").hide();</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>});</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>$(selectList1).closest("tr").show(); //show dropdown</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>$(trStartDate).hide(); // Field = Start Date</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>$(trEndDate).hide(); // Field = End Date</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>$(trExpires).hide(); // Field = Expires Date</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>clearAll(); // hides all rows upon loading the page</span><br />
<span class="Apple-tab-span" style="white-space: pre;"><span style="font-family: "arial" , "helvetica" , sans-serif;"> </span></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">This hides all the fields except for the <b>Category</b> drop-down. The line that begins $('*[id*= finds every field with an ID that contains "5ff0_49e3_b8da_0653643109f9_ctl00_ctl04" and the next line hides them all. The next four lines that begin with "$" shows the drop down and hides the table rows that contain the date fields.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Now, beneath the above script, add this:</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>//Category > Alert</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>function alert() {</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>clearAll(); // call the Alert form function</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$(trCategory).show(); // Field = Category</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$(trTitle).show(); // Field = Title</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$(trStatus).show(); // Field = Status</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$(trIncident).show(); // Field = Incident number</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$(trBody).show(); // Field = Body text</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$(trBodyTool).show(); // show text field options</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$(trUpdate).show(); // Field = Update Test / Reason</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>// Next two lines required to make Expired date field show</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$(trExpires).show(); // Row = Expires Date</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$(fncExpires).show(); // Row = Expires Date</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br />
<span class="Apple-tab-span" style="white-space: pre;"><span style="font-family: "arial" , "helvetica" , sans-serif;"> </span></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">This block of script makes the required fields for the Alert category visible.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Next, add this script, which makes the other category (Outage) visible:</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>//Category > Outage</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>function outage() {</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>clearAll(); // call the Outage form function</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$(trCategory).show(); // Field = Category</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$(trTitle).show(); // Field = Title</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$(trStatus).show(); // Field = Status</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$(trIncident).show(); // Field = Incident number</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$(trBody).show(); // Field = Body text</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$(trBodyTool).show(); // show text field options</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$(trUpdate).show(); // Field = Update Test / Reason</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>// Next two lines required to make Start date field show</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$(trStartDate).show(); // Row = Start Date</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$(fncStartDate).show(); // Row = Start Date</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>// Next two lines required to make End date field show</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$(trEndDate).show(); // Row = End Date</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$(fncEndDate).show(); // Row = End Date</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>// Next two lines required to make Expired date field show</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$(trExpires).show(); // Row = Expires Date</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$(fncExpires).show(); // Row = Expires Date</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br />
<span class="Apple-tab-span" style="white-space: pre;"><span style="font-family: "arial" , "helvetica" , sans-serif;"> </span></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">Finally, add the block of script that controls the whole function:</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>// calls function if selectlist1 is changed</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$(selectList1).change(function() {</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>var funcCall = "";</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>var primarySelect = $(selectList1).val().toLowerCase().replace(/-|\s/g, '');</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>var funcCall = primarySelect;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>//alert("Segment: "+ primarySelect +"\nRequestType: "+secondarySelect +"\nFunction Name: "+funcCall);</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>eval(funcCall+'()');</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>});</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">You don't need the <b>Alert</b> line. I was using this for testing a version of this script that had two different category drop-downs.</span><br />
<span class="Apple-tab-span" style="white-space: pre;"><span style="font-family: "arial" , "helvetica" , sans-serif;"> </span></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">Finally, make sure the whole script block is closed by adding:</span><br />
<span class="Apple-tab-span" style="white-space: pre;"><span style="font-family: "arial" , "helvetica" , sans-serif;"> </span></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">});</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Save the file, and you're ready to test.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">That should be it. Hope this helps someone.</span><br />
<br />AirPiratePresshttp://www.blogger.com/profile/13136561512898563240noreply@blogger.com0tag:blogger.com,1999:blog-3023476837266527744.post-42962952643222030512016-01-28T02:34:00.000-08:002018-03-01T08:08:02.002-08:00Use DDWRT to format your dates<span style="font-family: "arial" , "helvetica" , sans-serif;">The ddwrt date functions in SharePoint are not the easiest things to get to grips with. And it's quite difficult to find a definitive list of all the functions When I <i>have</i> found lists in other people's blogs, the functions posted don't always coincide with what I'm seeing in my site collection. This might be a result of us all using slightly different builds of SharePoint, but I'm going to list the ddwrt variations that I have observed on my SharePoint Site Collection by actually using them.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">If you are going to use ddwrt date formatting in your Data View Web Part, you <i>must</i> include the line:</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">xmlns:ddwrt=http://schemas.microsoft.com/WebParts/v2/DataView/runtime</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">... inside the </span><span style="font-family: "courier new" , "courier" , monospace;"><xsl:stylesheet ...></span><span style="font-family: "arial" , "helvetica" , sans-serif;"> tag, like this:</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:stylesheet </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <span style="color: red;">version</span><span style="color: #3d85c6;">="1.0"</span> <span style="color: red;">exclude-result-prefixes</span><span style="color: #3d85c6;">="xsl msxsl ddwrt"</span> </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <span style="color: red;">xmlns:x</span><span style="color: #3d85c6;">="http://www.w3.org/2001/XMLSchema"</span> </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <span style="color: red;">xmlns:dsp</span><span style="color: #3d85c6;">="http://schemas.microsoft.com/sharepoint/dsp" </span></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <span style="color: red;">xmlns:asp</span><span style="color: #3d85c6;">="http://schemas.microsoft.com/ASPNET/20"</span> </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <span style="color: red;">xmlns:__designer</span><span style="color: #3d85c6;">="http://schemas.microsoft.com/WebParts/v2/DataView/designer"</span> </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <span style="color: red;">xmlns:xsl</span><span style="color: #3d85c6;">="http://www.w3.org/1999/XSL/Transform"</span> </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <span style="color: red;">xmlns:msxsl</span><span style="color: #3d85c6;">="urn:schemas-microsoft-com:xslt"</span> </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <span style="color: red;">xmlns:SharePoint</span><span style="color: #3d85c6;">="Microsoft.SharePoint.WebControls"</span> </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <span style="color: red;">xmlns:ddwrt2</span>=<span style="color: #3d85c6;">"urn:frontpage:internal"</span></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <span style="background-color: yellow;"><span style="color: red;">xmlns:ddwrt</span>=<span style="color: #3d85c6;">"http://schemas.microsoft.com/WebParts/v2/DataView/runtime"</span></span></span><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">></span><br />
<br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">The 1033 LCID is used for US date formatting and the 2057 LCID is for UK date formatting. Where there's a hyphen in the <b>Result</b> column below, it means that the relevant ddwrt value produced no result for me.</span><br />
<br />
<table border="1" cellpadding="2" cellspacing="0" style="width: 100%px;">
<tbody>
<tr><td style="background-color: #0086cd;" width="80%"><span style="color: white; font-family: "arial" , "helvetica" , sans-serif;"><b>DDWRT value</b></span></td><td style="background-color: #0086cd;" width="20%"><b><span style="color: white; font-family: "arial" , "helvetica" , sans-serif;">Result</span></b></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@StartDate),1033,1)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">2/21/2016</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@StartDate),1033,2)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif;">-</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@StartDate),1033,3)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">Sunday, February 21, 2016</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@StartDate),1033,4)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">1:00 PM</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),1033,5)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">2/21/2016 1:00 PM</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),1033,6)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">1:00 PM</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),1033,7)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">Sunday, February 21, 2016 1:00 PM</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),1033,8)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">-</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),1033,9)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">2/21/2016</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),1033,10)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">-</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),1033,11)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">Sunday, February 21, 2016</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),1033,12)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">1:00:00 PM</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),1033,13)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">2/21/2016 1:00:00 PM</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),1033,14)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">1:00 PM</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),1033,15)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">Sunday, February 21, 2016 1:00:00 PM</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),1033,16)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">-</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),1033,17)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">2/21/2016</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),1033,18)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">-</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),1033,19)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">Sunday, February 21, 2016</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),1033,20)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">1:00 PM</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),1033,21)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">2/21/2016 1:00 PM</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),1033,22)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">1:00 PM</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),1033,23)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">Sunday, February 21, 2016 1:00 PM</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@StartDate),1033,25)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">2/21/2016</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@StartDate),1033,27)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">Sunday, February 21, 2016</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),1033,28)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">1:00:00 PM</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),1033,29)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">2/21/2016 1:00:00 PM</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),1033,30)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">1:00:00 PM</span></td></tr>
<tr><td width="80%"></td><td width="20%"></td></tr>
<tr><td style="background-color: #0086cd;" width="80%"><span style="color: white; font-family: "arial" , "helvetica" , sans-serif;"><b>DDWRT value</b></span></td><td style="background-color: #0086cd;" width="20%"><b><span style="color: white; font-family: "arial" , "helvetica" , sans-serif;">Result</span></b></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@StartDate),2057,1)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">21/02/2016</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@StartDate),2057,2)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">-</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@StartDate),2057,3)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">21 February 2016</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@StartDate),2057,4)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">13:00</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),2057,5)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">21/02/2016 13:00</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),2057,6)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">13:00</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),2057,7)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">21 February 2016 13:00</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),2057,8)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">-</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),2057,9)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">21/02/2016</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),2057,10)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">-</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),2057,11)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">21 February 2016</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),2057,12)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">13:00:00</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),2057,13)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">21/02/2016 13:00:00</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),2057,14)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">13:00:00</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),2057,15)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">21 February 2016 13:00:00</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),2057,16)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">-</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),2057,17)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">21/02/2016</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),2057,18)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">-</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),2057,19)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">21 February 2016</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),2057,20)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">13:00</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),2057,21)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">21/02/2016 13:00</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),2057,22)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">13:00</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),2057,23)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">21 February 2016 13:00</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@StartDate),2057,25)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">21/02/2016</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@StartDate),2057,27)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">21 February 2016</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),2057,28)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">13:00:00</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),2057,29)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">21/02/2016 13:00:00</span></td></tr>
<tr><td width="80%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDate(string(@EventDate),2057,30)" /></span></td><td width="20%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">13:00:00</span></td></tr>
</tbody></table>
<br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">If you're using the </span><span style="font-family: "courier new" , "courier" , monospace;">FormatDateTime</span><span style="font-family: "arial" , "helvetica" , sans-serif;"> specifier, it doesn't matter whether you define the LCID as 1033 or 2057.</span><br />
<br />
<table border="1" cellpadding="2" cellspacing="0" style="width: 100%px;">
<tbody>
<tr><td style="background-color: #0086cd;" width="85%"><span style="color: white; font-family: "arial" , "helvetica" , sans-serif;"><b>DDWRT value</b></span></td><td style="background-color: #0086cd;" width="15%"><b><span style="color: white; font-family: "arial" , "helvetica" , sans-serif;">Result</span></b></td></tr>
<tr><td width="85%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDateTime(string(@EventDate),1033,'dd-MMM-yy')" /></span></td><td width="15%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">21-Jan-15</span></td></tr>
<tr><td width="85%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDateTime(string(@EventDate),1033,'dd/MM/yy')" /></span></td><td width="15%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">21/01/15</span></td></tr>
<tr><td width="85%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDateTime(string(@EventDate),1033,'dd/M/yy')" /></span></td><td width="15%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">21/1/15</span></td></tr>
<tr><td width="85%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDateTime(string(@EventDate),1033,'ddd, dd/M/yy')" /></span></td><td width="15%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">Sun, 21/1/15</span></td></tr>
<tr><td width="85%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:value-of select="ddwrt:FormatDateTime(string(@EventDate),1033,'dddd, dd/M/yy')" /></span></td><td width="15%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">Sunday, 21/1/15</span></td></tr>
</tbody></table>
<br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">The full list of specifiers is as follows:</span><br />
<br />
<table border="1" cellpadding="2" cellspacing="0" style="width: 100%px;">
<tbody>
<tr><td style="background-color: #0086cd;" width="15%"><span style="color: white; font-family: "arial" , "helvetica" , sans-serif;">Specifier</span></td><td style="background-color: #0086cd;" width="85%"><span style="color: white; font-family: "arial" , "helvetica" , sans-serif;">Result</span></td></tr>
<tr><td width="15%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">d</span></td><td width="85%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">Day of the month, single digit 1-9, double digit 10 up</span></td></tr>
<tr><td width="15%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">dd</span></td><td width="85%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">Day of the month, leading zero 1-9, double digit 10 up</span></td></tr>
<tr><td width="15%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">ddd</span></td><td width="85%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">Abbreviated day of the week, ie, Wed</span></td></tr>
<tr><td width="15%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">dddd</span></td><td width="85%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">Full name of the day of the week</span></td></tr>
<tr><td style="background-color: #0086cd;" width="15%"><span style="color: white; font-family: "arial" , "helvetica" , sans-serif; font-size: xx-small;">Specifier </span></td><td style="background-color: #0086cd;" width="85%"><span style="color: white; font-family: "arial" , "helvetica" , sans-serif; font-size: xx-small;">Result</span></td></tr>
<tr><td width="15%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">M</span></td><td width="85%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">The month, 1 to 12</span></td></tr>
<tr><td width="15%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">MM</span></td><td width="85%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">The month, 01 to 12</span></td></tr>
<tr><td width="15%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">MMM</span></td><td width="85%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">Abbreviated name of the month</span></td></tr>
<tr><td width="15%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">MMMM</span></td><td width="85%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">Full name of the month</span></td></tr>
<tr><td style="background-color: #0086cd;" width="15%"><span style="color: white; font-family: "arial" , "helvetica" , sans-serif; font-size: xx-small;">Specifier </span></td><td style="background-color: #0086cd;" width="85%"><span style="color: white; font-family: "arial" , "helvetica" , sans-serif; font-size: xx-small;">Result</span></td></tr>
<tr><td width="15%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">y</span></td><td width="85%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">The year, from 0 to 99</span></td></tr>
<tr><td width="15%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">yy</span></td><td width="85%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">The year, from 00 to 99</span></td></tr>
<tr><td width="15%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">yyy</span></td><td width="85%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">The year with a minumum of three digits, ie 900</span></td></tr>
<tr><td width="15%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">yyyy</span></td><td width="85%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">The year as a four-digit number</span></td></tr>
</tbody></table>
<br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">You can also add the following, if you want to display the time, as well:</span><br />
<br />
<table border="1" cellpadding="2" cellspacing="0" style="width: 100%px;">
<tbody>
<tr><td style="background-color: #0086cd;" width="15%"><span style="color: white; font-family: "arial" , "helvetica" , sans-serif;">Specifier </span></td><td style="background-color: #0086cd;" width="85%"><span style="color: white; font-family: "arial" , "helvetica" , sans-serif;">Result</span></td></tr>
<tr><td width="15%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">h</span></td><td width="85%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">12-hour clock, 1 to 12</span></td></tr>
<tr><td width="15%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">hh</span></td><td width="85%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">12-hour clock, 01 to 12</span></td></tr>
<tr><td width="15%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">H</span></td><td width="85%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">24 hour clock, 1 to 24</span></td></tr>
<tr><td width="15%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">HH</span></td><td width="85%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">24 hour clock, 01 to 24</span></td></tr>
<tr><td width="15%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">m</span></td><td width="85%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">Minutes, 0 to 59</span></td></tr>
<tr><td width="15%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">mm</span></td><td width="85%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">Minutes, 00 to 59</span></td></tr>
<tr><td width="15%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">s</span></td><td width="85%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">Seconds, 0 to 59</span></td></tr>
<tr><td width="15%"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">ss</span></td><td width="85%"><span style="font-family: "arial" , "helvetica" , sans-serif; font-size: x-small;">Seconds, 00 to 59</span></td></tr>
</tbody></table>
<br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">Use anything you like to separate the components ... a dash, a slash or wordpsaces and/or commas.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Hope this helps someone.</span><br />
<br />
<br />AirPiratePresshttp://www.blogger.com/profile/13136561512898563240noreply@blogger.com4tag:blogger.com,1999:blog-3023476837266527744.post-60965147641283620732016-01-19T05:33:00.001-08:002017-05-10T11:41:05.194-07:00SharePoint Calendar – view as a year<span style="font-family: "arial" , "helvetica" , sans-serif;">The one thing SharePoint doesn’t do out of the box … well, there’s many things … but the one that has given me the biggest challenge is its inability to let me display a calendar in year-view. I’m sure there’s valid reasons for this. I’ve found that the Month View of the SharePoint calendar is a snake-pit of embedded tables and weird, week-long table rows. (Go “View Source” on a Month View if you want to be horrified.)</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Yes, you can go to various sites and buy an enhanced Calendar web part, and admittedly, that might well save you time. But if, like me, you work in a corporate environment, you’ll no doubt find that installing alien software on your SharePoint server will involve much sighing and sucking of teeth from the IT Department.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">So I thought I’d look into using a DataView Web Part to display a year’s-worth of events. It took me quite a while (I think I started this in 2013), but I’ve finally come up with something that’s at least workable, though by no means perfect. If anyone smarter than me (essentially just about everyone) reading this is able to suggest improvements, I would be hugely grateful.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">So here’s what I ended up with:</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5mWm_OePfFKiOjq7r1L-kcv2ZbS61dRK68bluVzo6Wv8VIXNyGNDaenPa6vzOojOAoWFIUTr0745gGk0kkNcDQ-mLjcbCkgLeaVTnQ1O0NS0he3F3zOgFHfFLJRAqvdQd5QcWOdYmwuc/s1600/pic01_FinalCalendar.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="218" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5mWm_OePfFKiOjq7r1L-kcv2ZbS61dRK68bluVzo6Wv8VIXNyGNDaenPa6vzOojOAoWFIUTr0745gGk0kkNcDQ-mLjcbCkgLeaVTnQ1O0NS0he3F3zOgFHfFLJRAqvdQd5QcWOdYmwuc/s320/pic01_FinalCalendar.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><i>This is where we want to be at the end of the process - rendering a calendar in year view. The colours can be changed in the code.</i></span></td></tr>
</tbody></table>
<span style="font-family: "arial" , "helvetica" , sans-serif;">This is going to need SharePoint Designer access level, so if you haven’t got that then this method isn’t for you.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">So the first thing you need to do is to create a SharePoint Calendar and populate it with some events. The one you see here is tracking our company Board and Committee meetings throughout the year. Prior to this, our senior PAs put this information into an Excel spreadsheet and emailed it around. My version at least gives users the ability to click on an event and be taken to a detail page, courtesy of the Calendar’s <b>DispForm.aspx</b> page.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">I’ve kept the data in the <b>Title </b>field of each Calendar event as short as possible – three characters – as by necessity the columns in your year calendar are going to be narrow. Users can always click on the event to see more details if they don’t understand a three character acronym.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">You should also consider adding a <b>Category </b>column (drop-down list) to your calendar. This will come in handy later when we colour code the types of events in the calendar.</span><br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhI_jm8dwiy3GOL8iEblEFAvXFi5RuSmG6T2WMYSer3FYJ3lqPAqq83vKoVaBMvOKHG5-MZC7o5OoPuelGqVV7WQIjGJY5vRkoYZ7Ia8yAiq0555RbfwDcdfpsHBY9_xJwAZL-k7aHMj3o/s1600/pic02_AddCategory.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhI_jm8dwiy3GOL8iEblEFAvXFi5RuSmG6T2WMYSer3FYJ3lqPAqq83vKoVaBMvOKHG5-MZC7o5OoPuelGqVV7WQIjGJY5vRkoYZ7Ia8yAiq0555RbfwDcdfpsHBY9_xJwAZL-k7aHMj3o/s320/pic02_AddCategory.jpg" width="240" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><i>An additional "Category" column can be added in the browser view of the Calendar's Settings area.</i></span></td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
</div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Right, let’s crack on … create a page in your subsite to hold the year view. You’ll need a page that has a web part zone running the width of the page. Check the page in as a Shared Draft.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkvfzSSM-J_mPSQcOcBmI40hNRz6JTtXo417vuUowLIZXSkNvs6w2nM51WWIFQ7ndLQ5MkgSMpRRM0PmocSjDWDDRrGqRMjMf64OZLiou8-hg63wofEgLcDhObmtndSP3h_-Y1PAast8o/s1600/pic03_CreatePage.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="153" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkvfzSSM-J_mPSQcOcBmI40hNRz6JTtXo417vuUowLIZXSkNvs6w2nM51WWIFQ7ndLQ5MkgSMpRRM0PmocSjDWDDRrGqRMjMf64OZLiou8-hg63wofEgLcDhObmtndSP3h_-Y1PAast8o/s320/pic03_CreatePage.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><i>I create the page in the browser so I can be sure of getting the right layout quickly and easily.</i></span></td></tr>
</tbody></table>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Now you’ll need to switch to <b>SharePoint Designer</b> and open the page you just created. (You could create the page in <b>SPD</b>, but I find it easier and quicker to use the browser for that.) Select the Web Part Zone and then bring up the Calendar in the <b>Data Source Details</b> sidebar. You can drop in any column you feel like – we’re going to overwrite most of the presentation code anyhow.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXE-jWMG8q3l_SFbtrzAcgG4W8o2KNX9TbMlbyhK8H3TvWwcvjxhOxGKHoxZyu9N_Ozrgk55-2FnQbt_rYF1kTnjtCrOZmEJbh__D9uHwn1h7jwoCe6duGOMv4WqMxLqEjmK6WyZ_6UY4/s1600/pic04_InsertDVWP.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXE-jWMG8q3l_SFbtrzAcgG4W8o2KNX9TbMlbyhK8H3TvWwcvjxhOxGKHoxZyu9N_Ozrgk55-2FnQbt_rYF1kTnjtCrOZmEJbh__D9uHwn1h7jwoCe6duGOMv4WqMxLqEjmK6WyZ_6UY4/s320/pic04_InsertDVWP.jpg" width="221" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><i>It doesn't really matter what data you insert in the Data View Web Part. We'll be changing the code as we go along and build a completely different view.</i></span></td></tr>
</tbody></table>
<span style="font-family: "arial" , "helvetica" , sans-serif;">The Web Part you just added will look something like this.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTvO4oLiBD_UgrMXHoi1DFS5Lp_12XPAw4AIpX4ewCC8dBFCkOwLNRvFU6kS-MUJ6cVSYf55WcI74Bwgsc48tgD2wObJvGPJ5svJ-0s93MYgDPHtKHxRNMQwVLlp59-dfT9fbQGz8L_rU/s1600/pic05_DataFormWebPart.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="212" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTvO4oLiBD_UgrMXHoi1DFS5Lp_12XPAw4AIpX4ewCC8dBFCkOwLNRvFU6kS-MUJ6cVSYf55WcI74Bwgsc48tgD2wObJvGPJ5svJ-0s93MYgDPHtKHxRNMQwVLlp59-dfT9fbQGz8L_rU/s320/pic05_DataFormWebPart.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><i>Oh, how I love the "Common Data View Tasks" panel.</i></span></td></tr>
</tbody></table>
<span style="font-family: "arial" , "helvetica" , sans-serif;">There are some adjustments to be made in the <b>Common Data View Tasks</b> panel, so we might as well make them now. First, set the <b>Paging </b>to <b>Display All Items</b>. Then, in <b>Sort and Group</b>, make the <b>Sort Order</b> “Start Time” and “Ascending”. This latter one will be needed so that events on the same day appear in time order.</span><br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhptOYF2IRhwBiOgZiF3QzPMWmQjucxinlMVBo5iP3NiRfAvD-QIRBx-fVp4omr9tt0WoV_NRda_u2ylzZld0hasvTrhHjVW0PtPk_gyIshEhU7HTTgyQcUNjwLF1wWGcLVtMVcGLdE_pY/s1600/pic06_ListOrder.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="175" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhptOYF2IRhwBiOgZiF3QzPMWmQjucxinlMVBo5iP3NiRfAvD-QIRBx-fVp4omr9tt0WoV_NRda_u2ylzZld0hasvTrhHjVW0PtPk_gyIshEhU7HTTgyQcUNjwLF1wWGcLVtMVcGLdE_pY/s320/pic06_ListOrder.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><i>Use this control panel to determine the order in which events appear in each day cell. This is important as, left to their own devices, events will appear in the order they were entered in the calendar (ie in order of ID).</i></span></td></tr>
</tbody></table>
<span style="font-family: "arial" , "helvetica" , sans-serif;">At this point you might want to <a href="http://blog.pathtosharepoint.com/2010/04/06/tutorial-add-color-coding-to-your-sharepoint-2007-calendar-in-15-minutes/">review Christophe Humbert’s article on adding colour coding</a> to a SharePoint 2007 calendar on his Path to SharePoint site. It only takes fifteen minutes and it will keep your monthly calendar view consistent with the Year View we’re building here. Indeed, this Year View uses some of Christophe’s techniques, so credit is due to M. Humbert for that. </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Once you’re done with that, switch back to SP Designer and locate the line:</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<code><xsl:variable name="dvt_1_automode">0</xsl:variable></code><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Directly below, type the following:</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:param name="Today" /></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">We’ll be using that variable further along. The next thing to do is to add the XSL code that will render the months and the days of the month. This was especially tricky, and most of the heavy lifting here was done by my friend Steve M. who is a Jedi Master when it comes to all kinds of code. So first the <b>Months </b>template, which is added below the <b>dvt_1</b> template. (We’ll be ripping out the <b>dvt_1</b> template in a moment, so don’t worry about it too much.) Here’s the code to add:</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:template name="Months"></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:param name="MonthNo" /></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <tr></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:choose></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:when test="$MonthNo= 0"></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <th width="32px" style="border:1px solid #666666; height=30px;background-color:#009fe3;color:#ffffff;">Month</th></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:when></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:otherwise></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <td width="32px" class="ms-vb" style="border:1px solid #666666; height=30px;background-color:#009fe3;color:#ffffff;"><strong></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:choose></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:when test="$MonthNo= 1">Jan</xsl:when></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:when test="$MonthNo= 2">Feb</xsl:when></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:when test="$MonthNo= 3">Mar</xsl:when></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:when test="$MonthNo= 4">Apr</xsl:when></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:when test="$MonthNo= 5">May</xsl:when></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:when test="$MonthNo= 6">Jun</xsl:when></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:when test="$MonthNo= 7">Jul</xsl:when></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:when test="$MonthNo= 8">Aug</xsl:when></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:when test="$MonthNo= 9">Sep</xsl:when></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:when test="$MonthNo= 10">Oct</xsl:when></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:when test="$MonthNo= 11">Nov</xsl:when></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:when test="$MonthNo= 12">Dec</xsl:when></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:otherwise></xsl:otherwise></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:choose></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </strong></td></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:otherwise></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:choose></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:call-template name="Days"></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:with-param name="MonthNo" select="$MonthNo" /></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:with-param name="DayNo" select="1" /></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:call-template></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </tr></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:if test="$MonthNo &lt; 12"></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:call-template name="Months"></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:with-param name="MonthNo" select="$MonthNo +1" /></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:call-template></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:if></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"></xsl:template></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">All we’re doing here is writing the first column of the table to iterate the names of the months downwards. For the sake of clarity, it’s best to convert the SharePoint data, which holds the value of the month as a number, into the name of the month.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Next, we need to write the days across the page as columns. So add this template code directly beneath the <b>Months </b>template:</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:template name="Days"></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:param name="MonthNo" /></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:param name="DayNo" /></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:variable name="Year" select="substring-before($Today, '-')" /></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:variable name="isLeapYear"></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:choose></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:when test="($Year mod 4 = 0 and $Year mod 100 != 0) or $Year mod 400 = 0">True</xsl:when></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:otherwise>False</xsl:otherwise></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:choose></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:variable></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:variable name="Month"></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:choose></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:when test="$MonthNo &lt; 10">0<xsl:value-of select="$MonthNo" /></xsl:when></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:otherwise><xsl:value-of select="$MonthNo" /></xsl:otherwise></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:choose></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:variable></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:variable name="Day"></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:choose></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:when test="$DayNo &lt; 10">0<xsl:value-of select="$DayNo " /></xsl:when></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:otherwise><xsl:value-of select="$DayNo " /></xsl:otherwise></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:choose></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:variable></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:variable name="backColor"></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:choose></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:when test="contains(' 4 6 9 11 ', concat(' ', $MonthNo, ' ')) and $DayNo = 31">gray</xsl:when></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:when test="$MonthNo = 2 and ($DayNo &gt;= 30 or ($isLeapYear = 'False' and $DayNo = 29))">gray</xsl:when></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:otherwise></xsl:otherwise></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:choose></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:variable></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:variable name="thisDay" select="concat($Year, '-', $Month, '-', $Day)" /></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row[substring-before(@EventDate, 'T') = $thisDay]"/></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:choose></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:when test="$MonthNo = 0"></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <th width="32px" style="border:1px solid #666666; height=30px;background-color:#83d0f5;"><xsl:value-of select="$DayNo" /></th></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:when></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:otherwise></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <td class="ms-vb" width="32px" style="border:1px solid #666666; height=30px;"></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:attribute name="bgcolor"><xsl:value-of select="$backColor" /></xsl:attribute></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:choose></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:when test="count($Rows) &gt; 0"></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:for-each select="$Rows"></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:call-template name="rowview" /></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:for-each></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:when></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:otherwise></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:text /></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:otherwise></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:choose></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </td></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:otherwise></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:choose></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:if test="$DayNo &lt; 31"></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:call-template name="Days"></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:with-param name="MonthNo" select="$MonthNo" /></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:with-param name="DayNo" select="$DayNo +1" /></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:call-template></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:if></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"></xsl:template></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">So the first section is testing for a Leap Year. Obviously, we need to know how many days February has in the current year.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">The next two sections are placing a zero in front of any single digit Month or Day.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">The following section beginning with variable name=”backColour” is determining which months have less than 31 days and setting a background colour for the excess days.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Then the next section is rendering the rows and applying the background colour to the “non-existent” days (for example days 30 and 31 in Feb, 31 in April and so on) … and calling the <b>rowview </b>template. So we’ll need to add that right after this.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:template name="Days"></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:param name="MonthNo" /></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:param name="DayNo" /> </span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:variable name="Year" select="substring-before($Today, '-')" /></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:variable name="isLeapYear"></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:choose></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:when test="($Year mod 4 = 0 and $Year mod 100 != 0) or $Year mod 400 = 0">True</xsl:when></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:otherwise>False</xsl:otherwise></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:choose></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:variable></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:variable name="Month"></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:choose></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:when test="$MonthNo &lt; 10">0<xsl:value-of select="$MonthNo" /></xsl:when></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:otherwise><xsl:value-of select="$MonthNo" /></xsl:otherwise></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:choose></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:variable></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:variable name="Day"></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:choose></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:when test="$DayNo &lt; 10">0<xsl:value-of select="$DayNo " /></xsl:when></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:otherwise><xsl:value-of select="$DayNo " /></xsl:otherwise></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:choose></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:variable></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:variable name="backColor"></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:choose></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:when test="contains(' 4 6 9 11 ', concat(' ', $MonthNo, ' ')) and $DayNo = 31">gray</xsl:when></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:when test="$MonthNo = 2 and ($DayNo &gt;= 30 or ($isLeapYear = 'False' and $DayNo = 29))">gray</xsl:when></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:otherwise></xsl:otherwise></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:choose></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:variable></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:variable name="thisDay" select="concat($Year, '-', $Month, '-', $Day)" /></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row[substring-before(@EventDate, 'T') = $thisDay]"/></span><br />
<span class="Apple-tab-span" style="white-space: pre;"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </span></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:choose></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:when test="$MonthNo = 0"></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <th width="32px" style="border:1px solid #666666; height=30px;background-color:#83d0f5;"><xsl:value-of select="$DayNo" /></th></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:when></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:otherwise></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <td class="ms-vb" width="32px" style="border:1px solid #666666; height=30px;"></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:attribute name="bgcolor"><xsl:value-of select="$backColor" /></xsl:attribute></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:choose></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:when test="count($Rows) &gt; 0"></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:for-each select="$Rows"></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:call-template name="rowview" /></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:for-each></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:when></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:otherwise></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:text /></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:otherwise></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:choose></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </td></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:otherwise></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:choose></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:if test="$DayNo &lt; 31"></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:call-template name="Days"></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:with-param name="MonthNo" select="$MonthNo" /></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:with-param name="DayNo" select="$DayNo +1" /></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:call-template></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </xsl:if></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"></xsl:template></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">So, now we add the <b>rowview </b>template. This will render the events into the appropriate table cells, and apply colour.</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span style="white-space: pre;"><xsl:template name="rowview">
<xsl:variable name="color">
<xsl:choose>
<xsl:when test="@Category = 'Boards'">Blue</xsl:when>
<xsl:when test="@Category = 'Formal Committees'">HotPink</xsl:when>
<xsl:when test="@Category = 'Divisional Boards'">Purple</xsl:when>
<xsl:when test="@Category = 'Proposed Trips'">Red</xsl:when>
<xsl:when test="@Category = 'Visits'">Green</xsl:when>
<xsl:when test="@Category = 'Group Committees/Boards'">Indigo</xsl:when>
<xsl:when test="@Category = 'Public Holiday'">Grey</xsl:when>
<xsl:when test="@Category = 'Group'">Brown</xsl:when>
<xsl:when test="@Category = 'Other'">Darkorange</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="EventDate" select="(number(ddwrt:DateTimeTick(ddwrt:GenDisplayName(string(@EventDate))))) div 864000000000" />
<xsl:variable name="EndDate" select="(number(ddwrt:DateTimeTick(ddwrt:GenDisplayName(string(@EndDate))))) div 864000000000" />
<xsl:variable name="width">
<xsl:choose>
<xsl:when test="$EndDate - $EventDate = 1">143%</xsl:when>
<xsl:when test="$EndDate - $EventDate = 2">178%</xsl:when>
<xsl:when test="$EndDate - $EventDate = 3">217%</xsl:when>
<xsl:when test="$EndDate - $EventDate = 4">232%</xsl:when>
<xsl:otherwise>95%</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<a href="http://yourintranet/departments/management/Lists/Main%20Boards%20%20Committees/DispForm.aspx?ID={@ID}&amp;Source=http://yourintranet/departments/management/Pages/BoardsCommitteesYearView.aspx">
<span style="position:relative;display:inline-block;width:{$width};">
<span style="display:inline-block;width:100%;cursor:pointer;text-align:center;border:1px solid {$color};position:absolute;color:{$color};"><xsl:value-of select="@Title" /></span>
<span style="display:inline-block;width:100%;background-color:{$color};text-align:center;border:1px solid;z-index:-1;filter:alpha(opacity=30);opacity:0.3;"><xsl:value-of select="@Title" /></span>
</span>
</a><br />
</xsl:template></span></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">This is where I’ve swiped some of Christophe’s code to render the different categories of events in different colours, using it to set a variable, color. </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Then from <a href="http://www.nothingbutsharepoint.com/2013/01/09/calculate-days-between-two-sharepoint-list-dates-in-xsl-using-ddwrtdatetimetick-aspx/">Marc D Anderson’s blog</a>, I swiped a bit of XSLT arithmetic and used it to check whether an event is more than one day. This bit gave me a bit of a problem, until I realised that a one day event gives a value of 0, a two day event returns 1, a three day event gives 2 and so on. I was then able to set the width of multiple day events accordingly, using a “width” variable.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>NOTE:</b> This is completely different to how SharePoint renders events in the Calendar’s Month View. To be honest, it’s a bit of a clumsy work-around. But the thought of trying to follow how the out-of-the-box month view works was more than a bit scary. You may have a better way of doing this, and if you do, feel free to share it. But this was the best I could manage.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">The final section renders the actual event in the table cell and applies the colour. I freely admit I couldn’t done this without Christophe’s and Marc's excellent work.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">We still have a couple of things to do to get this all to work. So next, remove all the XLST code that the SharePoint Designer wizard dropped in. That means delete the <b>dvt_body</b> template and the <b>dvt_1.rowview</b> template, then go back to the top and replace the two sections:</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:template match …></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">… and the <b>dvt_1</b> template with this code.</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span style="white-space: pre;"><xsl:template match="/"
xmlns:x="http://www.w3.org/2001/XMLSchema"
xmlns:d="http://schemas.microsoft.com/sharepoint/dsp"
xmlns:asp="http://schemas.microsoft.com/ASPNET/20"
xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer"
xmlns:SharePoint="Microsoft.SharePoint.WebControls">
<table width="100%" cellpadding="2" cellspacing="0" style="border:1px solid #666666;border-collapse: collapse;">
<xsl:call-template name="Months">
<xsl:with-param name="MonthNo" select="0" />
</xsl:call-template>
<xsl:choose>
<xsl:when test="ddwrt:IfHasRights(2)">
<tr>
<td class="ms-addnew" style="padding: 4px" colspan="99"><img src="/_layouts/images/rect.gif" /> <a class="ms-addnew" ID="idHomePageNewEvent" href="/departments/management/Lists/Main%20Boards%20%20Committees/NewForm.aspx?Source=http://yourintranet/departments/management/Lists/Main%20Boards%20%20Committees/calendar.aspx" onclick="javascript:NewItem('/departments/management/Lists/Main%20Boards%20%20Committees/NewForm.aspx?Source=http://yourintranet/departments/management/Lists/Main%20Boards%20%20Committees/calendar.aspx', true);javascript:return false;" target="_self"> Add new meeting</a></td>
</tr>
</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</table>
</xsl:template></span></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">This is what pulls the whole thing together. I also added a text link at the bottom of the table to allow Site Editors to add new events without having to go the whole <b>Site Actions</b> > <b>View All Site Content</b> route.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Admittedly, this may not be the most elegant solution. But I still haven’t been able to find an alternative approach by searching the Internet. </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">My least favourite aspect of this solution is how a multiple day event will simply overlay any first event in any of the other days in the date range. I wasn’t able to find a way of getting the overlaid event to sit below the multiple day event.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLdk1lRmc6JZX-RIbJADvIDo2SKJM2pBjOr-1lmhDx0YvMbzo4fYPC44p1MEkOQXv6EJdE4VdHgx6HuD7QbnRWEw3GO8rlIkDt1T2CTjWFzx8yUs5JstdftPTUI7nO5fnOiHTtKsbnirI/s1600/pic08_Overlay.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="198" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLdk1lRmc6JZX-RIbJADvIDo2SKJM2pBjOr-1lmhDx0YvMbzo4fYPC44p1MEkOQXv6EJdE4VdHgx6HuD7QbnRWEw3GO8rlIkDt1T2CTjWFzx8yUs5JstdftPTUI7nO5fnOiHTtKsbnirI/s320/pic08_Overlay.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><i>In this case, the green event (a three-dayer) is overlaid on top of the event that is scheduled for the second day, making for an ugly display.</i></span></td></tr>
</tbody></table>
<span style="font-family: "arial" , "helvetica" , sans-serif;">All I could do was input the multiple day events into the calendar as a series of single day events so that everything would display correctly.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgz3KAofR2EDnHdKKt0vWc7ppDEMgEb70ut-yovWlqKUEBLusYdRe7u7An_azSwpsSn5NL13TVN6MpKR69lfXZfUqRbgkDlijxZ47vwrDuDA6sW62jhKYJ4ATVX51gjm7kvtxlWMKu8SlQ/s1600/pic09_OverlayFix.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="197" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgz3KAofR2EDnHdKKt0vWc7ppDEMgEb70ut-yovWlqKUEBLusYdRe7u7An_azSwpsSn5NL13TVN6MpKR69lfXZfUqRbgkDlijxZ47vwrDuDA6sW62jhKYJ4ATVX51gjm7kvtxlWMKu8SlQ/s320/pic09_OverlayFix.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><i>The only workaround I could think of was to split the three-day event into two separate sections, forcing the event on the second day to sit below the three day event. It's not great, but it's better than what I first had.</i></span></td></tr>
</tbody></table>
<span style="font-family: "arial" , "helvetica" , sans-serif;">If you’re able to offer any improvements of a better way of doing any of the above, not just the imperfect display of events, then it would be great if you could share by leaving a comment below.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">I hope this helps someone.</span><br />
<div>
<br /></div>
AirPiratePresshttp://www.blogger.com/profile/13136561512898563240noreply@blogger.com8tag:blogger.com,1999:blog-3023476837266527744.post-74420250186972083042015-12-08T01:03:00.000-08:002017-05-10T11:48:24.373-07:00Render SharePoint list headers in the order you want<span style="font-family: "arial" , "helvetica" , sans-serif;">When it comes to presenting the contents of a SharePoint list in a Data View Web Part (Data Form Web Part), your out-of-the-box options </span><span style="font-family: "arial" , "helvetica" , sans-serif;">are a bit limited. It's certainly possible to group list items under headings, but SharePoint relentlessly displays these headings in </span><span style="font-family: "arial" , "helvetica" , sans-serif;">alphabetical (or reverse alphabetical) order. This can be a bit frustrating if you had some other order in mind.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">For example, I was planning to display a list of navigational links on a page. I had stored the link data in a list, and I'd even added a </span><span style="font-family: "arial" , "helvetica" , sans-serif;">custom column to the list to contain the group headings and tagged all my links with a group value.</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiM8XSIsm9n9r5TcuKP-Pc3a-Xz-Z4aRvtCECzNyYars_82hxVf9Mif-hxn-W8a3D4sogD1vg96U7D6x6Rv5c4xQAIIqGHqhKt4CVJMx9bt9Kg0WHOO5NwMImrhILLDWjBIIU8i5o4P5cA/s1600/pic03_HeaderValues.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiM8XSIsm9n9r5TcuKP-Pc3a-Xz-Z4aRvtCECzNyYars_82hxVf9Mif-hxn-W8a3D4sogD1vg96U7D6x6Rv5c4xQAIIqGHqhKt4CVJMx9bt9Kg0WHOO5NwMImrhILLDWjBIIU8i5o4P5cA/s1600/pic03_HeaderValues.jpg" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">But when I switched to SharePoint Designer and created the DVWP, and I selected <strong>Show group header</strong> under <strong>Sort and Group</strong> ... </span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHJ1H7H7bY-x0V3jDBWeALrYrp1bvFSGyPoZLjplp39HNSfMT38Lv5QVSreT2RkpUfCRynSobkAP-Wwm-dePC3VWztVS-Khejeg1DzIGjSVSIOptFgo2N7H4hpAs0R7_qUukf06LpNpHI/s1600/pic05_ShowGroupHeader.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="175" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHJ1H7H7bY-x0V3jDBWeALrYrp1bvFSGyPoZLjplp39HNSfMT38Lv5QVSreT2RkpUfCRynSobkAP-Wwm-dePC3VWztVS-Khejeg1DzIGjSVSIOptFgo2N7H4hpAs0R7_qUukf06LpNpHI/s320/pic05_ShowGroupHeader.jpg" width="320" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><span id="goog_60795793"></span><span id="goog_60795794"></span></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">... SharePoint helpfully displayed the headers in alphabetical order!</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg48kQX-jafUioGjeF5PYm_Lyy6zHNCjtSCyr5FmSwZiqtyXgjok_jApy-ydVJyPuOMfKTY85n01enk9bd75iMM9HEaqQzJu7lf2Wo2yAKOUC2XmY-QzFKbUVhaeQjHWcgLR-GDJMoTlJ8/s1600/pic10_SPlist-alpha.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg48kQX-jafUioGjeF5PYm_Lyy6zHNCjtSCyr5FmSwZiqtyXgjok_jApy-ydVJyPuOMfKTY85n01enk9bd75iMM9HEaqQzJu7lf2Wo2yAKOUC2XmY-QzFKbUVhaeQjHWcgLR-GDJMoTlJ8/s1600/pic10_SPlist-alpha.jpg" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">What I really wanted was for the headings to display in a different order. I thought about finding ways to create headings where the order of </span><span style="font-family: "arial" , "helvetica" , sans-serif;">importance would also be alphabetical order, but that proved far too difficult and awkward. So I resolved to figure out another way to manage </span><span style="font-family: "arial" , "helvetica" , sans-serif;">the order of the headings.</span><br />
<br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">I wanted "Head Office" as the first heading, followed by "UK Locations", then "Europe", then "Rest of the World". The </span><span style="font-family: "arial" , "helvetica" , sans-serif;">only way I could think of to do this was to preface each heading with a number value (to force the order) then, in the web part, </span><span style="font-family: "arial" , "helvetica" , sans-serif;">perhaps use the "substring" function to remove the numerical value from the beginning of each header.</span><br />
<span style="font-family: "arial";"></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXacFlO_tc70TTM1Jfss3ZS1iHB6M85Czp8lp3pAZGwQHgVc46K1CH5h79myF43zND_X5F2eTO7JggHqCHQMAZgEx53yXURCtwYEnCChyphenhyphencVA-4I7MvWN4OJJ2wGfer5bzyJptz2NxUN_M/s1600/pic03a_HeaderValues.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXacFlO_tc70TTM1Jfss3ZS1iHB6M85Czp8lp3pAZGwQHgVc46K1CH5h79myF43zND_X5F2eTO7JggHqCHQMAZgEx53yXURCtwYEnCChyphenhyphencVA-4I7MvWN4OJJ2wGfer5bzyJptz2NxUN_M/s1600/pic03a_HeaderValues.jpg" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">So ... in SharePoint Designer, add your DVWP to the page.</span><br />
<span style="font-family: "arial";"></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">Then use the <strong>Common Data View Tasks</strong> panel to arrange the list output under headers by clicking on <strong>Sort and Group</strong> and selecting the radio button next to <strong>Show group header</strong>. This displays the headers in alphabetical order as noted earlier, but this time, we can see the number prefixes I placed at the beginning of each header value.</span><br />
<span style="font-family: "arial";"></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhte5rCK0DkCwG6Bk8BAmCIo-w7zlOo7SRchkaniPwVmNOhgSHc8ir7ZztIWcbFu5DRSjQNUSG0ayHO_KImqEh0uvGZg5UBHcv5MGdtKThos26QLVTWHYouWrAzPiRcNWGfPbnMP3BZd3E/s1600/pic10_SPlist-ordered.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhte5rCK0DkCwG6Bk8BAmCIo-w7zlOo7SRchkaniPwVmNOhgSHc8ir7ZztIWcbFu5DRSjQNUSG0ayHO_KImqEh0uvGZg5UBHcv5MGdtKThos26QLVTWHYouWrAzPiRcNWGfPbnMP3BZd3E/s1600/pic10_SPlist-ordered.jpg" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">To get rid of the number prefixes, we're going to use the substring function.</span><br />
<span style="font-family: "arial";"></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">In SharePoint Designer, navigate to the DVWP and find the XSLT call that renders the header name. It should include the variable "$fieldvalue". It'll be towards the end of the DVWP code, and look like this:</span><br />
<br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: xx-small;"><xsl:value-of select="$fieldvalue" /></span><br />
<br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">In my version, I added a <strong> tag and, as I wanted my headers to be rendered in blue, I added a color attribute, like this:</span><br />
<br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><span style="font-family: "courier new" , "courier" , monospace; font-size: xx-small;"><strong style="COLOR: #009ae4;"><xsl:value-of select="$fieldvalue" /></strong></span><span style="font-family: "courier new" , "courier" , monospace;"></span></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">Then, to remove the number prefix, I changed the "$fieldvalue" call to look like this:</span><br />
<br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: xx-small;"><strong style="COLOR: #009ae4;"><xsl:value-of select="substring($fieldvalue, 3)" /></strong></span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlGJBKlHZOVJuyGJsvTQn0PY5enCI0JxvYkaTIEEsEO32qwnm7jcAp5ms7wyeqBh7KxSAfNusfmVHYhfWGOcSuu9PyQqNfxslIXpgfq0b0hQa3o5fl10xUI7fH1Wxb1ixOVxYx567vIn8/s1600/pic06_RemoveOpeningCharacters.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="123" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlGJBKlHZOVJuyGJsvTQn0PY5enCI0JxvYkaTIEEsEO32qwnm7jcAp5ms7wyeqBh7KxSAfNusfmVHYhfWGOcSuu9PyQqNfxslIXpgfq0b0hQa3o5fl10xUI7fH1Wxb1ixOVxYx567vIn8/s320/pic06_RemoveOpeningCharacters.jpg" width="320" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">The substring function here specifies the character to begin rendering the string, in this case, the third one. The result is that my headers still appear in the order specified by the number prefixes in the List but those number prefixes are invisible.</span><br />
<span style="font-family: "arial";"></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJIUB40bUBPL_1gjNeonV5kTcNSx9jWnuN0p9tWQ-H3bZVUhr2EoIz3hNN_JCYi93XYoVYW8m-Yc8T3bJV8PMVARIYYrpY_s8mH-f0jX_fx4hlunV-qK0wIzJpNiEgS83BW9fSzjs0S7o/s1600/pic10_SPlist-unordered.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJIUB40bUBPL_1gjNeonV5kTcNSx9jWnuN0p9tWQ-H3bZVUhr2EoIz3hNN_JCYi93XYoVYW8m-Yc8T3bJV8PMVARIYYrpY_s8mH-f0jX_fx4hlunV-qK0wIzJpNiEgS83BW9fSzjs0S7o/s1600/pic10_SPlist-unordered.jpg" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<span style="font-family: "arial";"></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">Hope this helps someone.</span>AirPiratePresshttp://www.blogger.com/profile/13136561512898563240noreply@blogger.com0tag:blogger.com,1999:blog-3023476837266527744.post-16176177732132180962015-11-10T13:58:00.000-08:002017-05-02T05:40:45.962-07:00Display multiple random list items in Dataview Web Part<span style="font-family: "arial" , "helvetica" , sans-serif;">I always like to configure our corporate Intranet to minimise the amount of admin work that needs to be done. One way to keep content looking fresh with minimum manual updating is to put all your text into a SharePoint list, then present it on the page using a Data View Web Part, with an added bit of XSLT scripting to show a random item from the list.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">I didn't have much trouble finding a bit of scripting (via Google) to achieve this effect. I ran in to difficulties when I wanted to take this one step further and present <i>several</i> random items from a SharePoint list. However hard I Googled, I just couldn't turn up comprehensive, step-by-step instructions on how to display more than one random item.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">The solution turned out to be a combination of two different methods, that I'd picked up in two different locations. As always, as I couldn't find the total solution by Googling alone, I'll explain how to display a number of random items from a list here.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">First things first: set up a list. In my case, I wanted to display a set of four large buttons that users can click on to be taken to content in the sub-sites below the top level of the Intranet. So to have a reasonable selection of buttons to choose from, I specified at least eight for each landing page. These were stored in a document library.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">As a document library is a just a flavour of list, I decided to keep things simple by using the library to double for the list and added my metadata in extra columns in the Document Library.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">So I used the <i>Title </i>field to store the text equivalent (alt attribute) for the button image. Then I added a custom column to hold the destination URL. You <i>could</i> use a <i>Hyperlink</i>-type content type, but I just opted for a <i>Single line of text</i>, to keep things simple. I also added an extra column to hold the value for the tab page the buttons would be appearing on, set up as a <i>Choice</i>.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Then I uploaded all the button images and made sure the metadata was completed correctly.</span><br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhe-bVbRfn7HF8-fqA85MXClnrBkV7Um-aUH0D4qcAD-qcRDFhHa-bcq0CNeZffR6h7uP34-Pt-Qd3kcAPqkOVIse_do3_jYgu9ubP78-OC_5k77ses-W7-5qoosrLKjfgVHh1Qg7xGKJQ/s1600/pic01_List.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="162" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhe-bVbRfn7HF8-fqA85MXClnrBkV7Um-aUH0D4qcAD-qcRDFhHa-bcq0CNeZffR6h7uP34-Pt-Qd3kcAPqkOVIse_do3_jYgu9ubP78-OC_5k77ses-W7-5qoosrLKjfgVHh1Qg7xGKJQ/s320/pic01_List.JPG" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td class="tr-caption" style="font-size: 12.8px;"><i style="font-family: arial, helvetica, sans-serif; font-size: 12.8px;">This is what my Document library looks like when populated with my image buttons.</i></td></tr>
</tbody></table>
</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">My next task was to create the DVWP on the tab page to display the four buttons. You almost certainly already know how to do this, so I won't waste your time here. But just in case you are struggling, here's <a href="http://www.nothingbutsharepoint.com/2009/05/12/data-view-web-part-the-basics-insert-a-dvwp-on-your-page-aspx/">a site that shows you How to insert a DVWP</a>. </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">The next step might not apply to you, but I was looking to manage a button set for each of my main tab pages on our Intranet. So once I had the Dataview Web Part on the page, I needed to filter out the irrelevant buttons. </span><br />
<br />
<table align="center" border="0" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiY3O1DmZDHmYsjHfnlXPKk5xh7G5bXaezgEHot_nFDKaWgmSqx9GhO1GAed8xIct9e4cW25gIcouvXHceYT09SLz6fSvQevrfwIo5DOBkgRrJ_pHsx98vZKjT8BAKx057gI-Dq5X21oN4/s1600/pic02_Wizard.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="285" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiY3O1DmZDHmYsjHfnlXPKk5xh7G5bXaezgEHot_nFDKaWgmSqx9GhO1GAed8xIct9e4cW25gIcouvXHceYT09SLz6fSvQevrfwIo5DOBkgRrJ_pHsx98vZKjT8BAKx057gI-Dq5X21oN4/s320/pic02_Wizard.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><i>In SharePoint Designer, there's a wizard that allows you to Filter, sort and set the number of items displayed.</i></span></td></tr>
</tbody></table>
<span style="font-family: "arial" , "helvetica" , sans-serif;">As I'd already set up a column to hold the name of the tab my button were going to appear on, I just had to click on <i>Filter </i>and set up a criterion for the tab I was working on, in this case "Community".</span><br />
<br />
<table align="center" border="0" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8OYDoTwamYtttXd_k3b6WqPRnIpeTQL-GMVBVApwDa41vdO4xZD2RfQaKAfp8Sm6WmYJG7QdbZ5kZO53cCfMmh0EUu34iS85VxdZjPOES0b6yOORHvpQ65GHbxo-IQViJxa-uufR2OE4/s1600/pic03_Filter.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="193" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8OYDoTwamYtttXd_k3b6WqPRnIpeTQL-GMVBVApwDa41vdO4xZD2RfQaKAfp8Sm6WmYJG7QdbZ5kZO53cCfMmh0EUu34iS85VxdZjPOES0b6yOORHvpQ65GHbxo-IQViJxa-uufR2OE4/s320/pic03_Filter.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><i>This allows me to filter out all the buttons except for those tagged as "Community".</i></span></td></tr>
</tbody></table>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Before I did any more work in the wizard, I thought I'd tidy up the HTML of the web part.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">The raw DVWP tends to nest tables inside tables which can get messy and complex to work with. Some people prefer to replace the table elements with DIVs, and sometimes I might do that. But here, I thought I'd stick with a simplified table as I wanted to iterate across the row, rather than down the column. So first I removed the extra nested table.</span><br />
<br />
<table align="center" border="0" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnd8ncKDcTrtdJIuYLSozNxuF6ibgoLIe7KlIkqzx78GvvG5jmYkOIp-nzQUd7luTZD6PatZC2sTH-j244sch-qaNOgRmR03wnZ5gtZY0HFxUNzqYbWdguZnFtt57N4E0W9T33Oi9hCts/s1600/pic04_RemoveTable.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="165" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnd8ncKDcTrtdJIuYLSozNxuF6ibgoLIe7KlIkqzx78GvvG5jmYkOIp-nzQUd7luTZD6PatZC2sTH-j244sch-qaNOgRmR03wnZ5gtZY0HFxUNzqYbWdguZnFtt57N4E0W9T33Oi9hCts/s320/pic04_RemoveTable.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><i>Inside the "rowview" template, first take out the TR, TD and TABLE tags ...</i></span></td></tr>
</tbody></table>
<span style="font-family: "arial" , "helvetica" , sans-serif;">As soon as you do that, the corresponding closing tags are highlighted by SharePoint Designer for you.</span><br />
<br />
<table align="center" border="0" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOp5VSNoq3nB2ZoBa6SlaeUvQw5s8T0J57At_A69UCItNEyG0atVoN-prG4XMolZl5gCtOeVMkpj-HCnoc7VBggrkN2TqnSQjH0HbXcGOritTSlBkzaJOU2SQQzB7Co2IOPIdjikUzBl4/s1600/pic05_RemoveTable.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="165" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOp5VSNoq3nB2ZoBa6SlaeUvQw5s8T0J57At_A69UCItNEyG0atVoN-prG4XMolZl5gCtOeVMkpj-HCnoc7VBggrkN2TqnSQjH0HbXcGOritTSlBkzaJOU2SQQzB7Co2IOPIdjikUzBl4/s320/pic05_RemoveTable.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><i>... SharePoint Designer then highlights the closing tags for you, making them easy to find and delete.</i></span></td></tr>
</tbody></table>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Now, because I'd knocked out the nested table and I wanted to iterate <i>across</i> the row, I needed to put an opening and closing <TR> tag inside the main table of the DVWP. Like this:</span><br />
<br />
<table align="center" border="0" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixfnLlubW1vXfb9LU7Y4EmzqXoN4rrwm6a3Q_J2ZsZNoVibixK5GduJ7AZDFWdP_UzT6mDh5Q72vgGT0APMzeqqDN_4uUjYiQOFOlWtcD8aBiOyppiEKqQKM2eab9RDUt5GuHQhCYnTWg/s1600/pic06_RemoveTable.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="165" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixfnLlubW1vXfb9LU7Y4EmzqXoN4rrwm6a3Q_J2ZsZNoVibixK5GduJ7AZDFWdP_UzT6mDh5Q72vgGT0APMzeqqDN_4uUjYiQOFOlWtcD8aBiOyppiEKqQKM2eab9RDUt5GuHQhCYnTWg/s320/pic06_RemoveTable.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><i>Wrap the dvt_1_body template in TR tags.</i></span></td></tr>
</tbody></table>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Next, I wanted to remove the column that holds the List Column names. You can do this quickly by right-clicking on the column in the Design view and selecting <i>Delete</i>, then <i>Delete Columns</i> from the drop-down menu.</span><br />
<br />
<table align="center" border="0" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUpDCdmRwS2aLBxBdwbSTqIzBjekJjaDnaZqjinFaXO3ZlIYTqbDYCz6rsU5nD62T9EoMS16ehuSBoFTK7kaqlnIVtge_NtIyd0lgKWpu-6zjswWpI1cLbBBsuCwHW26_cVS6Sbkx5xhc/s1600/pic07_RemoveColumn.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="165" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUpDCdmRwS2aLBxBdwbSTqIzBjekJjaDnaZqjinFaXO3ZlIYTqbDYCz6rsU5nD62T9EoMS16ehuSBoFTK7kaqlnIVtge_NtIyd0lgKWpu-6zjswWpI1cLbBBsuCwHW26_cVS6Sbkx5xhc/s320/pic07_RemoveColumn.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><i>Deleting the table column is very simple.</i></span></td></tr>
</tbody></table>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Next I needed to remove the <TR> tags that render the items from the list down the column. Doing this will cause the items to render across the row, instead. You might want to remove the legacy width attributes while you're at it.</span><br />
<br />
<table align="center" border="0" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBgK5uvX4SKOiucB71lOnsDwRpNgdbUswzv93Nb1hf08H_3AP4lEm5MEvXlDoQ2ngGIPwSMWMtcT7apywlzOIE8xeBEREAGkIR3_H1q12HEe043grwYMRP_Ne0WXrOB4Z3_H9QQWofA3Q/s1600/pic08_RemoveTRs.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="165" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBgK5uvX4SKOiucB71lOnsDwRpNgdbUswzv93Nb1hf08H_3AP4lEm5MEvXlDoQ2ngGIPwSMWMtcT7apywlzOIE8xeBEREAGkIR3_H1q12HEe043grwYMRP_Ne0WXrOB4Z3_H9QQWofA3Q/s320/pic08_RemoveTRs.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><i>So I removed the unneeded TR tags ...</i></span></td></tr>
</tbody></table>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Next, I needed to get all the "value-of"s into a single table cell and discard the remainder, like this.</span><br />
<br />
<table align="center" border="0" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhidSnaOX10hFzvA5A1wuu0DXdVHS4iLDBLec4qWM3V0tGGP68dlVJgMDmRlsLOzzS97oEOuhCCVwnYQ8J09hQNjRek-CiWaOJQvElElozlh288JstYIccBiE3WZKfLCeRBJx6jCBIAXJ0/s1600/pic09_RemoveTDs.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="165" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhidSnaOX10hFzvA5A1wuu0DXdVHS4iLDBLec4qWM3V0tGGP68dlVJgMDmRlsLOzzS97oEOuhCCVwnYQ8J09hQNjRek-CiWaOJQvElElozlh288JstYIccBiE3WZKfLCeRBJx6jCBIAXJ0/s320/pic09_RemoveTDs.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><i>Re-arranging the value-of calls and eliminating the unwanted TD tags.</i></span></td></tr>
</tbody></table>
<span style="font-family: "arial" , "helvetica" , sans-serif;">My next job was to get the buttons to render across the row, and to have the ALT attribute inserted, and make each button a link to the relevant content I was highlighting. Rather than explain it, here's the final code ... you should be able to figure out what it's doing for yourself.</span><br />
<br />
<table align="center" border="0" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzKAyWjxl-6NWQ5u7xZd_-EXt_du1-kZJBD_zYgf-7GN9wbvBk9BnTqfPBgckf8kQH384ZYEt8sxkjvbRK8G5vCosokPV09zXeskcuvXawDa1O11mqJuET2ojp8aJf9VCluq_aXG6pSyA/s1600/pic10_FormatCell.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="119" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzKAyWjxl-6NWQ5u7xZd_-EXt_du1-kZJBD_zYgf-7GN9wbvBk9BnTqfPBgckf8kQH384ZYEt8sxkjvbRK8G5vCosokPV09zXeskcuvXawDa1O11mqJuET2ojp8aJf9VCluq_aXG6pSyA/s320/pic10_FormatCell.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><i>Here's the final code ...</i></span></td></tr>
</tbody></table>
<span style="font-family: "arial" , "helvetica" , sans-serif;">It's starting to take shape, now:</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrbrIr4LgjoY5aCO0EcoCKx3NBLA_-ksrHS3k02eByctoy1g6CzSNvzphlHR0jWHLVwHjS68dkwxkGrpvZpOmS7QvLjfrYk_ZDfhgVkhryOkujqYf8XixlmKLcgRj7te4kivm9TgsJDn8/s1600/pic11_FirstButton.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="165" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrbrIr4LgjoY5aCO0EcoCKx3NBLA_-ksrHS3k02eByctoy1g6CzSNvzphlHR0jWHLVwHjS68dkwxkGrpvZpOmS7QvLjfrYk_ZDfhgVkhryOkujqYf8XixlmKLcgRj7te4kivm9TgsJDn8/s320/pic11_FirstButton.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Next, I needed to go back to the Wizard and set the <i>Paging </i>to <i>Display All Items</i>.</span><br />
<br />
<table align="center" border="0" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjf9w7VgsWCl0-YuKp1iBdkJL_cBs0b4rZoT78gEpY1n1HCo6E_d-FFn-ea-sdrCoMV7jS6KjmaWkqvqTOp49JNtqqtEvgZ2tAewXySlxxCR9A99FTlKn2mOowFxc98dSqiGchbtdoGyE0/s1600/pic12_DisplayAll.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="165" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjf9w7VgsWCl0-YuKp1iBdkJL_cBs0b4rZoT78gEpY1n1HCo6E_d-FFn-ea-sdrCoMV7jS6KjmaWkqvqTOp49JNtqqtEvgZ2tAewXySlxxCR9A99FTlKn2mOowFxc98dSqiGchbtdoGyE0/s320/pic12_DisplayAll.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><i>Select Display all items ...</i></span></td></tr>
</tbody></table>
<span style="font-family: "arial" , "helvetica" , sans-serif;">At this point I was finally ready to apply the bits of XSLT scripting that would do the work of presenting four random items from the list, and would change each time a visitor came back to the page or refreshed.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">I'd already previously implemented DVWPs where the script selected <i>one </i>item at random from the list to display. Suitable techniques for this are not difficult to find on the Internet via Google search. I've come across several ways to do this. The one I've most commonly used is:</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:template name="dvt_1.body"></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:param name="Rows"/></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:variable name="Random" select="ddwrt:Random(1,count($Rows))" /></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span><xsl:for-each select="$Rows[position()=$Random]"></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span><xsl:call-template name="dvt_1.rowview" /></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span></xsl:for-each></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"></xsl:template></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">... but this only displays one random item from the list. My challenge was to get the DVWP to display four random items. I figured this would be made more difficult because I didn't want to any of the items to be repeated, which would be a possibility with a routine that selected four items randomly, one after another.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">But while digging around on Google, I came across several different ways of rendering a random item from a list and came to understand that I might have to combine two different methods to get the effect I wanted.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">In the end I settled for a</span><span style="font-family: "arial" , "helvetica" , sans-serif;"> slightly different way of rendering a random item that turned up in several different SharePoint blogs, but <a href="https://joeprakash.wordpress.com/2012/05/02/display-random-items-using-xslt-in-data-view-web-part/?contact-form-id=50&contact-form-sent=85024&_wpnonce=1499062278#contact-form-50">this is the one I came back to</a>. </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:for-each select="$Rows"></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:sort select="ddwrt:Random(1, $RowCount)" order="ascending"/></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> <xsl:call-template name="dvt_1.rowview" /></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"></xsl:for-each></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">What this is doing is sorting the items in the list into a random order and rendering the first one. It's a slightly different approach to the one I was using, but it does get me a step closer to where I want to be.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">I did get error messages with this saying that the variable wasn't defined, so I added in the line:</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:variable name="RowCount" select="count($Rows)" /></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">... before the </span><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:for-each= ...></span><span style="font-family: "arial" , "helvetica" , sans-serif;"> line and it seemed to work okay.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">All I had to do next was figure out how to select the first four items in this randomised list and I'd be there. I found <a href="http://www.dnnsoftware.com/forums/threadid/144228/scope/posts/limit-number-of-items-viewable-in-news-feed">something on another blog that selected the first x number of items from a list</a>, </span><span style="font-family: "arial" , "helvetica" , sans-serif;">so I figured I might be able to combine the two elements to get a randomised first four items ... I added the line:</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:if test="position() &lt; 5"></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">This is saying: display the row if the position is less than five (ie, four, then) ... so the "for-each" section should now look like this:</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:variable name="RowCount" select="count($Rows)" /></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><xsl:for-each select="$Rows"></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span><xsl:sort select="ddwrt:Random(1, $RowCount)" order="ascending" /></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span><xsl:if test="position()&lt;5"></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span><xsl:call-template name="dvt_1.rowview" /></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span></xsl:if></span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"></xsl:for-each></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Now the buttons will change randomly each time the user lands on the page for the first time, or indeed refreshes the page. The final effect looks like this:</span><br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiR4e5tb89IGh5PGti8ogsslAdmfkDkWBQDkEC_OmowRk5N_DT4XGD-tJhtAli_qFVhL6Kogg9qT1l4fU8xnFT_ZaPg0pOGAW-_BeXxBsbZhe9FWS7qIsnDE12okeBXp5w5wR1vsmbD2KE/s1600/pic13_final_z.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="172" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiR4e5tb89IGh5PGti8ogsslAdmfkDkWBQDkEC_OmowRk5N_DT4XGD-tJhtAli_qFVhL6Kogg9qT1l4fU8xnFT_ZaPg0pOGAW-_BeXxBsbZhe9FWS7qIsnDE12okeBXp5w5wR1vsmbD2KE/s320/pic13_final_z.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><table align="center" border="0" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td class="tr-caption" style="font-size: 12.8px;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><i>The images display randomly across the row.</i></span></td></tr>
</tbody></table>
</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
</div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Then it changes to this, when you refresh.</span><br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOc2w29GlSkte_nnsl0vz6K6YlSbrmbY2un__GD6vpDOyNjC5F5ZJ2cX5dtEamMK4BWjjJW2rABMQgBAxWmG1pTUply__gGcgKjJ4a9uX7qZNOhqFTeZYEJhRDPQb_qrhv5TtqTxLWJ4Q/s1600/pic14_final_z.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="172" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOc2w29GlSkte_nnsl0vz6K6YlSbrmbY2un__GD6vpDOyNjC5F5ZJ2cX5dtEamMK4BWjjJW2rABMQgBAxWmG1pTUply__gGcgKjJ4a9uX7qZNOhqFTeZYEJhRDPQb_qrhv5TtqTxLWJ4Q/s320/pic14_final_z.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><i style="font-family: arial, helvetica, sans-serif; font-size: 12.8px;">Hit refresh and another four images display.</i></td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
</div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">You can probably adapt this method to suit the set of random items you want to display.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Hope this helps someone.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>AirPiratePresshttp://www.blogger.com/profile/13136561512898563240noreply@blogger.com0tag:blogger.com,1999:blog-3023476837266527744.post-16794932894291781652015-03-26T09:58:00.002-07:002017-05-10T12:03:36.938-07:00Manage an email subscription list in SharePoint<span style="font-family: "arial" , "helvetica" , sans-serif;">I had a request from the Business about using a SharePoint teamsite to store an Excel email subscription list so that users could add and delete subscribers. It seemed to me that the requester was missing a trick, as SharePoint is capable of so much more than just storing documents and data. So I suggested that we transfer the Excel document data into a SharePoint list and use SharePoint's SMTP function to send out the email newsletter to the subscribers.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Most of it was quite easy. For example, it wasn't difficult to figure out that I'd need a teamsite containing two lists, one for the newsletter content and another for the subscribers.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">But I ran into a bit of a barrier when I tried to load the subscribers' addresses into the "To" field of the Workflow email, as these were people outside the Business without access to our Intranet. As usual when I have a tricky problem, I Googled for a solution, but that got me nowhere, so I braced myself to figure out an answer for myself.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<h3>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Subscribers list</span></h3>
<span style="font-family: "arial" , "helvetica" , sans-serif;">I set this one up first as I knew I'd need to call it as a lookup in the Newsletter Content list.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">It doesn't need to be complicated, but I included other information to help identify the subscriber's company and who in our organisation was their contact or sponsor, so the columns of this list looked like this:</span><br />
<ul>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">Title - with the default value of "Subscriber" (Single line of text)</span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">Company - so we know who they work for (Single line of text)</span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">Email - obviously (Single line of text)</span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">Position - so we know their job title (Single line of text)</span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">Underwriter - name of their sponsor/contact in our company (Single line of text)</span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">UWteam - name of the team the subscriber deals with (Choice)</span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">Owner - admin responsible for taking care of this subscriber's profile (Choice)</span></li>
</ul>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">I could have made the <i>Underwriter </i>field a <b>Name </b>field, but we had no plans to include this group of people on any communications, so I kept it simple. The <i>Team</i> and <i>Owner </i>fields are choices to minimise user error.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<h3>
<span style="font-family: "arial" , "helvetica" , sans-serif;">NewsletterFooter list</span></h3>
<span style="font-family: "arial" , "helvetica" , sans-serif;">My first thought was to hard code the email footer text into the Workflow email, but then I decided to include it in a separate (third) list so that if any of the info changed, the administrators of the list could edit the text. The columns were simply:</span><br />
<ul>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">Title - with a default value of "Edit details" (Single line of text)</span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">Address - just what it says (Single line of text)</span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">Phone - Phone numbers, fax and website URL (Single line of text)</span></li>
</ul>
<span style="font-family: "arial" , "helvetica" , sans-serif;">I did try to include the Disclaimer in here as well, but then remembered you can't do a look up on a Multiple Line field.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<h3>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Newsletter content list</span></h3>
<span style="font-family: "arial" , "helvetica" , sans-serif;">How many fields you put in this list depends entirely on what kind of newsletter you want to send out. I kept our one simple, with just a few columns:</span><br />
<ul>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">Title - used for the newsletter headline (Single line of text)</span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">Body - the main text goes here (Multiple lines of text)</span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">Link01 - to hold an embedded link (Hyperlink or Picture)</span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">Link02 - to hold an embedded link (Hyperlink or Picture)</span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">Link03 - to hold an embedded link (Hyperlink or Picture)</span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">Address - for the footer (Lookup)</span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">Phone - for the footer (Lookup)</span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">Disclaimer - for the footer (Multiple lines of text)</span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">Recipients - the subscribers (Lookup)</span></li>
</ul>
<span style="font-family: "arial" , "helvetica" , sans-serif;">So the Address and Phone fields lookup the data from the NewsletterFooter list. The Recipients column looks up the data from the Subscribers list and I ticked the Allow multiple values box.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">So far so good.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<h3>
<span style="font-family: "arial" , "helvetica" , sans-serif;">The Workflow email</span></h3>
<span style="font-family: "arial" , "helvetica" , sans-serif;">I figured I could use a Workflow Email function to mail out the newsletter. Shouldn't be difficult, right?</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">So using HTML and embedded CSS styles, I put together an email that would gather up the content from the list and compile it into a simple rich format email. As this was going to subscribers outside our company, I knew any imagery or attachments would have to be stored on an external server. None of this is difficult and is amply documented anywhere else.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">The snag came when I wanted to load the subscribers' email addresses in the "To" field of the email.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgskVPIO82WlS31ypr18072e-G_ghy_8D8df801cnuTSIXIuz7mRvdEoF2IoA_DSO-1O344BWm0tjKkHp1NgESKqr1OdVZf78B0Rvro7A6vO3faQTnG7zS_g63Iucag9lhPfkX8xVX7Hog/s1600/pic01_ToField.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="249" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgskVPIO82WlS31ypr18072e-G_ghy_8D8df801cnuTSIXIuz7mRvdEoF2IoA_DSO-1O344BWm0tjKkHp1NgESKqr1OdVZf78B0Rvro7A6vO3faQTnG7zS_g63Iucag9lhPfkX8xVX7Hog/s1600/pic01_ToField.jpg" width="320" /></a></div>
<br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">Trying to use a WorkFlow lookup on the "To" field resulted in not very many options. Certainly no Recipients field. I figured that this was because the Worklow Lookup was only accomodating Single line of text fields. I had to find another way. The trouble was, after an hour or two of Googling, I was no nearer to finding out how to get the subscriber email addresses into the "To" field.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">After sleeping on it, I wondered if I could use a variable to dump the text of the subscribers' emails in. So I set up a variable by clicking the <b>Variables </b>button.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjELz4sP_PN2NOb4d90TTfCzokYaSwfy1Ub0LWGJBstierbwTsVUa1oAb_kEl3Oo4y5dkWtIO_Kl-XDkJnbtC1WGz_mb9UWlIsEGjkYmIhNqP6JXbmO5PNhAHXs1Ke562C513_4RTqNzjk/s1600/pic02_Variable.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="249" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjELz4sP_PN2NOb4d90TTfCzokYaSwfy1Ub0LWGJBstierbwTsVUa1oAb_kEl3Oo4y5dkWtIO_Kl-XDkJnbtC1WGz_mb9UWlIsEGjkYmIhNqP6JXbmO5PNhAHXs1Ke562C513_4RTqNzjk/s1600/pic02_Variable.jpg" width="320" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">I gave the variable a name, "var_recip", and set its Type to string.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjm3Uv1E3IsCVHrLhelA5j2uGY0PlNfVxuXjfW8NycxJ7XuGyBzr1MzyMRqZDL6w3HEYItDHx8PJsCs2-zpG0PA5k-1R0pmj1aYeOJ2VUQYxBHaA6g5dnEEoHYS8PEaXZKML5oOK16VBSg/s1600/pic03_CreateVariable.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="249" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjm3Uv1E3IsCVHrLhelA5j2uGY0PlNfVxuXjfW8NycxJ7XuGyBzr1MzyMRqZDL6w3HEYItDHx8PJsCs2-zpG0PA5k-1R0pmj1aYeOJ2VUQYxBHaA6g5dnEEoHYS8PEaXZKML5oOK16VBSg/s1600/pic03_CreateVariable.jpg" width="320" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Next I had to populate the variable. You can do that by finding <b>Build a dynamic string</b> on the <b>Actions</b> dropdown. </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Then move this new action to sit above the Email action. </span><span style="font-family: "arial" , "helvetica" , sans-serif;">Next click on the text workflow variable, and select the <b>Variable: var_recip</b> option. The click on <b>dynamic string</b> to bring up the String Builder.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSGIfQsypB5EUofjZA3zZjc1W7aabAfTAvGsJgMAW-yUSQAm-4bXppn2J3gj72Q1MhSJBUBJ1ByqtUu4Mq3bmSwDoyX2ZdE5Ce9Qzp0-vERwQ2rSE-_26231fcmbTXvkB4X-aQPOC82Mk/s1600/pic03a_StringBuilder.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="249" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSGIfQsypB5EUofjZA3zZjc1W7aabAfTAvGsJgMAW-yUSQAm-4bXppn2J3gj72Q1MhSJBUBJ1ByqtUu4Mq3bmSwDoyX2ZdE5Ce9Qzp0-vERwQ2rSE-_26231fcmbTXvkB4X-aQPOC82Mk/s1600/pic03a_StringBuilder.jpg" width="320" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">In the String Builder, click on <b>Add Lookup</b>, then find <b>Recipients </b>in the drop down.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj65OwOxkGO_xgKC4nX3zQpnKOh-XA5UY3qwDyMFWJA17Sor40s3heZ062nV3O6IPFeP5U2uwsYWimoVwscjd2GSBpX_hWtnqkUBMGX9kLt_6zqsPHZ-OMZ2xY962r_jMhYhoff7dJGNq4/s1600/pic03b_StringBuilder.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="249" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj65OwOxkGO_xgKC4nX3zQpnKOh-XA5UY3qwDyMFWJA17Sor40s3heZ062nV3O6IPFeP5U2uwsYWimoVwscjd2GSBpX_hWtnqkUBMGX9kLt_6zqsPHZ-OMZ2xY962r_jMhYhoff7dJGNq4/s1600/pic03b_StringBuilder.jpg" width="320" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Click <b>OK</b>. Now click on <b>Variable </b>and select <b>Variable: var_recip</b>.</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUHoYhYliPt2NBtsY7Kc8sKC140rmoP0ascR05-eywFFHBGfSKGSR-0igOTmLo8UpDeLGbynHqU-U38DBpLvrVUukH7Xx7QvWCNqqXCFSaP4tqUWCDVBAnIQMQsUJGGlNPIALJTi6mAEk/s1600/pic03c_SelectVariable.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="249" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUHoYhYliPt2NBtsY7Kc8sKC140rmoP0ascR05-eywFFHBGfSKGSR-0igOTmLo8UpDeLGbynHqU-U38DBpLvrVUukH7Xx7QvWCNqqXCFSaP4tqUWCDVBAnIQMQsUJGGlNPIALJTi6mAEk/s1600/pic03c_SelectVariable.jpg" width="320" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">And that was pretty much it. You can test it by adding just your own email in the Newsletter's Recipients column. Maybe it was just too obvious for anyone to include in a blog ...</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<h3>
<span style="font-family: "arial" , "helvetica" , sans-serif;">How to put the subscribers' emails in the BCC</span></h3>
<span style="font-family: "arial" , "helvetica" , sans-serif;">The other thing was that I didn't really want to have the entire subscription list revealed in the "To" field of the email. It would be better to somehow include them in the BCC. Except that a Workflow doesn't have a BCC ... okay, that's not quite true. It does have a BCC, but you just can't see it.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">This one I was able to solve via Google. I found this anonymous post that explains how to hack the code and turn the CC field into a BCC field. [http://blog.summitcloud.com/2010/03/how-to-bcc-in-sharepoint-workflow-email/]</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">So, in SharePoint Designer, first add your <b>var_recip</b> variable to the CC field in the email, by clicking on the lookup icon next to the CC field (circled in red in the screengrab). Then select <b>Workflow Lookup</b> from the list or options. Click <b>Add </b>to bring up the <b>Define Workflow Lookup</b> dialogue box. Change <b>Source </b>to <b>Workflow Data</b>, and select <b>Variable: var_recip</b> in the <b>Field </b>window.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBWRGbTHjUg4_QfHsT1cipihnkDQr4zoQ28YtRlMd5Bt8oY_D38Hc-UYNsyu07WMm1FRPdhSEwnMs9PoXWL-12_bugvkwLbxvozrc3IxAcLvB_iUWZabL72wlUHbKGtUpyCiTD1mNgFME/s1600/pic04_CallVariable.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="249" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBWRGbTHjUg4_QfHsT1cipihnkDQr4zoQ28YtRlMd5Bt8oY_D38Hc-UYNsyu07WMm1FRPdhSEwnMs9PoXWL-12_bugvkwLbxvozrc3IxAcLvB_iUWZabL72wlUHbKGtUpyCiTD1mNgFME/s1600/pic04_CallVariable.jpg" width="320" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Click <b>OK</b>. Click <b>OK</b> again. And click <b>OK</b> again. Finally, click <b>Finish </b>to close the Workflow Designer window.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Now find the .xoml file in SharePoint Designer's left-hand navigation bar and right-click on it to reveal the drop-down menu. Select <b>Notepad </b>under the <b>Open With</b> option.</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeKJg4oWMycwltilZSaU8zFAQZkuGH5aGv1L2xX9oUhpoZH_Ho4mJ78LD0Ww8o-HPhSSHjIA5PZeuIR6GQ8oDrlGzTQ4qc1QVnb07VqUyQSyDWF50j6fdsp0MEETNO98g_eIRUTaAxRvk/s1600/pic08_OpenInNotepad.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="249" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeKJg4oWMycwltilZSaU8zFAQZkuGH5aGv1L2xX9oUhpoZH_Ho4mJ78LD0Ww8o-HPhSSHjIA5PZeuIR6GQ8oDrlGzTQ4qc1QVnb07VqUyQSyDWF50j6fdsp0MEETNO98g_eIRUTaAxRvk/s320/pic08_OpenInNotepad.jpg" width="320" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Now search the Notepad document for "BCC", then make the "BCC" text "CC", and the "CC" text "BCC".</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-u8npsVmUiHMHsdCCcCuqC5ssmSjL3X6a5xbZZRUZYm_ptrtJmYRaDo2ogSf3aMANo7rd3QqxyXRaXeaeJxdzQ5olCQK5z6bNo4m6INA4zDzTYdZxLwLTSYGu82tfx-6fhhW2K1F5omk/s1600/pic09_Notepad.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="205" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-u8npsVmUiHMHsdCCcCuqC5ssmSjL3X6a5xbZZRUZYm_ptrtJmYRaDo2ogSf3aMANo7rd3QqxyXRaXeaeJxdzQ5olCQK5z6bNo4m6INA4zDzTYdZxLwLTSYGu82tfx-6fhhW2K1F5omk/s320/pic09_Notepad.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>Save </b>the changes.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">That's it. If it's worked, your CC field should now be blank.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0WBel7lThgfSwrO8uMcvcDScr9rn2bLUiNoVjvhKVkn03w9IVh2M8QpWUyh6fAER7wJcmES5SaC4DYN_DO_3nh0F6Cb4wmqSPWA7c5NJZcuRKIY5HPVaYMkikBWUwg59KLtvcvNVri3w/s1600/pic09a_blankCC.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="249" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0WBel7lThgfSwrO8uMcvcDScr9rn2bLUiNoVjvhKVkn03w9IVh2M8QpWUyh6fAER7wJcmES5SaC4DYN_DO_3nh0F6Cb4wmqSPWA7c5NJZcuRKIY5HPVaYMkikBWUwg59KLtvcvNVri3w/s320/pic09a_blankCC.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Trigger the Workflow Email from the list back in the teamsite. My email looked like this ...</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoYbrhJ4SsawvEgLy6YRsScKySJ-ByFqxB0NcxAlrXOOtaXtJvkLgL2Ah7kPE-Vi17Bit4YNZyNZZy511X6GfUWm9uNxDGcas0lEYA36wtlJcYQOE_4ul2Qu79Jnz21GCNjGdKWhHg5T4/s1600/pic12_FinalEmail.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoYbrhJ4SsawvEgLy6YRsScKySJ-ByFqxB0NcxAlrXOOtaXtJvkLgL2Ah7kPE-Vi17Bit4YNZyNZZy511X6GfUWm9uNxDGcas0lEYA36wtlJcYQOE_4ul2Qu79Jnz21GCNjGdKWhHg5T4/s320/pic12_FinalEmail.jpg" width="271" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Hope that helps someone.</span>AirPiratePresshttp://www.blogger.com/profile/13136561512898563240noreply@blogger.com0tag:blogger.com,1999:blog-3023476837266527744.post-68163084288096773642014-08-12T09:02:00.001-07:002017-05-10T12:21:51.287-07:00Display a user's name in workflow email<span style="font-family: "arial" , "helvetica" , sans-serif;">I needed to create a List in SharePoint 2007 that would allow my colleagues in IT to track installations on staff PCs and laptops. I then wanted to be able to trigger an email to the staff member when the installation was completed, giving instructions on how and when to reboot their computers.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Obviously, a Workflow was the way to go, but I kept bumping my head against the problem of extracting the staff member's name from the "Name (with presence)" field in the SharePoint list. The Workflow was writing "domain\userID" instead of "Firstname Lastname". So I had a bit of a Google and came up with ... not very much. Others were obviously having the same problem - it seems to be a known issue with SP2007.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<a href="http://sharepoint.stackexchange.com/questions/46317/how-to-resolve-full-names-from-a-person-or-group-column-that-contains-multiple"><span style="font-family: "arial" , "helvetica" , sans-serif;">How to resolve full names from a Person or Group column</span></a><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<a href="http://social.technet.microsoft.com/Forums/sharepoint/en-US/4c648567-4897-461b-8dca-698f1f6f9850/workflow-generated-email-username-lookup"><span style="font-family: "arial" , "helvetica" , sans-serif;">Workflow generated email - Username lookup - TechNet</span></a><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">[Annoyingly, the messageboard moderators had in both cases marked these questions as answered, even though the OPs had reported that the answer didn't work for them.]</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">So how do you get the text of a person's name out of a "Name" list column? Well, you can't really ... at least, not out of the box.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">I certainly didn't want to start installing Codeplex solutions onto our server (I work in a Corporate environment and making changes to the server involves much tsk-ing and shaking of heads). So I had to come up with another way of doing it.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">I reasoned that the IT project manager running the project would have to type in the staff member's name anyway, so why not just type the name into a plain text field? No difference in effort, right?</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">So I set up the list with these columns (among others):</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>Employee </b>- plain text field</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>UserName</b> - Person or Group, Show field value = Name (with presence)</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>UserID</b> - Person or Group, Show field value = User Name</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>Department </b>- Person or Group, Show field value = Department</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Then I set up a workflow to copy the values for UserName, User ID and Department from the plain text Employee field, when a new item is created ... that's Step 1.</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-ktxMzfNuc-B0_oVCf6uCFrRWWN4U7COoWoUXkVt-OfV6MZ6gTO_4OeR0ZzzypC-rQ7dlQPGy8A4PhumjCAFp1WdeLgypf9874iGaTWaFvpuHgQwOaQgMRYoiusw75gblU_8tn1gsbhc/s1600/pic01_WorkflowSetup.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-ktxMzfNuc-B0_oVCf6uCFrRWWN4U7COoWoUXkVt-OfV6MZ6gTO_4OeR0ZzzypC-rQ7dlQPGy8A4PhumjCAFp1WdeLgypf9874iGaTWaFvpuHgQwOaQgMRYoiusw75gblU_8tn1gsbhc/s1600/pic01_WorkflowSetup.gif" width="320" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">This copies the user's name from the plain text column into the Person or Group columns ... like this:</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXDbQGAtxFqj4M6Eqw5rRpXlOMjvo9VkXF0Wq8ZijmnvNfqZ9GeHuJ1fAzl3R4qMuftRxjKfwx7WYJdGUxuxYccrmdSoQcE0VTyFiJxgNT-0BG2EPDLq3a3l_G-KGDoRNKztLeTsQFxws/s1600/pic02_List.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="59" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXDbQGAtxFqj4M6Eqw5rRpXlOMjvo9VkXF0Wq8ZijmnvNfqZ9GeHuJ1fAzl3R4qMuftRxjKfwx7WYJdGUxuxYccrmdSoQcE0VTyFiJxgNT-0BG2EPDLq3a3l_G-KGDoRNKztLeTsQFxws/s320/pic02_List.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Step 2 is where I create an email template to alert the employee that their installation is complete. (For test purposes, I'm sending this email to myself using the "Created by" value, but you can use the "User Name" value to send the email to the employee named in the List Item.) </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Be careful to insert a pause before the email is triggered. If you don't, the email will contain the plain text value as entered in the Employee field for each of the other columns. That is because the system takes a few seconds to resolve the plain text into a "Name (with presence)".</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2C121QXPUPrGEShupSVsKrGzJEAUL3GFwT2Zekcmp1buWAdeejYzFEoXVx7QlcvQfodqlJMnt3_PnGAXOAo8hShlfMDdTBWs9WvFO0SMkg8opNzPj7jXCR4OCuoF_2lnKN28c8V-WqQg/s1600/pic03_WorkflowEmail.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2C121QXPUPrGEShupSVsKrGzJEAUL3GFwT2Zekcmp1buWAdeejYzFEoXVx7QlcvQfodqlJMnt3_PnGAXOAo8hShlfMDdTBWs9WvFO0SMkg8opNzPj7jXCR4OCuoF_2lnKN28c8V-WqQg/s1600/pic03_WorkflowEmail.gif" width="320" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Setting up the email is quite easy. I've reproduced a simplified version here, so you can see which columns I called in the email, then the finished result below:</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRf0OZDiu4xOb1aOXvxjY6Ev16fZZB41VV94X9hgPlhk_ghp2J9gMYeP5cltwUIkMQYpi7uyFEEqluHW114IjvPcsYI7uEai-1DcTMBdHw3vUMH-brNWqtEdeedsrJ9w6xGEWqz8iatGM/s1600/pic04_WorkflowEmail.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRf0OZDiu4xOb1aOXvxjY6Ev16fZZB41VV94X9hgPlhk_ghp2J9gMYeP5cltwUIkMQYpi7uyFEEqluHW114IjvPcsYI7uEai-1DcTMBdHw3vUMH-brNWqtEdeedsrJ9w6xGEWqz8iatGM/s1600/pic04_WorkflowEmail.gif" width="320" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">You can see from the email reproduced here how the columns output into a Workflow email. The one to use if you want the include the User's name, say, in a salutation, is the first, plain text one.</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidI4wBMjfkO99M9TFvPpX4jOvs5ktzOcp29RBBP79yRDLrttd7fimSoAzQe0m7hrihwEqm7tbwSM1f_g3hTEZEiYZr3CG_Z7QkQGZlxmhV7MbtzqRzc6I9Y6CX_H7Lm-VOqOfPCQ52muE/s1600/pic05_WorkflowEmailResult.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidI4wBMjfkO99M9TFvPpX4jOvs5ktzOcp29RBBP79yRDLrttd7fimSoAzQe0m7hrihwEqm7tbwSM1f_g3hTEZEiYZr3CG_Z7QkQGZlxmhV7MbtzqRzc6I9Y6CX_H7Lm-VOqOfPCQ52muE/s320/pic05_WorkflowEmailResult.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Hope this helps someone.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>AirPiratePresshttp://www.blogger.com/profile/13136561512898563240noreply@blogger.com0tag:blogger.com,1999:blog-3023476837266527744.post-79708194653160262492014-01-09T10:25:00.004-08:002014-01-09T10:51:57.140-08:00SharePoint 2007: WorkFlow email removes space from Lookup URL<br />
Here's a thing ... A colleague wanted SharePoint to handle requests for printed stationery (letterheads and so forth), based on Templates stored as PDF files in a SharePoint Document Directory. So, the best way of doing this was to create a new separate Custom List to store the requests and when a new request was logged, use a SharePoint Designer WorkFlow to fire off an email to our facilities people so they could action the printed stationery request.<br />
<br />
Sounds simple, right? Well, it was ... up to a point.<br />
<br />
So I created the list, and added these columns:<br />
<br />
<b>SelectTemplate</b> - A Lookup. This points at the Doc Directory where the PDF tempates are stored. As I couldn't retrieve the file name (SharePoint doesn't offer that option), I had to target the Title field. I made this work this by adding a separate WorkFlow that copies the file name into the Title field whenever you add a new document to the Directory. This field shows as a drop-down picklist in the NewForm.aspx page.<br />
<br />
<b>Quantity</b> - obviously, we need to know how many copies of the letterhead they want.<br />
<br />
<b>UserText</b> - this is to convert the User ID into a proper name - <a href="http://thesharepointhive.blogspot.co.uk/2011/09/test-post.html">see the very first post in this blog for how to do that</a>.<br />
<br />
This meant that users could create a new item in the <b>Order Stationery</b> list, fill in the NewForm and let the WorkFlow fire off the email. For the email I stole the code SharePoint generates for a List Alert and customised it to hold the fields I wanted. The content of the email would include the <b>Title</b> (I gave the Title field a default value of "Stationery Order"), The <b>PDF template name</b> rendered as a <b>link to the stored PDF</b>, the <b>Quantity</b> required, the <b>name of the Requestor</b> and the <b>date the request</b> was made.<br />
<br />
All pretty straightforward.<br />
<br />
But when I ran a test, I found something really odd was happening. The link to the PDF didn't work. Here's how I sent up the link in the WorkFlow email:<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"><a href="http://myserverpath/[%LH Orders:SelectTemplate%].pdf">[%LH Orders:SelectTemplate%]</a></span><br />
<br />
No reason why that shouldn't work, right? But when I did View Source on the email in my Inbox I could see, weirdly, SharePoint had stripped out the first word space it encountered in the URL but translated the remainder into "<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">%20</span>". Like this:<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"><a href="http://</span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">myserverpath</span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">/Birmingham-%20Letterhead%20Jan%2014.pdf"></span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">Birmingham - Letterhead Jan 14</span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"></a></span><br />
<br />
Why it was doing that I had no idea. A search on Google showed this problem was frustrating other people as well. So, not just me then.<br />
<br />
Not one instance of this problem, posted in the various forums (fora?), had an adequate answer beyond, "Don't put word spaces in file names". My problem with that advice is that these systems are used by human beings and people find file names full of underscores and hyphens hard to read on-screen. Even more confusing when they're trying to find a complex file name in a picklist of many complex file names.<br />
<br />
However, because I'd been able, on an earlier occasion, to use JavaScript in a list's NewForm.aspx page to transform the UserID value into a fully-rendered user name I figured there might be a way to replace the word spaces throughout the filename with the "<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">%20</span>" character. So the first thing to do was to create a new column to hold the cleaned up text of the file name. I called it "templateURL".<br />
<br />
<b>templateURL</b> - this is the field where we'll store the "escaped" file name.<br />
<br />
Then I needed to retrieve the ID of the field as rendered in the NewForm.aspx page. So I opened the NewForm page and did View Source, then grabbed the IDs of both the <b>SelectTemplate</b> field and the <b>templateURL</b> field.<br />
<br />
Now my JavaScript skills are pretty poor, so I managed to get a colleague to help me with this. The script he came up with was this:<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"><script></span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>function getSelectedText( obj ) {</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span> return obj.options[obj.selectedIndex].text;</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"> function encodeTemplate() {</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>var templateURL = document.getElementById("ctl00_m_g_23fc3b40_9a6b_4126_bcf4_a3bfc2fff76d_ctl00_ctl04_ctl05_ctl00_ctl00_ctl04_ctl00_ctl00_TextField");</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>var templateLookup = document.getElementById("ctl00_m_g_23fc3b40_9a6b_4126_bcf4_a3bfc2fff76d_ctl00_ctl04_ctl01_ctl00_ctl00_ctl04_ctl00_Lookup");</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>templateURL.value = encodeURI("http://oneintranet.qbe.eo/departments/cres_procedures/QBE Claims/" + getSelectedText(templateLookup) + ".pdf");</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">}</span><br />
<span class="Apple-tab-span" style="white-space: pre;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"> </span></span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>var templateLookup = document.getElementById("ctl00_m_g_23fc3b40_9a6b_4126_bcf4_a3bfc2fff76d_ctl00_ctl04_ctl01_ctl00_ctl00_ctl04_ctl00_Lookup");</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>templateLookup.attachEvent("onchange", function(){encodeTemplate()});</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"></script></span><br />
<br />
I pasted this script into the NewForm.aspx page after this line:<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"><asp:Content ContentPlaceHolderId="PlaceHolderBodyAreaClass" runat="server"></span><br />
<br />
The JavaScript grabs the value rendered by the <b>SelectTemplate</b> field. It then replaces the word spaces with "<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">%20</span>" (that's the <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">encodeURI</span> function), then copies the result into the plain text field I set up, <b>templateURL</b>. Finally, it builds a URL for the PDF template file by putting in the server path at the front and tagging ".pdf" on the end. Note that the actual name of the document directory that holds the templates also has a word space in it. The <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">encodeURI</span> takes care of that, too.<br />
<br />
All that remained was to change the link in the WorkFlow email to:<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"><a href="[%LH Orders:templateURL%]">[%LH Orders:SelectTemplate%]</a></span><br />
<br />
And there you go. All done and dusted. You have a link to a stored document that works and gets round SharePoint's strange habit of removing just the first space it encounters in a URL inserted from a Lookup in a WorkFlow email.<br />
<br />
One enhancement you might make would be to hide the text fields in the NewForm.aspx page, so that your users can't mess with the text automatically copied there during the placing of an order. Another of my earlier blogs describes <a href="http://thesharepointhive.blogspot.co.uk/2011/11/hiding-fields-in-newformaspx.html">Hiding Fields in NewForm.aspx</a>.<br />
<br />
Hope this helps someone.AirPiratePresshttp://www.blogger.com/profile/13136561512898563240noreply@blogger.com0tag:blogger.com,1999:blog-3023476837266527744.post-91740463507309971362013-08-02T08:13:00.001-07:002017-04-28T05:57:13.147-07:00SharePoint 2007 - Cannot access "Page Settings" area in Publishing site<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;">Here's an odd thing. I wanted to change the Page template of a SharePoint page that was displaying in an old, outdated template. But when I went Edit Page, then <b>Page</b> > <b>Page Settings </b>... </span><br />
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgThi6BZiQptvJT3Gfc2ImV2Jv5nJxaTSdmJu8NfLPso3RJVF52nHuR-OVh6hC86asdGfY6mmIHGtPkJt6FPURXlEXymVefaWeqiUzM5kGQEShiXL-kwETjya8U_9CQNTOWSgQiozcdlGw/s1600/01_PageSettings.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="206" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgThi6BZiQptvJT3Gfc2ImV2Jv5nJxaTSdmJu8NfLPso3RJVF52nHuR-OVh6hC86asdGfY6mmIHGtPkJt6FPURXlEXymVefaWeqiUzM5kGQEShiXL-kwETjya8U_9CQNTOWSgQiozcdlGw/s320/01_PageSettings.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;">... I wasn't seeing the familiar <b>Page Settings</b> page. I was seeing this:</span><br />
<div class="separator" style="clear: both; text-align: -webkit-auto;">
<br /></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0ylppcL6Aefsow6THAw26z3b0iv_4pdF-Y35OC4zl1q_zP7RXJq0CYazmM8lXXuN6P_CSjveEtnmPIHZgzOi6xR_7Zfg8BvmK8n8hyb48E6P1_CIkgMYJBoAsiX5TvJ4Ouue72OD692U/s1600/02_ChangeTemplate.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="202" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0ylppcL6Aefsow6THAw26z3b0iv_4pdF-Y35OC4zl1q_zP7RXJq0CYazmM8lXXuN6P_CSjveEtnmPIHZgzOi6xR_7Zfg8BvmK8n8hyb48E6P1_CIkgMYJBoAsiX5TvJ4Ouue72OD692U/s320/02_ChangeTemplate.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<br />
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;">No sign of my picklist of Page Templates at all. I knew I had encountered this problem before, but couldn't remember what the solution was, so I got on to trusty <a href="http://www.google.com/"><b>Google</b></a>, figuring someone is bound to have the answer to this vexing issue. But no ... nothing doing.</span><br />
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;">I tried going to the Pages Directory and seeing if <b>Editing Properties</b> of the page would help, but that got me nowhere.</span><br />
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;">Then, running out of options, I fired up SharePoint Designer and navigated to the sub-site. And there it was! </span><br />
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_0mRdSKW9PGkPFXOePD49ChGMAbnfFl5guZCbSz6paAmPx9MIU8uTgWkXKNCWsnkjzlc3RwRMYkvORUWOUn5AIN4Uld8Av1TvHE0dgb07eCE5yko4MS17wpoTS4P-ggCz0ERAd2kSl3XF/s1600/03_Reattach_Template.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_0mRdSKW9PGkPFXOePD49ChGMAbnfFl5guZCbSz6paAmPx9MIU8uTgWkXKNCWsnkjzlc3RwRMYkvORUWOUn5AIN4Uld8Av1TvHE0dgb07eCE5yko4MS17wpoTS4P-ggCz0ERAd2kSl3XF/s320/03_Reattach_Template.jpg" width="193" /></a></div>
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;">The dad-blasted Page Layout was detached, obviously from some earlier Designer fiddling and I'd forgotten to reattach. Simply reattaching the Page Layout fixed the problem and I was able to access the Page Layout picklist in the Page Settings area.</span><br />
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFpL06djACnQfIxf21_BaeaV9kC2oKltXRuqqBaitnAi08BT5AOfp-C6u9rt3wjE6bqGaCi_mnEWi67lbIVrz9iM4rSuGP16Ab6Quz978Yxuy1GbyYe6EnIhSchxdMhlAnd8iwdsAvAXc/s1600/04_PageLayout.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="181" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFpL06djACnQfIxf21_BaeaV9kC2oKltXRuqqBaitnAi08BT5AOfp-C6u9rt3wjE6bqGaCi_mnEWi67lbIVrz9iM4rSuGP16Ab6Quz978Yxuy1GbyYe6EnIhSchxdMhlAnd8iwdsAvAXc/s320/04_PageLayout.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;">It might seem screamingly obvious but then, you can't always remember everything, and incredibly, no one has posted an explanation for this problem that crops up in the first ten screens of a Google search. </span><br />
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;">So hopefully, this will save someone thrashing around, trying to figure out why they can't change the Template for a SharePoint Publishing page.</span><br />
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>The SharePoint Hivehttp://www.blogger.com/profile/02187796084766651206noreply@blogger.com0tag:blogger.com,1999:blog-3023476837266527744.post-91001353193424236822013-07-08T05:07:00.000-07:002017-04-28T07:03:09.481-07:00Place a Picture Library SlideShow on a SharePoint 2007 page<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;">I wanted to embed a Picture Library as a SlideShow in a SharePoint 2007 page, but when I checked the Microsoft web site, their <a href="http://office.microsoft.com/en-gb/windows-sharepoint-services-help/working-with-sharepoint-picture-libraries-HA001123335.aspx">coverage of the SharePoint 2007 Picture Library function</a> didn't have the information I needed. So, I had to figure it out for myself.</span><br />
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;">So here's what I did to embed a Picture Library SlideShow on the page ...</span><br />
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<ol>
<li><span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;">First, I created a SharePoint Picture Library in the normal way and loaded up the images.<br /></span>
</li>
<li><span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;">Next, in the newly-created Picture Library, I selected <b>View Slide Show</b> from the <b>Actions</b> menu.</span><br /><br /><div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0woj-UKMX7DuC78ME5S7BJ5Cfcn6O4qD4jOagE-u-dF27ivbMPFOpk3HogR0mjmFCSSQRmn6Wa5-Zb4tDjmMvdRrtCnLb9BVOKtJkdMrfgF1jpOVDaFHIQGiESuArhCYDhfuWaEIpu3lD/s1600/pic01_slideshowmenu.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0woj-UKMX7DuC78ME5S7BJ5Cfcn6O4qD4jOagE-u-dF27ivbMPFOpk3HogR0mjmFCSSQRmn6Wa5-Zb4tDjmMvdRrtCnLb9BVOKtJkdMrfgF1jpOVDaFHIQGiESuArhCYDhfuWaEIpu3lD/s320/pic01_slideshowmenu.jpg" width="284" /></a></div>
<br />
</li>
<li><span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;">This brings up the Slide Show in a new browser window. I right-clicked on the Slide Show and selected <b>Properties</b>.<br /><br /><div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6hzlLujbDaaxHTjHpZ4-8Cc1skD7Ah_9xUfMn4z-zKlKSLBA8dATy2tbCXFrIORZJKYi9goeB7WQRrtnR6oqZUp6f_dvZb0hGLdF8SVnE51wl-BJBVdnQcZrNnXle19g4OPEKc5LLuW7M/s1600/pic02_slideshow.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6hzlLujbDaaxHTjHpZ4-8Cc1skD7Ah_9xUfMn4z-zKlKSLBA8dATy2tbCXFrIORZJKYi9goeB7WQRrtnR6oqZUp6f_dvZb0hGLdF8SVnE51wl-BJBVdnQcZrNnXle19g4OPEKc5LLuW7M/s320/pic02_slideshow.jpg" width="264" /></a></div>
<br />
</span></li>
<li><span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;">I highlighted the URL of the Slide Show and copied to the clipboard with the <b>ctrl-c</b> function.<br /><br /><div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqJJKoQ2xdV2XBwDA9rd_RP8jOscp3V8zv5KEwvdZ-GIPL9tkmYPVrIXDou5MdKU4q_k__D40dyi1NVm86gjTZ45cLRG0dbFYwCwifCx5Z5xcapIHBBa31GRk5eq0ScEvUawu7vgjLhPo/s1600/pic03_slideshowURL.jpg" imageanchor="1" style="font-family: Times; margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqJJKoQ2xdV2XBwDA9rd_RP8jOscp3V8zv5KEwvdZ-GIPL9tkmYPVrIXDou5MdKU4q_k__D40dyi1NVm86gjTZ45cLRG0dbFYwCwifCx5Z5xcapIHBBa31GRk5eq0ScEvUawu7vgjLhPo/s320/pic03_slideshowURL.jpg" width="261" /></a></div>
<div style="text-align: left;">
</div>
<br /><div class="separator" style="clear: both; text-align: center;">
</div>
</span></li>
<li><span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;">Then I placed a Page Viewer Web Part on the selected SharePoint page and added the URL from the clipboard. You may have to adjust the height of the Page Viewer Web Part to accommodate the size of image you're using.</span></li>
</ol>
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;">That's it ...</span>The SharePoint Hivehttp://www.blogger.com/profile/02187796084766651206noreply@blogger.com0tag:blogger.com,1999:blog-3023476837266527744.post-84101532648182580522013-05-21T03:50:00.001-07:002017-05-10T12:27:27.793-07:00Setting default values for Content Types on creating a new page<br />
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;">While trying to set up a facility in SharePoint to email around summaries of the week's top news stories, I ran into a strange problem.</span><br />
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;">If you've read <a href="http://thesharepointhive.blogspot.co.uk/2013/04/adding-page-specific-icons-to.html">my previous post</a>, you'll recall that I had set up a sub-site in SharePoint to hold the news articles - each article was on a new page and the pages incorporated metadata stored in Content Types created for that purpose.</span><br />
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;">I'd built the pages that way so that the non-technical News publishers would be able to set vital meta-data for each story without having to go the </span><br />
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;"><i>Site Actions > View all Site Content > Pages </i></span><br />
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;">route to get to the <b>Edit Properties</b> function.</span><br />
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;">All that went fairly smoothly - apart from a small glitch around retrieving the current Page URL (see the previous Blog posting) - and we proudly launched our new News facility.</span><br />
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;">The next glitch came when one of the publishers was compiling the weekly round up of top News stories. I'd made a page containing a DVWP which looked at the Pages folder that contained all the News stories and displayed just those where a value for "weekly roundup email position" had been set. This is a Content Type that contains a choice of values "1st story, 2nd story, etc". The publisher creates a new story, then selects a value for "weekly roundup position" from a pick list. If the story isn't required in the weekly round up then they leave the value as "Select a position for email". The Content Type had the same value set as the default value.</span><br />
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;">The issue was, when the publisher created a new story, the value for "weekly roundup position" was blank by default. Where was the default value?</span><br />
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhd4vuwVLwn10NRJysh28LtKwzCsZxTBicDRWyvXF-QRQHb_VNvSqDNKyS3HWAXeNwfzZ8_NmRlxhBfej1R2LXSjUMV0SUTq-iQ1x-CXd8jWhDE4s9XCjOl25R5jKodohn2eBxNPV_2hrh7/s1600/pic01_final.gif" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhd4vuwVLwn10NRJysh28LtKwzCsZxTBicDRWyvXF-QRQHb_VNvSqDNKyS3HWAXeNwfzZ8_NmRlxhBfej1R2LXSjUMV0SUTq-iQ1x-CXd8jWhDE4s9XCjOl25R5jKodohn2eBxNPV_2hrh7/s400/pic01_final.gif" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;"><i>Above left is what the metadata setting looked like when a new page was created, but we needed it to look like the above right image, with a default value displayed in the Roundup picklist.</i></span></td></tr>
</tbody></table>
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;">Everything looked like it was set up correctly but it wasn't working ... so had a trawl around on Google and was unable to find anyone else with the same problem. Then I chanced on a site where someone was talking about not seeing default values on Content types. After following a series of links and putting the information together, it became apparent to me what was causing the problem. Turns out you have to make the group of Content Types the Default Content Type Group for the List you're looking at.</span><br />
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;">So here's what I did ...</span><br />
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;">I had set up my new Content Types in the Article Page group. So I drilled down to the Content Type and made sure the default value was set to what I wanted.</span><br />
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwDN0GSKlgO74rBP4Bp8ZLJr9J8gc_u1TN8nXgz10kfOyC6tqs3I9tzWanOMRIvZzQ47ABJT7Go7rZ9guqD08_tTQFoHiTbMKZvwe8aiDoXnwruWcjOPExbqPGwCQfCideCCP411YE4ghG/s1600/pic06_DefaultValue.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwDN0GSKlgO74rBP4Bp8ZLJr9J8gc_u1TN8nXgz10kfOyC6tqs3I9tzWanOMRIvZzQ47ABJT7Go7rZ9guqD08_tTQFoHiTbMKZvwe8aiDoXnwruWcjOPExbqPGwCQfCideCCP411YE4ghG/s1600/pic06_DefaultValue.JPG" /></a></div>
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;">Next I went back to the List - in this case, the Pages Directory that held the News articles - and from the Settings menu selected Document Library Settings.</span><br />
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;">Then I found the <b>Content Types</b> section - note that the <b>Page</b> Content Type is set as the default - and clicked on the link <b>Change new button order</b> and default content type.</span><br />
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgq8GCd9F1eUlZ_ZDDYrQF_Kt2OsVTu2oKDDEJ3oQ90aO4oiaDnkyQZH-nxtof8cSk1w0s9AY_yQBK2IK4z83hcJ6r-_HYq3dSKPHsNWs_YJYPHehgyHvv07CarT3ydl9bD7AvEpr1sciaI/s1600/pic02a.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="145" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgq8GCd9F1eUlZ_ZDDYrQF_Kt2OsVTu2oKDDEJ3oQ90aO4oiaDnkyQZH-nxtof8cSk1w0s9AY_yQBK2IK4z83hcJ6r-_HYq3dSKPHsNWs_YJYPHehgyHvv07CarT3ydl9bD7AvEpr1sciaI/s640/pic02a.jpg" width="640" /></a></div>
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;">Now it's not screamingly obvious but what you have to do is bring the Content Type Group that holds the Content Types you want to display the Default Values for up to the top of the list by setting its value to "1", then clicking OK.</span><br />
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwW4YtTUT_Le-SCdOC22VWAuHO3wReD1WjG270OK3apogBCWtKkJCjYWp9aTGCzgE7Jxu5T63tW9hGVfpWlEmi3Q8Z4WQsBsLTUFXNLvqXCxHwRRga0poCH520nZZiBf84BsFsRep6e69U/s1600/pic03.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="171" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwW4YtTUT_Le-SCdOC22VWAuHO3wReD1WjG270OK3apogBCWtKkJCjYWp9aTGCzgE7Jxu5T63tW9hGVfpWlEmi3Q8Z4WQsBsLTUFXNLvqXCxHwRRga0poCH520nZZiBf84BsFsRep6e69U/s640/pic03.JPG" width="640" /></a></div>
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;">That's it. The Content Types section should now look like this, with Articles at the top and ticked as the Default Content Type.</span><br />
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRgoYLL7pU0Ep4P_XgplonqChMwmu8jI1jh9Gwnerb1VUvf4gSO_NRWJfl6Nv9G5KnCk8xt9arBG6IHIBHhFmsYE7aDM1PAO_rj-z-tAGFPZkzsQ7DiYKaeUdzNdFOAoPAyDEEe-KDJMAv/s1600/pic02b.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="144" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRgoYLL7pU0Ep4P_XgplonqChMwmu8jI1jh9Gwnerb1VUvf4gSO_NRWJfl6Nv9G5KnCk8xt9arBG6IHIBHhFmsYE7aDM1PAO_rj-z-tAGFPZkzsQ7DiYKaeUdzNdFOAoPAyDEEe-KDJMAv/s640/pic02b.jpg" width="640" /></a></div>
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;">Now when you create a new page, the default values you set in the Content types will be added to the metadata for that page, unless (or until) you choose a different Content Type value.</span><br />
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span class="Apple-style-span" style="font-family: "arial" , "helvetica" , sans-serif;">Hope this helps someone ...</span>The SharePoint Hivehttp://www.blogger.com/profile/02187796084766651206noreply@blogger.com0