Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Exporting rendered HTML

StephLindorff
Tera Expert

Has anyone found a way to export the contents of a Knowledge article as rendered HTML (when Article Type = HTML)?  

Thanks

18 REPLIES 18

Stephanie


let me know how that goes, there might also be a way to send an email w/ the rendered HTML via a UI Action


I might have to look into that for us as a way to send the KB for others to review who may not have a service-now license


That would be great!   Thanks


Were you able to find a solution for your use case?


Unfortunately, no.   Anyone?



Steph


Hi Stephanie Lindorff,



Try this in your worksheet:



1. Copy this code:


Sub StripTags()



      Dim cell               As Range


      Dim s                     As String


      Dim asWd()           As String


      Dim iWd                 As Long



      For Each cell In Intersect(Selection.Cells, ActiveSheet.UsedRange)


              s = Replace(cell.Value, Chr(160), " ")


              s = Replace(s, ">", "<")


              s = Replace(s, vbCr, vbLf)


             


              asWd = Split(s, "<")


              s = vbNullString


              For iWd = 0 To UBound(asWd) Step 2


                      s = s & " " & asWd(iWd)


              Next iWd



              Do While InStr(s, vbLf & " ")


                      s = Replace(s, vbLf & " ", vbLf)


              Loop



              Do While InStr(s, vbLf & vbLf)


                      s = Replace(s, vbLf & vbLf, vbLf)


              Loop


             


              cell.Value = WorksheetFunction.Trim(s)


      Next cell


End Sub



2. While in your worksheet, press Alt+F11 to open the Visual Basic Editor


3. From the menu bar, do Insert> Module


4. Paste the code in the window


5. Close the window. (Don't worry about trying to find a save button.   You can just close the window.)


6. Select your range, which will probably be a column since you're doing all those rows of article text


7. Press Alt+F8 to open the macro dialog


8. Select the macro name from the dropdown list and press run






Note:   These steps are a little different if you're on a Mac, but they're pretty close.   I tested the script on my Mac because I haven't run it in since the last time I was converting articles to plain text in Excel, and what I ended up doing was highlighting my range first, creating the macro as outlined above, closing the window, and then just clicking the Run button in the header. It looks like a Play button, and is directly under the Format menu.



Sarah Eubanks, this solution might also work for you if I understand what you want.   You could export, run the script, make updates to the plain text and then do an auto-import of the content back into your instance.



Let me know if this doesn't answer the question, or if there's anything else I can do to help.



Britt Champeau