<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Remove file immediately, if extension is not &amp;quot;PDF&amp;quot;</title><link>https://community.appian.com/discussions/f/general/25017/remove-file-immediately-if-extension-is-not-pdf</link><description>HI All, 
 
 I am using a!fileUploadField for uploads file, which has validated to allow only &amp;quot;PDF&amp;quot; file, 
 Our ask is, if uploaded file extension is not PDF, shall remove immediately, how i can do that? 
 
 Note:- file upload feature i have given on a</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Remove file immediately, if extension is not "PDF"</title><link>https://community.appian.com/thread/96917?ContentTypeID=1</link><pubDate>Tue, 28 Jun 2022 14:22:05 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:228b504d-b0fd-4eae-9ea9-3c7c5dc77f80</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;I would urge you figure out a way to disable moving between tabs/pages when the validation has an error, implementing a form-level validation component for visibility.&amp;nbsp; You could use the functionality Harshit and I suggest below to store into a local variable a flag that becomes &amp;quot;true&amp;quot; if any uploaded files have an invalid extension per your business rules.&lt;/p&gt;
&lt;p&gt;I &lt;em&gt;&lt;strong&gt;strongly suggest AGAINST&lt;/strong&gt;&lt;/em&gt; simply clearing out the &amp;quot;value&amp;quot; of the File Upload Field if the uploaded document&amp;#39;s extension is wrong, because the user experience will be exceptionally poor (they will simply see their uploaded file vanish with no explanation).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Remove file immediately, if extension is not "PDF"</title><link>https://community.appian.com/thread/96915?ContentTypeID=1</link><pubDate>Tue, 28 Jun 2022 14:10:19 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:2d08f983-8743-41ff-b4d3-3a3846b8ca46</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;This can be done by using the &amp;quot;content details&amp;quot; plug-in which can also access object properties by ID for freshly-uploaded files (though annoyingly the output is only plaintext so we must scrape the result).&amp;nbsp; I&amp;#39;ve switched to that method for the times when it&amp;#39;s truly necessary.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="java"&gt;/* Parent Rule =  UTIL_getNewUploadDocName */
a!localVariables(
  local!rawDetails: if(
    a!isNullOrEmpty(ri!doc),
    &amp;quot;&amp;quot;,
    getcontentobjectdetailsbyid(ri!doc)
  ),
  local!wholeName: index(extract(
    local!rawDetails,
    &amp;quot;[Name: &amp;quot;,
    &amp;quot;, UUID:&amp;quot;
  ), 1, null()),

  rule!UTIL_processDocumentName(
    docName: local!wholeName
  )
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="java"&gt;/* Child Rule = UTIL_processDocumentName (uses RegEx plug-in) */
a!localVariables(
  local!hasNoExtension: search(&amp;quot;.&amp;quot;, ri!docName) = 0,
  
  local!namePart: if(
    local!hasNoExtension,
    ri!docName,
    regexsearch(
      pattern: &amp;quot;.*(?=\.)&amp;quot;,
      searchString: ri!docName,
      regexFlags: &amp;quot;i&amp;quot;
    )[1].match
  ),
  
  local!extension: if(
    local!hasNoExtension,
    &amp;quot;&amp;quot;,
    regexsearch(
      pattern: &amp;quot;[^\.]*$&amp;quot;,
      searchString: ri!docName,
      regexFlags: &amp;quot;i&amp;quot;
    )[1].match
  ),
  
  a!map(
    name: local!namePart,
    extension: local!extension
  )
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Result:&lt;br /&gt;&lt;img alt=" " src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/11/pastedimage1656425459310v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;cc:  please consider adopting this method instead of the unsupported component-hacking that was formerly required for this functionality, at least in terms of what we recommend to people around here &lt;span class="emoticon" data-url="https://community.appian.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Remove file immediately, if extension is not "PDF"</title><link>https://community.appian.com/thread/96888?ContentTypeID=1</link><pubDate>Tue, 28 Jun 2022 08:11:24 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b87af45a-8690-4cef-ad53-e727a7b4ed0b</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;Be aware that accessing internal state of components like in TA_checkFileExtension is unsupported and can break without notice any time.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Remove file immediately, if extension is not "PDF"</title><link>https://community.appian.com/thread/96886?ContentTypeID=1</link><pubDate>Tue, 28 Jun 2022 07:59:20 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:53b3218f-fc4e-4741-9f46-f4e5546d28c5</guid><dc:creator>Harshit Bumb (Appyzie)</dc:creator><description>&lt;p&gt;Use the below code then.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!fileUploadField(
                label: &amp;quot;File Upload&amp;quot;,
                labelPosition: &amp;quot;ABOVE&amp;quot;,
                value: ri!document_doc,
                saveInto: {
                  ri!document_doc,
                  a!save(
                    ri!document_doc,
                    if(
                      rule!TA_checkFileExtension(document_doc: ri!document_doc)=&amp;quot;PDF&amp;quot;,
                      null,
                      ri!document_doc
                    )
                  )
                },
                target: cons!DA_DESIGNER_DOCUMENTS,
              )&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;br /&gt;TA_checkFileExtension&lt;/strong&gt; -&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;tostring(
  a!fileUploadField(value: ri!document_doc).contents.value.extension
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Remove file immediately, if extension is not "PDF"</title><link>https://community.appian.com/thread/96885?ContentTypeID=1</link><pubDate>Tue, 28 Jun 2022 07:54:02 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:dc3aca4d-1942-41e3-8063-4b90720ad7df</guid><dc:creator>nitin07</dc:creator><description>&lt;p&gt;that fine, if no document uploaded but issue only with to upload wrong file (other that PDF)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Remove file immediately, if extension is not "PDF"</title><link>https://community.appian.com/thread/96884?ContentTypeID=1</link><pubDate>Tue, 28 Jun 2022 07:51:29 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:43408b12-2fdf-488a-936a-e5ee2816ea67</guid><dc:creator>Harshit Bumb (Appyzie)</dc:creator><description>&lt;p&gt;But in that case, even if you leave it blank and try to move to the next page, you&amp;#39;ll end up not storing any value in it. As the required validation will not trigger if the field is not visible on the screen.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Remove file immediately, if extension is not "PDF"</title><link>https://community.appian.com/thread/96879?ContentTypeID=1</link><pubDate>Tue, 28 Jun 2022 07:34:17 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b793958e-6891-4ca8-be06-bc109c8c0c2b</guid><dc:creator>nitin07</dc:creator><description>&lt;p&gt;actually, my application design is multi pager, if i have applied any validation on certain page and move to another page, in that case, previous page validations not being trigger while saving records.. due to that system allows users to save NON PDF files as well.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Remove file immediately, if extension is not "PDF"</title><link>https://community.appian.com/thread/96878?ContentTypeID=1</link><pubDate>Tue, 28 Jun 2022 07:26:44 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:a2fb626b-13e9-49b8-9d81-37a57802549a</guid><dc:creator>Stewart Burchell</dc:creator><description>&lt;p&gt;The problem here is that there will be no indication to the User what the issue is as the file will have been removed which means the validation logic won&amp;#39;t trigger and the User won&amp;#39;t seen an error message. The UX at this point is that their file has disappeared with no indication why and they&amp;#39;ll think there&amp;#39;s a bug in the system and won&amp;#39;t trust it.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not sure that&amp;#39;s a good pattern to be aiming for.&lt;/p&gt;
&lt;p&gt;Systems that Users interact with should follow good &amp;quot;Dialogue&amp;quot; practices. The User asks the system to do something, the system replies accordingly. What you&amp;#39;re asking for breaks this good practice.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Remove file immediately, if extension is not "PDF"</title><link>https://community.appian.com/thread/96877?ContentTypeID=1</link><pubDate>Tue, 28 Jun 2022 07:20:54 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b2e7376a-ad44-4ce8-817c-afdf4ef60aef</guid><dc:creator>nitin07</dc:creator><description>&lt;p&gt;if user tried to upload wrong file (not pdf), instead of showing error message along with file, remove file from field and make it file upload field empty before save&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Remove file immediately, if extension is not "PDF"</title><link>https://community.appian.com/thread/96876?ContentTypeID=1</link><pubDate>Tue, 28 Jun 2022 07:17:41 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b231f543-2845-4890-90ad-5e4f4353e7a7</guid><dc:creator>Stewart Burchell</dc:creator><description>&lt;p&gt;What&amp;#39;s the use case for the &amp;quot;immediate removal&amp;quot;? If you implement validations that check for PDF only files, then the User cannot progress with the process which is the actual objective here. Is it just an optimisation you&amp;#39;re looking for to save the User from removing the current file before uploading a new one?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>