<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Need help with using  Document template script in HRSD forum</title>
    <link>https://www.servicenow.com/community/hrsd-forum/need-help-with-using-document-template-script/m-p/2786920#M34080</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Try below approach:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;BR /&gt;&amp;lt;html&amp;gt;&lt;BR /&gt;&amp;lt;head&amp;gt;&lt;BR /&gt;&amp;lt;title&amp;gt;Document Template&amp;lt;/title&amp;gt;&lt;BR /&gt;&amp;lt;/head&amp;gt;&lt;BR /&gt;&amp;lt;body&amp;gt;&lt;BR /&gt;&amp;lt;h1&amp;gt;Document Template&amp;lt;/h1&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;!-- Your HTML content here --&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;script&amp;gt;&lt;BR /&gt;// Assuming your document template is associated with a particular table, let's say 'incident'&lt;BR /&gt;var gr = new GlideRecord('incident');&lt;/P&gt;&lt;P&gt;// Apply a filter based on conditions from the Document Block Content&lt;BR /&gt;gr.addQuery('your_condition_field', 'your_condition_value');&lt;BR /&gt;gr.addQuery('additional_condition_field', 'additional_condition_value');&lt;BR /&gt;// Add more conditions as needed&lt;/P&gt;&lt;P&gt;gr.query();&lt;/P&gt;&lt;P&gt;while (gr.next()) {&lt;BR /&gt;// Access fields and perform calculations&lt;BR /&gt;var fieldValue = gr.getValue('your_field_name');&lt;BR /&gt;// Perform your calculations here based on the field values&lt;/P&gt;&lt;P&gt;// Output the calculated values or use them as needed in your template&lt;BR /&gt;document.write('&amp;lt;p&amp;gt;Calculated value for ' + gr.getValue('number') + ': ' + calculatedValue + '&amp;lt;/p&amp;gt;');&lt;BR /&gt;}&lt;BR /&gt;&amp;lt;/script&amp;gt;&lt;BR /&gt;&amp;lt;/body&amp;gt;&lt;BR /&gt;&amp;lt;/html&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Shoheb&lt;/P&gt;</description>
    <pubDate>Wed, 10 Jan 2024 07:21:00 GMT</pubDate>
    <dc:creator>Shoheb_IbaaBoss</dc:creator>
    <dc:date>2024-01-10T07:21:00Z</dc:date>
    <item>
      <title>Need help with using  Document template script</title>
      <link>https://www.servicenow.com/community/hrsd-forum/need-help-with-using-document-template-script/m-p/2786916#M34079</link>
      <description>&lt;P&gt;Hi all ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We have a document block created and a document block content created for a particular table with some filter conditions.&amp;nbsp; In the HTML body we want to call a document template script.I have not used it before and hence have some doubts.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We want to do some calculations based on the fields of the table used in the Document Block. That should apply for all the records filtered in the condition field of the Document Block content .Can current be used in the document template script in a Glide Record Query of the table?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2024 07:18:18 GMT</pubDate>
      <guid>https://www.servicenow.com/community/hrsd-forum/need-help-with-using-document-template-script/m-p/2786916#M34079</guid>
      <dc:creator>muktha1</dc:creator>
      <dc:date>2024-01-10T07:18:18Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with using  Document template script</title>
      <link>https://www.servicenow.com/community/hrsd-forum/need-help-with-using-document-template-script/m-p/2786920#M34080</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Try below approach:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;BR /&gt;&amp;lt;html&amp;gt;&lt;BR /&gt;&amp;lt;head&amp;gt;&lt;BR /&gt;&amp;lt;title&amp;gt;Document Template&amp;lt;/title&amp;gt;&lt;BR /&gt;&amp;lt;/head&amp;gt;&lt;BR /&gt;&amp;lt;body&amp;gt;&lt;BR /&gt;&amp;lt;h1&amp;gt;Document Template&amp;lt;/h1&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;!-- Your HTML content here --&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;script&amp;gt;&lt;BR /&gt;// Assuming your document template is associated with a particular table, let's say 'incident'&lt;BR /&gt;var gr = new GlideRecord('incident');&lt;/P&gt;&lt;P&gt;// Apply a filter based on conditions from the Document Block Content&lt;BR /&gt;gr.addQuery('your_condition_field', 'your_condition_value');&lt;BR /&gt;gr.addQuery('additional_condition_field', 'additional_condition_value');&lt;BR /&gt;// Add more conditions as needed&lt;/P&gt;&lt;P&gt;gr.query();&lt;/P&gt;&lt;P&gt;while (gr.next()) {&lt;BR /&gt;// Access fields and perform calculations&lt;BR /&gt;var fieldValue = gr.getValue('your_field_name');&lt;BR /&gt;// Perform your calculations here based on the field values&lt;/P&gt;&lt;P&gt;// Output the calculated values or use them as needed in your template&lt;BR /&gt;document.write('&amp;lt;p&amp;gt;Calculated value for ' + gr.getValue('number') + ': ' + calculatedValue + '&amp;lt;/p&amp;gt;');&lt;BR /&gt;}&lt;BR /&gt;&amp;lt;/script&amp;gt;&lt;BR /&gt;&amp;lt;/body&amp;gt;&lt;BR /&gt;&amp;lt;/html&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Shoheb&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2024 07:21:00 GMT</pubDate>
      <guid>https://www.servicenow.com/community/hrsd-forum/need-help-with-using-document-template-script/m-p/2786920#M34080</guid>
      <dc:creator>Shoheb_IbaaBoss</dc:creator>
      <dc:date>2024-01-10T07:21:00Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with using  Document template script</title>
      <link>https://www.servicenow.com/community/hrsd-forum/need-help-with-using-document-template-script/m-p/2787043#M34082</link>
      <description>&lt;P&gt;Hi Shoheb,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your reply.&amp;nbsp;So, do you mean to say that all the filter conditions pertaining to the table selected given in the document block content record have to be given in the document template script also? I wanted to know whether like in an email script where we&amp;nbsp; current refers to the current record of the notification, we have anything here which will refer to the records filtered in the block content.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2024 09:01:29 GMT</pubDate>
      <guid>https://www.servicenow.com/community/hrsd-forum/need-help-with-using-document-template-script/m-p/2787043#M34082</guid>
      <dc:creator>muktha1</dc:creator>
      <dc:date>2024-01-10T09:01:29Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with using  Document template script</title>
      <link>https://www.servicenow.com/community/hrsd-forum/need-help-with-using-document-template-script/m-p/2787048#M34083</link>
      <description>&lt;P&gt;If you want to achieve this via email script, try below code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Assuming your document template is associated with a particular table, let's say 'incident'&lt;BR /&gt;var gr = new GlideRecord('incident');&lt;/P&gt;&lt;P&gt;// Apply a filter based on conditions from the Document Block Content&lt;BR /&gt;gr.addQuery('your_condition_field', 'your_condition_value');&lt;BR /&gt;gr.addQuery('additional_condition_field', 'additional_condition_value');&lt;BR /&gt;// Add more conditions as needed&lt;/P&gt;&lt;P&gt;gr.query();&lt;/P&gt;&lt;P&gt;var emailBody = '&amp;lt;!DOCTYPE html&amp;gt;' +&lt;BR /&gt;'&amp;lt;html&amp;gt;' +&lt;BR /&gt;'&amp;lt;head&amp;gt;' +&lt;BR /&gt;'&amp;lt;title&amp;gt;Document Template&amp;lt;/title&amp;gt;' +&lt;BR /&gt;'&amp;lt;/head&amp;gt;' +&lt;BR /&gt;'&amp;lt;body&amp;gt;' +&lt;BR /&gt;'&amp;lt;h1&amp;gt;Document Template&amp;lt;/h1&amp;gt;';&lt;/P&gt;&lt;P&gt;while (gr.next()) {&lt;BR /&gt;// Access fields and perform calculations&lt;BR /&gt;var fieldValue = gr.getValue('your_field_name');&lt;BR /&gt;// Perform your calculations here based on the field values&lt;BR /&gt;var calculatedValue = fieldValue * 2; // Replace with your actual calculation logic&lt;/P&gt;&lt;P&gt;// Output the calculated values or use them as needed in your template&lt;BR /&gt;emailBody += '&amp;lt;p&amp;gt;Calculated value for ' + gr.getValue('number') + ': ' + calculatedValue + '&amp;lt;/p&amp;gt;';&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;emailBody += '&amp;lt;/body&amp;gt;' +&lt;BR /&gt;'&amp;lt;/html&amp;gt;';&lt;/P&gt;&lt;P&gt;// Use 'email' object to send the email with the generated HTML content&lt;BR /&gt;email.addMessage(emailBody);&lt;BR /&gt;email.send();&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;/P&gt;&lt;P&gt;Shoheb&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2024 09:08:25 GMT</pubDate>
      <guid>https://www.servicenow.com/community/hrsd-forum/need-help-with-using-document-template-script/m-p/2787048#M34083</guid>
      <dc:creator>Shoheb_IbaaBoss</dc:creator>
      <dc:date>2024-01-10T09:08:25Z</dc:date>
    </item>
  </channel>
</rss>

