[Solved]Global usable Variable to be used in Binding.confing, Items-File and Rules

I’m getting information from a website. In order to get the information I need to send IDs, they are set in the binding.conf .
The received JSON String will either be parsed using JSONPATH Transform service directly in the Items File or within a rule(any suggestions for the “better” way?). In both cases the already used IDs are needed again. Is it possible to set them globally?

Put them into an Item and you can reference the Items within your rules and scripts. I don’t think there is any way to reference them for the Transform service.

Thanks for the reply.,
If I can’t use such an item in the transformation service AND without the possibility to use such in the configuration for the binding I’m stuck with "hardcoding"them in at least two places.So I’m going to miss the goal!

Perhaps if you gave more details and/or examples we can come up with some alternative. But with the little information provide, indeed you will have to set it two places if you continue doing it the way you are now.

Did I upset you in someway? I wasn’t intending to do that, SORRY for that!
All I can say is that I’m used to forums in which a lot of questions come up like “please write my code”, and I don’t want that. Because of that I’m trying to ask questions as generic as possible, this way others migth use the answers as well.
On my question I got an answer, not the one I hoped to get, but I got one.

Not at all! On my phone so I have to be terse sometimes and if you read any of my posts you will see I often fail to go back and re-read and edit them. I did not mean to come across as angry or anything like that.

The purpose of my response is intended to find out more about what you are trying to accomplish. Often times we all get so focused on how we think we should solve a problem and ask these technical questions to try to solve it in that one special way that we don’t consider that a completely different approach may work and work better. I’m more interested in helping people get to their real goal verses just answering highly specific technical questions.

I’m only asking for more information to see if there is a better way where perhaps you don’t even need the API IDs or something like that.

The “problem” I’m facing is like that:
The ID is definitely needed for the binding, no way around that.
The received JSON String is composed in a way where the ID is needed to get the associated data.
In my Items file it looks like:
"…{http="<[URLCall:60000:JSONPATH:$.values (%22TheNeededID%22).myvalue)]" …
It would by nice if I could call this “object” by an index, but it’s not an array.

Is there anything else about the data returned that would let you grab it using a regular expression and not need the ID? For example, if the ID is a certain number of characters and made up of digits characters and none of the rest of the fields are you would create a regex to pull the data instead.

Yes, that could probably been done. However, would you call that elegant?
Thanks for the effort, I’ll stick with the way I have done so far.

Elegant is in the eye of the beholder. I personally don’t see much a difference between regex and JSON or XML in many cases. Sometimes it can be easier to write and be much more efficient to pull a value out of an XML or JSON document using a regular expression than it is to parse the whole thing, particularly if there is only one value you care about in the whole document.

From that perspective, doing more work or having to repeat yourself just so you can use the “proper” transform seems less elegant to me than using the REGEX.

That being said, I would personally just hard code the ID in both places and not worry about it. :slight_smile: