<?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: Checking for attachments in Service Management forum</title>
    <link>https://www.servicenow.com/community/service-management-forum/checking-for-attachments/m-p/400487#M16825</link>
    <description>&lt;P&gt;Glad you got it resolved!&lt;/P&gt;</description>
    <pubDate>Mon, 05 Aug 2019 13:35:58 GMT</pubDate>
    <dc:creator>Allen Andreas</dc:creator>
    <dc:date>2019-08-05T13:35:58Z</dc:date>
    <item>
      <title>Checking for attachments</title>
      <link>https://www.servicenow.com/community/service-management-forum/checking-for-attachments/m-p/400479#M16817</link>
      <description>&lt;P&gt;Greetings everyone,&lt;/P&gt;
&lt;P&gt;I have the following problem.&lt;/P&gt;
&lt;P&gt;I&amp;nbsp;got&amp;nbsp;one type of record that needs to be filled with specific attachments. So I made a section in the form with "File Attachment" fields because i need to keep track of which file was attached and which wasn't.&lt;/P&gt;
&lt;P&gt;Something like this.&lt;span class="lia-inline-image-display-wrapper" image-alt="find_real_file.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/11462i631B3FC552270094/image-size/large?v=v2&amp;amp;px=999" role="button" title="find_real_file.png" alt="find_real_file.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I managed to make a Business Rule that checks if there are attachments missing, if so, it shows a message at the top of the screen saying "The following files are missing: " and it shows which ones are missing.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="find_real_file.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/11461iB84C4FB26F844B80/image-size/large?v=v2&amp;amp;px=999" role="button" title="find_real_file.png" alt="find_real_file.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The problem is, if I attach a file, update the record and then remove the file, the form won't recognize that a file is missing anymore.&lt;/P&gt;
&lt;P&gt;I don't understand why it does that.&lt;/P&gt;
&lt;P&gt;Can someone help me? Tell me if you need more info.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2019 17:21:59 GMT</pubDate>
      <guid>https://www.servicenow.com/community/service-management-forum/checking-for-attachments/m-p/400479#M16817</guid>
      <dc:creator>Samuel Macedo</dc:creator>
      <dc:date>2019-07-25T17:21:59Z</dc:date>
    </item>
    <item>
      <title>Re: Checking for attachments</title>
      <link>https://www.servicenow.com/community/service-management-forum/checking-for-attachments/m-p/400480#M16818</link>
      <description>&lt;P&gt;Well, we have no information about your business rule...other than you have one. So a screenshot of the settings and/or script and all that would be a start.&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2019 17:24:37 GMT</pubDate>
      <guid>https://www.servicenow.com/community/service-management-forum/checking-for-attachments/m-p/400480#M16818</guid>
      <dc:creator>Allen Andreas</dc:creator>
      <dc:date>2019-07-25T17:24:37Z</dc:date>
    </item>
    <item>
      <title>Re: Checking for attachments</title>
      <link>https://www.servicenow.com/community/service-management-forum/checking-for-attachments/m-p/400481#M16819</link>
      <description>&lt;P&gt;Hi Samuel, how you are managing attachment type via business rule, business rule can check the file attached/or not attached for any records. Please share more information for your custom file type and business rule code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2019 17:31:19 GMT</pubDate>
      <guid>https://www.servicenow.com/community/service-management-forum/checking-for-attachments/m-p/400481#M16819</guid>
      <dc:creator>AshishKM</dc:creator>
      <dc:date>2019-07-25T17:31:19Z</dc:date>
    </item>
    <item>
      <title>Re: Checking for attachments</title>
      <link>https://www.servicenow.com/community/service-management-forum/checking-for-attachments/m-p/400482#M16820</link>
      <description>&lt;P&gt;Hi Samuel,&lt;/P&gt;
&lt;P&gt;I believe you are using the Business rule as only on insert not on update, and that is the only reason that when you create/insert the record the business rule is triggered and checks for the attachment but when it is updated the business rule is not triggered.&lt;/P&gt;
&lt;P&gt;Please check the update check box as true in your business rule.&lt;/P&gt;
&lt;P&gt;Please mark my answer as correct/helpful based on the impact.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Alok&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2019 17:43:40 GMT</pubDate>
      <guid>https://www.servicenow.com/community/service-management-forum/checking-for-attachments/m-p/400482#M16820</guid>
      <dc:creator>AlokD6499012040</dc:creator>
      <dc:date>2019-07-25T17:43:40Z</dc:date>
    </item>
    <item>
      <title>Re: Checking for attachments</title>
      <link>https://www.servicenow.com/community/service-management-forum/checking-for-attachments/m-p/400483#M16821</link>
      <description>&lt;P&gt;Sorry about that! I should've done that haha&lt;/P&gt;
&lt;P&gt;I made a OnDisplay Business Rule with the following script:&lt;/P&gt;
&lt;P&gt;(function executeRule(current, previous /*null when async*/) {&lt;BR /&gt; &lt;BR /&gt; // Add your code here&lt;BR /&gt; if (current == null) // to prevent null pointer exceptions.&lt;BR /&gt; return;&lt;BR /&gt; &lt;BR /&gt; var PE = current.u_file_attachment_7;&lt;BR /&gt; var NF = current.u_file_attachment_4;&lt;BR /&gt; var RA = current.u_file_attachment_2;&lt;BR /&gt; var RC = current.u_file_attachment_8;&lt;BR /&gt; &lt;BR /&gt; if(PE=="" || NF=="" || RA=="" || RC==""){&lt;BR /&gt; gs.addErrorMessage("Missing the following files: ");&lt;/P&gt;
&lt;P&gt;if(PE==""){&lt;BR /&gt; gs.addErrorMessage(PE.getLabel());&lt;BR /&gt; }&lt;/P&gt;
&lt;P&gt;if(RC==""){&lt;BR /&gt; gs.addErrorMessage(RC.getLabel());&lt;BR /&gt; }&lt;/P&gt;
&lt;P&gt;if(RA==""){&lt;BR /&gt; gs.addErrorMessage(RA.getLabel());&lt;BR /&gt; }&lt;/P&gt;
&lt;P&gt;if(NF==""){&lt;BR /&gt; gs.addErrorMessage(NF.getLabel());&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2019 18:14:58 GMT</pubDate>
      <guid>https://www.servicenow.com/community/service-management-forum/checking-for-attachments/m-p/400483#M16821</guid>
      <dc:creator>Samuel Macedo</dc:creator>
      <dc:date>2019-07-25T18:14:58Z</dc:date>
    </item>
    <item>
      <title>Re: Checking for attachments</title>
      <link>https://www.servicenow.com/community/service-management-forum/checking-for-attachments/m-p/400484#M16822</link>
      <description>&lt;P&gt;I made a OnDisplay Business Rule that checks if each field is empty or not.&lt;/P&gt;
&lt;P&gt;I don't know if there's a better way to do that.&lt;/P&gt;
&lt;P&gt;This what I wrote:&lt;/P&gt;
&lt;P&gt;(function executeRule(current, previous /*null when async*/) {&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;// Add your code here&lt;BR /&gt;if (current == null) // to prevent null pointer exceptions.&lt;BR /&gt;return;&lt;BR /&gt;&lt;BR /&gt;var PE = current.u_file_attachment_7;&lt;BR /&gt;var NF = current.u_file_attachment_4;&lt;BR /&gt;var RA = current.u_file_attachment_2;&lt;BR /&gt;var RC = current.u_file_attachment_8;&lt;BR /&gt;&lt;BR /&gt;if(PE=="" || NF=="" || RA=="" || RC==""){&lt;BR /&gt;gs.addErrorMessage("Missing the following files: ");&lt;/P&gt;
&lt;P&gt;if(PE==""){&lt;BR /&gt;gs.addErrorMessage(PE.getLabel());&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;if(RC==""){&lt;BR /&gt;gs.addErrorMessage(RC.getLabel());&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;if(RA==""){&lt;BR /&gt;gs.addErrorMessage(RA.getLabel());&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;if(NF==""){&lt;BR /&gt;gs.addErrorMessage(NF.getLabel());&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2019 18:18:18 GMT</pubDate>
      <guid>https://www.servicenow.com/community/service-management-forum/checking-for-attachments/m-p/400484#M16822</guid>
      <dc:creator>Samuel Macedo</dc:creator>
      <dc:date>2019-07-25T18:18:18Z</dc:date>
    </item>
    <item>
      <title>Re: Checking for attachments</title>
      <link>https://www.servicenow.com/community/service-management-forum/checking-for-attachments/m-p/400485#M16823</link>
      <description>&lt;P&gt;you can give a try with before-insert- update Business Rule instead of display business rule,&lt;/P&gt;
&lt;P&gt;Also,&lt;/P&gt;
&lt;P&gt;you can refer to the below link:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.servicenow.com/community?id=community_question&amp;amp;sys_id=247fbaa9db58dbc01dcaf3231f96190c&amp;amp;view_source=searchResult" rel="nofollow"&gt;https://community.servicenow.com/community?id=community_question&amp;amp;sys_id=247fbaa9db58dbc01dcaf3231f96190c&amp;amp;view_source=searchResult&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2019 18:23:01 GMT</pubDate>
      <guid>https://www.servicenow.com/community/service-management-forum/checking-for-attachments/m-p/400485#M16823</guid>
      <dc:creator>AlokD6499012040</dc:creator>
      <dc:date>2019-07-25T18:23:01Z</dc:date>
    </item>
    <item>
      <title>Re: Checking for attachments</title>
      <link>https://www.servicenow.com/community/service-management-forum/checking-for-attachments/m-p/400486#M16824</link>
      <description>&lt;P&gt;So... what I found out was that the File Attachment Field is a mess.&lt;/P&gt;
&lt;P&gt;When the field is empty for the first time, it is ACTUALLY empty, so you can use the business rules condition like "IF FIELD IS EMPTY" and it'll work.&lt;/P&gt;
&lt;P&gt;The problem is, when you upload a file and then delete it, the field doesn't become empty again. Instead it deletes the file from sys_attachment table &lt;EM&gt;(as expected)&lt;/EM&gt; but the field itselft stays with the value of the sys_id of the last file &lt;STRONG&gt;(don't ask me why)&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;So I had to make a Insert/Update business rule with a script that searches for the sys_id of the file on the sys_attachment table, like this:&lt;/P&gt;
&lt;DIV&gt;&amp;nbsp;var att = new GlideRecord('sys_attachment');&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;att.addQuery('sys_id',current.u_file_attachment_1);&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;att.query();&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(att.getRowCount()&amp;gt;0){&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;current.setValue('u_choice_1','true');&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}else{&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;current.setValue('u_choice_1','false');&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Then I had to make an onDisplay business rule to see if the 'u_choice_1' is true or false. If it's false, it shows a message saying that the file is missing.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Thanks for the help everyone.&lt;/DIV&gt;</description>
      <pubDate>Mon, 05 Aug 2019 13:32:40 GMT</pubDate>
      <guid>https://www.servicenow.com/community/service-management-forum/checking-for-attachments/m-p/400486#M16824</guid>
      <dc:creator>Samuel Macedo</dc:creator>
      <dc:date>2019-08-05T13:32:40Z</dc:date>
    </item>
    <item>
      <title>Re: Checking for attachments</title>
      <link>https://www.servicenow.com/community/service-management-forum/checking-for-attachments/m-p/400487#M16825</link>
      <description>&lt;P&gt;Glad you got it resolved!&lt;/P&gt;</description>
      <pubDate>Mon, 05 Aug 2019 13:35:58 GMT</pubDate>
      <guid>https://www.servicenow.com/community/service-management-forum/checking-for-attachments/m-p/400487#M16825</guid>
      <dc:creator>Allen Andreas</dc:creator>
      <dc:date>2019-08-05T13:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: Checking for attachments</title>
      <link>https://www.servicenow.com/community/service-management-forum/checking-for-attachments/m-p/400488#M16826</link>
      <description>&lt;P&gt;Hi &lt;SN-MENTION class="sn-mention" table="live_profile" sysid="71826ac1db8abb805129a851ca9619a9"&gt;@Samuel Macedo&lt;/SN-MENTION&gt;&amp;nbsp; ,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope you are doing good.&lt;/P&gt;
&lt;P&gt;I have used this script for my requirement and it is working good for showing messages. But, when I delete the attachment from the field, and saving the form&amp;nbsp; it is not showing the message even document field is empty. Could you please help me on this?&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2021 12:34:08 GMT</pubDate>
      <guid>https://www.servicenow.com/community/service-management-forum/checking-for-attachments/m-p/400488#M16826</guid>
      <dc:creator>Ajay37</dc:creator>
      <dc:date>2021-01-08T12:34:08Z</dc:date>
    </item>
  </channel>
</rss>

