Upload Multi Document Validation Failed 17.1

I have a function that works great with 7.11 but when we converted to 17.1. I get a Text into type FieldLayout error. I have tried puting the Text in a local but it is the isnull function(i beleave) that is wanting to covert it to a FieldLayout. In the Rule i have with the Attached code works great but when i add it to the Interface to validate the files and run it in Tempo it fails not sure what i am doing wrong or why it is trying to turn the Text in to a FieldLayout type.

Error: Expression evaluation error in rule 'nml_fileextensionvalidation' (called by rule 'nml_ui') at function 'or': Invalid index: Cannot index property 'uploadedDocumentName' of type Text into type FieldLayout
Code: is Attached


Any help word be appreciated!

OriginalPostID-271928

  Discussion posts and replies are publicly visible

  • Marieh, not sure I understand exactly what you're trying to do in this code, but it looks like you should have one (or many) a!fileUploadFields, but when you are running the validation rule, it should be checking the VALUE of that field instead of using the field layout within your or() statements. Right now it's trying to compare a file upload field with a text string which is likely causing your error.

    Couple of additional notes from your code:
    -An or() with a nested or() with no other logic is the same as one large or() statement. Thus, you don't need the nested or() in your first line
    -functions like or() and contains() return booleans by nature, so there is no need to wrap them in if() statements to return true/false
  • What im trying to do is get the file Name of the Document that was uploaded or being uploaded by the user and see if it is a PDF or not. Do you know of another way that i can get the file name of the Document that i pass in to my vaild function?
  • If you put

    a!fileUploadField(target: ri!target, value:ri!file)

    in a Expression rule and have a file thats uploaded already and the target of where it is located. Then Test the Rule you get back a list of items

    [@attributes=, label=, instructions=, required=, disabled=, target=, uploadedDocumentName=1319_SupportingDocumentation.pdf, uploadedDocumentSize=359.44 KB, validations=, clientErrors=, value=[Document:143334], saveInto=,labelPosition=ABOVE, actions=, helpTooltip=, acceptedTypes=]

    The one i would like is the uploadedDocumentName this way i can look at the .pdf to see if it is one or not
  • 0
    Certified Lead Developer
    I put more details in the other thread linked in the prior comment, but the 17.1 issue boils down to the fact that the background properties returned by "a!fileUploadField" are different when viewed in the 17.1 front-end; and more confusingly, they still look the "old" way in the 17.1 interface designer, only the in-task rendering uses the new style so far. The rule I attached in the other thread contains code which will check for either and should work in both cases.
  • Please try below code for 17.1
    if(or(rule!APN_isEmpty(ri!file), or(a!fileUploadField(target: ri!target, value:ri!file).contents="", isnull(a!fileUploadField(target: ri!target, value:ri!file).contents))),
    false,
    if(contains({"pdf"}, a!fileUploadField(target: ri!target, value:ri!file).contents.extension),
    false,
    true
    )
    )

    Make you that this will not work while implementation and testing in rule or UI. This will work only if UI is executed in SITES or TEMPO