document upload check

There is a smart service in my interface known as document upload . When i am uploading any document , it should be in pdf or word format , basically I need to check that User can only upload a pdf or word document . If the user uploads document of different type it should throw the error . 

how to achieve this please explain or give some code snippet if possible .

Thanks in advance !

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer

    Hi, you can use this in validation.

    a!localVariables(
            local!invalidExtensions: difference(upper(fv!files.extension), {"PDF","DOCX"}),
            if(
              length(local!invalidExtensions) > 0, 
              "Attachments must be pdf or word files. Remove: " & 
              index(fv!files, "name", wherecontains(local!invalidExtensions, upper(fv!files.extension)), {}), 
              ""
            )
          )

Reply
  • 0
    Certified Senior Developer

    Hi, you can use this in validation.

    a!localVariables(
            local!invalidExtensions: difference(upper(fv!files.extension), {"PDF","DOCX"}),
            if(
              length(local!invalidExtensions) > 0, 
              "Attachments must be pdf or word files. Remove: " & 
              index(fv!files, "name", wherecontains(local!invalidExtensions, upper(fv!files.extension)), {}), 
              ""
            )
          )

Children
No Data