can we pass constant to process model as process parameter?

Certified Associate Developer

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

Parents
  • 0
    Certified Lead Developer

    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 Shrug

    extract(
      getcontentdetailsbyuuid(
        getconstantorruleuuidbyname("TEST_CONST_FOR_UPDATE")
      ),
      "Id: ",
      ", Parent:"
    )

Reply
  • 0
    Certified Lead Developer

    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 Shrug

    extract(
      getcontentdetailsbyuuid(
        getconstantorruleuuidbyname("TEST_CONST_FOR_UPDATE")
      ),
      "Id: ",
      ", Parent:"
    )

Children
No Data