How to handle the error when passing the wrong document id to document function

Certified Associate Developer



lets say im passing the id as 1 to 1000 range for example , as there is no document with that id it will show error right 

  Discussion posts and replies are publicly visible

Parents
  • The "Check Object Existence" plug-in referenced in Baji's comment has been deprecated and removed from the App Market.  Notably, every time it's run (at least any time it checks an invalid doc ID, and maybe even times it checks a valid doc ID), it creates a LONG error message in the system log file, so this is a good reason to avoid it.

    Instead, use the Content Tools plug-in and use the "get content object details by ID" function, which safely returns an invalid message (but not an "error") when a nonexistent ID is passed in.  I always suggest creating a system-global "document existence checker" expression rule, which would look about like this:

    and(
      a!isNotNullOrEmpty(ri!doc),
      tointeger(ri!doc) > 0,
      
      /*isobjectexists("Document", ri!doc)*/
      /* replacing with the below as the plug-in used is archived, and any check on an invalid doc ID results in a beefy log entry */
      
      find(
        "Type: Document,",
        getcontentobjectdetailsbyid(ri!doc)
      ) > 0
    )

Reply Children
No Data