Forum Discussion
WendyShoef
7 years agoQrew Cadet
What is wrong with this formula?
var text thisText = [Body];
$thisText = SearchAndReplace( $thisText, "[PC]", [Case - PC Full Name]);
$thisText
var text thisText = [Body];
$thisText = SearchAndReplace( $thisText, "[PC]", [Case - PC Full Name]);
$thisText
- QuickBaseCoachD7 years agoQrew CaptainWendy, are you saying that the formula has invalid syntax and won't save or does not work. I have used upper and lower case in the formula variable names and they work fine.
and btw, you can chain these formula variables so each one refers to the previous one, so that you can successively replace the fields. - WendyShoef7 years agoQrew CadetI get an error.
Inside the formula it says "Expecting text but found Boolean"
On save I get this error:
There are extra characters beyond the end of the formula.
var text thisText = [Body];
$thisText = SearchAndReplace( $thisText, "[PC]", [Case - PC Full Name])
$thisText
I have tried it with and without a semi-colon after the ) on the line of $thisText.
FYI: I did just write a .js script file using the [iol] method to do all of the search and replace, format the dates, and then write the value back to the field. After a little bit of tinkering with your API, it all was pretty simple. I know you have answered a couple of my other questions (it's all related) and want to say thanks. - QuickBaseCoachD7 years agoQrew CaptainSorry, I was being a bit stupid, but also you did not post your error message.
var text thisText = [Body];
var text PCReplace = SearchAndReplace( $thisText, "[PC]", [Case - PC Full Name]);
$PCReplace - WendyShoef7 years agoQrew CadetSo you can't write a new value to the variable using a function? You need to declare a new variable on each line?
- QuickBaseCoachD7 years agoQrew CaptainThen once that is working you grow the formula larger and feed the previous formula variable into the next.
var text thisText = [Body];
var text PCReplace = SearchAndReplace( $thisText, "[PC]", [Case - PC Full Name]);
var text DeliveryReplace = SearchAndReplace($PCReplace, "[Delivery Method]",[Delivery Method]);
var text CaseIDReplace = SearchAndReplace($DeliveryReplace, "[Case ID]", [Case - Case ID]);
$CaseIDReplace - QuickBaseCoachD7 years agoQrew Captainyes, exactly. you can use short names if you like, such as
A
B
C
D etc - WendyShoef7 years agoQrew CadetGood to know for future.
The benefit to the .js file is that I created a function that I can pass in a table, RID, and field variables so I have started using the same file in multiple places. - QuickBaseCoachD7 years agoQrew CaptainWhen you only have a hammer, every problem looks like a nail. I do not come from a coding background so I'm a native kind of guy so I solve native. I also rationalize that apps will be more easily supported in the future when your eventual successor inherits support for it, if there is less non native code, but to each their own. :)
- WendyShoef7 years agoQrew CadetI'm a web developer but in my current position I'm now the database girl! I always try to use native solutions because it is easier for support questions (and at worst, if I find a bug I can report it). Between the date formatting and having to use this same formula on multiple fields just once on adding a record across a few tables, it just seemed easier to only have to update one file instead of all the extra fields if we added a new variable. That's my DRY coding practices at play.
I couldn't find any documentation anywhere on the variable thing. I honestly tried looking and Google searching for quite a bit trying for a native solution. I probably would have used this method and made it work, but in the end it was probably good that I dove into the API anyways. I have some future integrations to do, so at least I got some practice.
Coming from Access or PHP/MySQL, I'm not used to having limitations. Quick Base has a learning curve but luckily there's more than one way to accomplish anything. - QuickBaseCoachD7 years agoQrew CaptainWe come from different directions and just meet in the middle somewhere. Here is some help on formula variables.
https://help.quickbase.com/user-assistance/formula_variables.html