How to find out whether a given ID is a Folder or a Document

Certified Lead Developer

I have an ID.  It's currently an integer.

I want to know if there's a Document with that ID, or if there's a Folder with that ID.  Why?  Because if I guess and try to put it in the document() function, it will crash if it's a folder.  If I guess and try to put it in the folder() function, it will crash if it's a document.

I've tried plugins, but the plugins have a super fun tendency to throw lots of Java errors destroying our logs whenever we try to find out if this stupid thing is a Document or a Folder.

Is there a way to do this out of the box?  I want a rule that receives an integer and outputs the word "Document" or the word "Folder" or the word "Neither" and DOES NOT PINK BOX no matter what integer is.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    AFAIK you want Content Tools, and probably its function getContentObjectDetailsById(), which will return a string containing various properties (including type) of the ID you passed in.

    I've whipped up a sample expression rule using this functionality that will return "Document" (plaintext) when the ID type is Document, "Folder" for a folder, and if no type is found, it will return the text "Invalid".  I forget off the top of my head whether any other object types will return (maybe KCs too?).  In any case it should work and hopefully won't clutter log files with too much junk, though that's usually something I worry about a lot later than getting functionality to actually work...

    a!localVariables(
      local!details: getcontentobjectdetailsbyid(ri!objectId),
      local!extractedType: extract(local!details, "Type: ", ", Created"),
      
      index(local!extractedType, 1, "Invalid")
    )

  • 0
    Certified Lead Developer
    in reply to Mike Schmitt

    I think my fix might be to use one custom plugin rule or the other (it doesn't matter which) in a script task I can configure to run as whoever designed the PM, then post the results as a rule input into the SAIL, because I can't process the info from WITHIN the SAIL.

  • 0
    Certified Lead Developer
    in reply to Dave Lewis

    I had a similar thought, it seems it might work but it seems like it's a pretty big work-around.  If your need for this is strong enough it might be worthwhile to try, of course.

Reply Children
No Data