Hi
Looking through the responses for the Substitute function. It looks as if you have subsititute function in a "On Select" of a Button you must use Set(varfirstSubstitution,Substitute(<original string>,<string to replace>,<replacement string>)) and varfirstSubstitution holds the updated string.
If you use the substitute function elsewhere the Substitute(<original string>,<string to replace>,<replacement string>) and <original string > has been updated.
Am I correct ?
Thanks
Nigel
Solved! Go to Solution.
hi @NigelP the original string both cases should not change. if you have a variable "Some string" when you substitute the string whether onselect or in a label the variable will remain, substitute give you a new output. this is my understanding,
have la look at this
Set(_String,"This is a string") and assign the variable to a label
Substitute the string Set(_SubstitudedString, Substitute(_String,"string","what")) and assing the variable to anopther label
the add both variable to a single label, you can see the _String variable remains unchanged.
Is you rexpereince different?
Hope this helps
Substitute is a Function that returns a substituted string. It does not alter the original string.
If you use substitute on a non-behavioral property (for example, the Text property of a label), it will use the results of the function.
Example - a Label Text property: Substitute("My Dog is Brown", "Dog", "Horse") will display My Horse is Brown in the label.
If you use Substitute in a behavioral action (an OnSelect for example), then this implies you are going to do something with it.
Example: Set(myVar, Substitute("My Dog is Brown", "Dog", "Horse") ) will give you a variable with My Horse is Brown in it.
Also worth noting, substitute can be chained (as with almost all functions in PowerApps). So the following in a Label Text property:
Substitute(Substitute("My Dog is Brown", "Dog", "Horse"), "Brown", "White")
would display My Horse is White
I hope this is helpful for you.
hi @NigelP the original string both cases should not change. if you have a variable "Some string" when you substitute the string whether onselect or in a label the variable will remain, substitute give you a new output. this is my understanding,
have la look at this
Set(_String,"This is a string") and assign the variable to a label
Substitute the string Set(_SubstitudedString, Substitute(_String,"string","what")) and assing the variable to anopther label
the add both variable to a single label, you can see the _String variable remains unchanged.
Is you rexpereince different?
Hope this helps
Substitute is a Function that returns a substituted string. It does not alter the original string.
If you use substitute on a non-behavioral property (for example, the Text property of a label), it will use the results of the function.
Example - a Label Text property: Substitute("My Dog is Brown", "Dog", "Horse") will display My Horse is Brown in the label.
If you use Substitute in a behavioral action (an OnSelect for example), then this implies you are going to do something with it.
Example: Set(myVar, Substitute("My Dog is Brown", "Dog", "Horse") ) will give you a variable with My Horse is Brown in it.
Also worth noting, substitute can be chained (as with almost all functions in PowerApps). So the following in a Label Text property:
Substitute(Substitute("My Dog is Brown", "Dog", "Horse"), "Brown", "White")
would display My Horse is White
I hope this is helpful for you.
Hi @RandyHayes ,
Im using substitute as same approach you mantioned.
Substitute(
Substitute(
Substitute(
Substitute(
"Product (Mobile) SERIAL_NUMBER booked over to USER and location updated from OLD_LOCATION to NEW_LOCATION",
"SERIAL_NUMBER",
serialNumber
),
"USER",
varUserForMobileBookover.Result
),
"OLD_LOCATION",
oldLocation
),
"NEW_LOCATION",
varChangedLocationMobileBookover
)
And I have check every variable I'm using in here are having text value in them.
But still this portion of my code is throwing unknow error.
I dont know whats going wrong with it.
Can you suggest ?
User | Count |
---|---|
261 | |
127 | |
99 | |
48 | |
47 |