Hi there, I am trying to create an expression rule that returns true if a document is not null, and has an ID attached to it. The expression rule is used to determine an XOR node to go to the document deletion node to delete the document if it exists, or to move to the end node if it has already been deleted. Right now, I am using a plugin isObjectExists() and it does work correctly but my supervisor wants me to improve the code to not use that plugin, any ideas for what to do?Here is the expression rule I created, it currently works how I want it to but I want to avoid using the plugin, any help is appreciated!
Discussion posts and replies are publicly visible
Multiple threads on this topic:
So those also suggest a plugin which I cannot do.
You have no plugins installed in your environment?
Content Tools is a pretty common one.
Hello nickk1385 ,
You can use getcontentobjectdetailsbyid() function to check if the document exists or not.
If it does not exists, you would see "No object with this ID has been found" as an output.
I do not know of any way to determine document existence without a plugin.
But wait ... in the applications I build, I always store meta data to the database, and whenever a file is created or deleted, I use that meta data to perform that activity. So I never get into a situation where I need to check whether a file exists for some random id.
Instead of solving the problem, I avoid it altogether.
It is installed but my supervisor asked me to avoid using Plugins for this story. It's annoying I know but that's why I asked here to see
Stefan Helzle said:I do not know of any way to determine document existence without a plugin.
agreed - off the top of my head i think it maybe can't be done (other than MAYBE some hack utilizing unsupported functionality, which is WAYYYYY off-limits if you're already not even allowed to use plug-ins).
Seriously though, OP - have your "supervisor" call me and tell me why they're not allowing people to use plug-ins. It's an absolutely ridiculous requirement. You can quote me on that.
I also shared my own utility rule most recently here. (it uses the "object existence" plug-in as well as null-check all wrapped together in a nice general expression rule.) I stand by my assertion that this really does require the use of a plug-in (at least for a solution that doesn't cause an error to be thrown).
In my experience, simple works for me - my checks only convert the document object to string which equals "[Document:]" for nulls. Have not had any issues with this yet.
or( rule!APN_isEmpty(ri!doc), tostring(ri!doc)="[Document:]" )
Is an option to create your own plugin?
Anyway , in the post you can find different options to handle this case.