Having some difficulty retrieving counterId={counterId}
in the following API method:
https://{instance}/{collection}/{project}/_apis/build/definitions/{definitionId}?counterId={counterId}&api-version=4.1
Reference:
https://learn.microsoft.com/en-us/rest/api/azure/devops/build/definitions/reset%20counter?view=vsts-rest-tfs-4.1
I am trying to retrieve the counterId in order to reset it.
Is there any way to retrieve the counterId?
I’ve found a solution.
I can reset the counter by prefixing the custom variable.
Also if using a custom variable e.g $[counter(001)], to reset the counter increment the custom variable to $[counter(002)]
Related
I'm very new to Lua, I'm working with it on an io controller which has strict limits on script sizes so I need to work within these limits.
I have a number of relays which I am controlling (1-64). I need to switch off a relay when an event happens, but the relay I'm switching off can change.
I have a variable that holds the relay number and I need to turn off this relay.
I can achieve this using I statements:
if variable = 1 then
io.relay1=0 //Turns off the relay
end
else if variable = 2 then
io.relay2=0 //Turns off the relay
end
However, this will very quickly become a large script when repeated for the 64 relays. Is it possible to address the relay using the value of the variable as the relay name? Similar to the below:
io.relay{variable}=0 //Turns off the relay1/2/3/4/5 etc. depending on the value of variable
Alternatively, is there another way to keep the code compact?
Use
io["relay".. variable]=0
However, this creates a string every time.
If you can change how io works, a better solution would be to make io.relay a table and then simply do io.relay[variable]=0.
To avoid the string allocation issue that lhf's answer has, you could pre-generate a string table and index into that:
relay_names = {}
for k = 1,64 do
relay_names[k] = "relay"..tostring(k)
end
Then setting the IO states would look something like this:
io[relay_names[1]] = 1
If my database structure is like this:
and I have this:
ref = Database.database().reference().child(passUserID)
ref?.child("wins").updateChildValues("wins": numerator)
where numerator = (games played beforehand) + (games played after logging in), for the second statement it is giving me an error in the expression that I don't know how to fix.
Also if I try to do this instead:
ref?.child("wins").setValue(numerator)
it messes up my data bad and gives a bad instruction error.
The updateChildValues method takes a Dictionary. So you just need to call the method with a dictionary containing the key-value pairs you want to update, i.e.
ref = Database.database().reference().child(passUserID)
ref?.updateChildValues(["wins": numerator])
For more on how to read/write data to firebase realtime database, refer to: https://firebase.google.com/docs/database/ios/read-and-write
If you use .setValue triggers only in the beginning. Instead of .setValue use updateChildValues(.values/.childAdded/.childRemoved etc..) to update the values inside your tree. It will be executed whenever changes occurs to your node.
How to update particular value of child in Firebase DB
If I have an existing image, how can get a reference to its Image::Info object? In particular, I want to read an option (that was previously set using image.define(...)) from it using the [] operator.
If there is any other way to read a value set via image.define(...) from an image, that would be perfect as well.
The define method is the same as []=, so you can get the option value using [].
Let's say I have following code:
DacClass cl = new DacClass();
//init fields of DacClass()
this.Persist();
but when I run this code in any graph, I'm getting different errors. Why?
You can't create DAC item in db in current graph. As mentioned in T200 manual you should create instance of graph and in created instance to call method persist. Another option is to use method PXDataBase.Insert. The first option is preferable for case if you need insertion with graph logic. The second option is preferable for cases if you need perfomance.
I have field called ads_counter in my database, and I need to increase its value each time when this ad is rendered.
I tried to write a custom method and use it in the controller responsible for this data, but that didn't work. Are there any built-in methods to increase the value of a field in the database?
Yes, there is the increment method that you can call in your ActiveRecord.
For reference: increment
Edit:
To make it save directly use the increment!
You may use it this way:
instance.increment!(:ads_counter)
It automatically increments by 1
instance.increment!(:ads_counter, <number>)
It increments by number provided
You have the method increment! that increments an attribute and saves the record
your_object.increment!(:ads_counter)
Put this code in the show method of your controller.
You can try increment! method
object.increment!(:method_name)