Skip to main content
June 2, 2022
Question

Document Name Storing with document name, extension and size instead of only document name.

  • June 2, 2022
  • 12 replies
  • 0 views

Hi,

I am validating just uploaded document size  with below code:

if(
rule!APN_isBlank(ri!documentId),

{
fullName: null(),
name: null(),
ext: null(),
size: tointeger(null())
},

a!localVariables(

local!value: a!fileUploadField(value: todocument(ri!documentId), target:cons!RMO_FOLDER_ALL_DOCUMENTS, fileNames: fv!file),

local!fileDetails: tostring(local!value.contents.value.filename),

local!fileName: extract(local!fileDetails, "[name=", ", extension" )[1],
local!fileExt: extract(local!fileDetails, "extension=", ", size")[1],
local!fileSize: tointeger(extract(local!fileDetails, "size=", "]")[1]),
{
fullName: local!fileName & if(rule!APN_isBlank(local!fileExt), "", "." & local!fileExt),
name: local!fileName,
ext: local!fileExt,
size: local!fileSize
}
)
)

Issue: After clicking on submitting button, document name storing as [name=Document Name, extension=docx, size=3752844] instead of only document name in KC.

Can anyone let me know how to store only document name instead of all above details in KC.

    12 replies

    danny.verb
    June 2, 2022

    You must index into fv!file such as fv!file.name

    Docs

    June 2, 2022

    I already tried this but it's not helping me out. If I use  fv!file.name for filenames parameter validation is not happening on size. 

    suggest if you have any other thoughts!!

    danny.verb
    June 2, 2022

    Also, you really shouldn't have a fileuploadfield within a local variable

    mikes0011
    Brainy
    June 2, 2022
    Can anyone let me know how to store only document name

    You're misusing the "fileNames" parameter.  I can't even tell what you're *trying* to do with it, but what I can tell is that it's directly responsible for the behavior you describe.

    In short: fileNames is intended as an override for the name(s) of freshly-uploaded file(s).  Any text passed into this parameter will become the name(s) of the file(s) upon form submission.  The regular default is to not even use this parameter - it's completely optional and only needed if you want to provide an override, for example having the user type a document name to accompany an uploaded file.

    Instead you're passing in the raw value of "fv!file", which is a dictionary of information containing name, size, extension information for each uploaded file (as you're seeing in the document name being applied to your uploaded files).

    June 2, 2022

    Thanks Mike for the information. Please let me know if there is any other way to validate size on the just uploaded documents?

    mikes0011
    Brainy
    June 2, 2022
    Please let me know if there is any other way to validate size on the just uploaded documents?

    As I asked above - what's wrong with the standard way?