Trying to capitalize the first letter of variable ...
# 🤝help
f
hi. after i capture the name of the user, i want to run a code which capitalize the firsst letter of the firsnt name Am writing the folowing code: @workflow.userName.first=@workflow.userName.first.charAt(0).toUpperCase() + @workflow.userName.first.slice(1) it says: declaration expected. what am i doing wrong https://gyazo.com/34132583be2189f45ad86cb4ec053aac
w
Hi 👋 in your code card , you shouldn’t use the @
To target variables, juste use workflow.variable
f
let me try.....and thanks
wow.....so that worked!!
in the docs, it iss said to use {{workflow.variable}} and that was not working.......how do we know which is the correct way?
w
in an execute code card you don't need the brackets nor the @
but inside of the worfklow (in a text card for exemple) , if you want to use a variable, you can use either @worklow.variable or {{workflow.variable}}
f
hi.....thank you
but....now i am stuck again
when i use the insert record card, am having the same isssue. it is storing ass follows: https://gyazo.com/671e6c95ccc60e6a7a01aab673998373
i have tried @workflow.userName.first {workflow.userName.first}
and when i use {{ workflow.userName.first }} .... it gives me an explicit error
@wooden-beard-40210 please advise at your convenience....
w
Can you send the error and the logs ? And a screenshot of yo ur insert record card
f
am not getting any error logs when i use @workflow.userName.first or workflow.userName.first , the error here is logical since it inserts the text 'workflow.userName.first'..... as you can see
but i will paste the log
w
Okay okay I see
So send rather a screenshot of your insert record card
f
ok..one moment plz
w
And with this configuration you get {workflow.username.first} in yo tavle ?
f
yes
w
And what is the format of your variable username ?
f
Copy code
{
  "first": "James",
  "last": "Bond"
}
w
Okay , did you tried {{workflow.username.first}} ?
f
yes....and when i used {{}}, it gave me an explicit error
one sec...i will show ou that error
w
It seems to be a bug..
f
error: {{workflow.userName.first}} evaluated to Undefined
w
I will try when a come back to my pc
f
thank you so very much
@wooden-beard-40210 i solved the issue.... when i typed in: @userName.first, it worked
and it works well
personnaly i rather prefer to always use the javascript notation, with the brackets
f
i agree
w
but it's a matter of personnal taste i guess
f
i will follow your uggestion
🙂
one sec,...let me tr it out
it worked!!!!!!
danke!!
w
Niiiice !
f
hahah
w
You're welcom
f
awesome....you to!
i mean.....you have a great one
cheers
2 Views