I created a custom tool in Pro. I used calculate value variable as extent parameter. Here I pull coordinates from a string as xmin ymin xmax ymax. It works as expected in Pro as it overrides the tool's environment extent.

I published it to portal but it does not work there. The tool ignores the extents in the parameter and tries to process the entire dataset. I did this to be able to enter extent parameters if I choose to run the tool as a service from REST endpoint. The REST endpoint also ignores the extent parameters I enter in context field.
Can anyone advise the right way of doing it?
Thanks