Validating empty excel file upload

Hi, how to validate an empty excel file while uploading using file upload component. Parse Excel to CDT smart service fails if the excel sheet is blank. 

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer
    Hi ,
    I guess if you have to validate and check whether the uploaded excel is empty, you can use the below logic in a rule that executes in the process model(in a script task node) after submission of the form (because only after submission the document can be accessed for any validations). If the rule returns any validation, the flow has to loop back to the UIT without taking the parse excel to cdt node path.

    -----------------
    with(
    local!excelData: readexcelsheet(
    ri!document,
    0,
    0
    ),
    local!excelDataOnSuccess: if(
    toboolean(
    local!excelData.success
    ) = false(),
    null,
    remove(
    local!excelData.result,
    where(
    a!forEach(
    items: local!excelData.result.values,
    expression: length(
    fv!item
    ) = 0
    )
    )
    )
    ),
    if(
    rule!APN_isNullOrEmpty(
    local!excelDataOnSuccess
    ),
    "Uploaded document is empty",
    if(
    length(
    local!excelDataOnSuccess.values
    ) <= 1,
    "Uploaded document doesn't have data",
    {}
    )
    )
    )
    ------------------
    Here ri!document is of type document,the string that the rule returns(if that string it is not null), it can be displayed as a rich text on the UIT on loop back. I hope this might help you.

    Thanks,
    Athira
Reply Children
No Data