Check Object Existence

Overview

This function helps in situations where the designer or developer has to act upon an Appian object (e.g. Document, Folder, Community, Knowledge Center).  Before doing any operations on the Appian object this function can be used to check whether the object exists.

Syntax: isObjectExists(typeOfObject, objectId)

Returns true or false based on the existence of the Appian object

Anonymous
  • Now that this plug-in has been archived, everyone should replace the functionality using the Content Tools plug-in, namely using the "Get Content Object Details By Id" function. 

    This function can check for the mere existence of an item at that ID, e.g.

    getcontentobjectdetailsbyid(ri!id) <> "No object with this ID has been found"

    but also, it can be used (in one pass) to check specifically for Document or Folder IDs, e.g.

    find(
      "Type: Document,",
      getcontentobjectdetailsbyid(ri!docId)
    ) > 0
    
    /* or... */
    
    find(
      "Type: Folder,",
      getcontentobjectdetailsbyid(ri!folderId)
    ) > 0

    As always, I recommend staging your own "helper expression rules" to handle null-checks and other housekeeping at the same time as calling the rule, to facilitate re-use and code-readability.  See my slightly older comment here for an example recipe.

  • Just realizing that the ultimate answer for this is to simply use the current function availalbe in Content Tools, which can easily return object type existence for an ID (and also doesn't clutter the tomcat logs).

    find(
      "Type: Document,",
      getcontentobjectdetailsbyid(ri!id)
    ) > 0

    And for folders, merely replace the string "Document," with "Folder," in the example above.  I like to create helper rules i.e. "rule!UTIL_docExists" (etc) to handle null-checking before calling the plug-in function.

    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
    )

  • I just noticed this too.  I note it hasn't been updated in over 9 years, so not much hope(?) of some future update that will avoid a log entry when an invalid doc ID is checked.  Boo.

  • since this is 6 months ago, u probably wont need it, but anyway.. ur giving a null value in the document() function or so it says, might wanna check that weird rule isNotEmpty() ur using, im saying 'weird' cuz why not just use isNotNullOrEmpty() function instead?

  • I was able to correct the issue by first checking for null or empty values in the variable and then by casting using tointeger. For some reason, returning a Document type as a value from a query will return the Document number, but will cause isobjectexists to fail, because a Document is not Long (Number (Integer)), however, tointeger() will correctly cast to the Document number.

  •  can anyone help me with this? Thank You Smiley


  • Is this compatible with 21.4v of Appian Cloud?

    Threw this error yesterday:
    =isobjectexists("Document",pv!documentZIP) (Expression evaluation error at function 'isobjectexists': The passed parameter(s) are of the wrong type. Received the type com.appiancorp.common.xml.JaxbConversionException: JAXB was not able to produce a value for typed value TypedValue[it=3,v=[Document:533750]] as java class java.lang.Long.)

    And when I checked the following manually in an unnamed ER: 
    isobjectexists("Document",533750) 
    Then this returns true.

    Any suggestions, please?

    Thank you.

  • Short information:
    If you check for an ID and there is no object of the defined type with this Id, it will create a log entry.
    I tried this function to search for all groupIds in a system.
    Idea was: loop and enumerate all IDs and then return the ids which are existing. yeah....

    -> I made our tomcat crash as i was creating 5 GB and more in log files because most groupIds i was checking are not in Use -> log entry -> huge log size in a short time.

  • thank you so much for this plug-in! I'm really surprised that there isn't a "native" function that does this.  Solves a major issue I've had between different environments that have duplicated tables, but not duplicated folders/documents :)

  • awesome. thank you for you input here