I have a query entity rule which works in DEV and QA with no issues. However i

Certified Senior Developer
I have a query entity rule which works in DEV and QA with no issues. However it fails with "Expression evaluation error at function a!queryEntity [line 2]: An error occurred while retrieving the data." in Production, but ONLY when the batch size is set to anything other than -1. The query is against a secondary datasource which tends to have latency issues at times. Note, there is much higher volume in Production that DEV and QA.

OriginalPostID-191331

OriginalPostID-191331

  Discussion posts and replies are publicly visible

  • @rogerp Would you be able to attach the logs, particularly at the time when the query is being made? The 'Caused By' in the logs will help the practitioners here to analyse the issue quickly and provide a resolution accordingly.
  • 0
    Certified Senior Developer
    Hi sikhivahans - which log file? The application log is empty.
  • It would be worth finding out the location of the logs as per your Appian instance and then the application-server.log in them. Ideally it would be <install_dir>/logs/application-server.log.

    If it's a cloud instance, you can navigate to the 'Home' tab and thereafter you can see a link named 'Access System Logs' on the left hand side.

    You are saying that the file is empty. Are you talking with respect to the above file? If that's the case, I would like to suggest you to regenerate the error so that log will record it (I guess the log file has been cleared earlier).
  • Hi rogerp63, Could you please verify if any of the data in production table for any of the columns is exceeding the max size of the length. We have once seen similar issue, where our Dev environments were not having the data as present in production. so when we tried to run the same in QA it errored out as the value its trying to cast is huge. Kindly check if any of the columns data exceeds the allowed values.. I recommend as "sikhivahans", mentioned looking into the application-server.log to see exception message, the caused by would give you exact reason why its failing.
  • Attaching the source code will be fruitful only when there is a difference (in areas such as code, plugins etc) across the environments. Else it might not help as per my knowledge.
  • 0
    Certified Senior Developer
    Below is the source code. It works when the batchSize is set to -1
    a!queryEntity(
    entity:cons!LAW_ENT_AP_INVOICE_SUMMARY,
    query:a!query(
    logicalExpression:{
    a!queryLogicalExpression(
    operator:"AND",

    filters:{

    if(ri!approvedQueue_bool,{

    a!queryFilter(
    field:"OBJ_ID",
    operator:"not in",
    value:apply(fn!todecimal,split(joinarray(index(rule!LAW_QE_getInvoicePOLine_overspent().data,"API_OBJ_ID",{}),"###"),"###"))
    ),
    a!queryFilter(
    field:"PO_RELEASED_FL",
    operator:"=",
    value:"Y"
    ),
    a!queryFilter(
    field:"BALANCED_FL",
    operator:"=",
    value:"Y"
    )},{}),

    a!queryFilter(
    field:"OBJ_ID",
    operator:"in",
    value:apply(fn!todecimal,split(joinarray(index(rule!P2P_QE_INV_getInvoiceReview_by_status(statusCde:cons!P2P_STATUS_INV_APPROVED).data,"lawObjId_dec",{}),"###"),"###"))
    ),

    if(isNull(ri!batch_num),{},
    a!queryFilter(
    field:"BATCH_NUM",
    operator:"=",
    value: ri!batch_num
    )),
    if(isNull(ri!isPayBatch_bool),{},
    a!queryFilter(
    field:"BATCH_NUM",
    operator:"not in",
    value: {cons!P2P_CFG_INV_BATCH_CA,cons!P2P_CFG_INV_BATCH_US}
    )),

    if(isNull(ri!operator),{},
    a!queryFilter(
    field:"OPERATOR",
    operator:"includes",
    value:ri!operator
    )),
    if(isNull(ri!vendorName),{},
    a!queryFilter(
    field:"VENDOR_VNAME",
    operator:"includes",
    value:ri!vendorName
    )),
    if(isNull(ri!vendor),{},
    a!queryFilter(
    field:"VENDOR",
    operator:"=",
    value:ri!vendor
    )),
    if(isNull(ri!invoice),{},
    a!queryFilter(
    field:"INVOICE",
    operator:"includes",
    value:ri!invoice
    )),
    if(isNull(ri!voucherNbr),{},
    a!queryFilter(
    field:"VOUCHER_NUM",
    operator:"includes",
    value:ri!voucherNbr
    )),
    if(isNull(ri!ponumber),{},
    a!queryFilter(
    field:"PO_NUMBER",
    operator:"includes",
    value:ri!ponumber
    )),
    if(isNull(ri!handlingCode),{},
    a!queryFilter(
    field:"HANDLING_CODE",
    operator:"=",
    value:ri!handlingCode
    )),
    if(OR(isNull(ri!thruDueDate_dt),isNull(ri!fromDueDate_dt)),{},
    a!queryFilter(
    field:"DUE_DATE",
    operator:"between",
    value:{ri!fromDueDate_dt,ri!thruDueDate_dt}
    )),
    if(AND(not(isNull(ri!thruDueDate_dt)),isNull(ri!fromDueDate_dt)),
    a!queryFilter(
    field:"DUE_DATE",
    operator:"<=",
    value:ri!thruDueDate_dt
    ),{}),
    if(AND(isNull(ri!thruDueDate_dt),not(isNull(ri!fromDueDate_dt))),
    a!queryFilter(
    field:"DUE_DATE",
    operator:">=",
    value:ri!fromDueDate_dt
    ),{}),
    if(ri!pastDue_bool,
    a!queryFilter(
    field:"DUE_DATE",
    operator:"<",
    value:today()
    ),{})



    }
    )},
    /*pagingInfo:ri!pagingInfo*/
    pagingInfo:a!pagingInfo(startIndex:1,batchSize:-1,
    sort:a!sortInfo(field:"DUE_DATE",ascending:true)
    )

    )
    )
  • 0
    Certified Senior Developer
    When I change the batchSize to 10 I receive the error "Expression evaluation error at function a!queryEntity [line 2]: An error occurred while retrieving the data." The application-server.log is still empty (see attached for screenshot). Note that this query takes approx 18 seconds to run.