I want to create a generic process model for update constant. I used update constant smart service as it required constant as input which is of type content constant. so i want to pass constant as process parameter.
is it possible or is there any other way to do this?
Discussion posts and replies are publicly visible
No, passing a reference to a constant as a process variable is not supported. Making this a generic process will not work.
sakshi97 said:i want to pass constant as process parameter.
There is no variable type called content constant, so its not possible
Hi sakshi97 ,When you try to pass as mentioned you will get Null as Constant ID in the Update Constants inputs.So It's not possible to do that thing!
I would as a general rule avoid updating constants and would suggest using a database field instead. Updating a constant creates a new version and having many versions of an object can cause performance issues down the line.
I echo Mathieu's warning that it's a good idea to not update general-use constants procedurally, except in rare special cases where you have a strong reason. I would point out, though, that the modern version of the Update Constant service actually does have a way to turn off "new versions", i.e. you can force a straight-up overwrite, which could be useful for constants that act merely as flags / toggles, where no version history would ever be relevant or useful.
A while ago I figured out a way to update constant by name (if you have a way of passing a valid constant name into your subprocess) - this uses a combo of tricks to look up the constant's ID (note this requires at least one plugin), and the ID is passed to the smart service in lieu of a direct reference to the constant. Keeping the new data type in line with the constant you're updating will be up to you - use at your own risk i guess
extract( getcontentdetailsbyuuid( getconstantorruleuuidbyname("TEST_CONST_FOR_UPDATE") ), "Id: ", ", Parent:" )