How can I take a LOCAL VAR (GoogleAddress) and break it into three new SUB VARs (STREET, CITY, STATE) so that I can execute a CRUD from a GOOGLE PLACES result.
My current screens local VARs are:
I am using google places to lookup and identify an address and storing the result in a local var "GoogleAddress" I want to take the data from GoogleAddress VAR and use the comma "," as a delimiter to take a full address such as (123 Main Street, Brooklyn, New York, USA) and assign the respective data to each of the following SubVAR...
I have tried java but cannot not assign the JS output to my local vars (Address,City,State) based on the debugger monitoring the local vars values :(
Here is the JS that ChatGPT gave me:
Thank you for any support on this one!
To get more specific, also you have the option to use String_split function that splits text by a delimiter that you choose. So in your case, a delimiter could be a comma, that i see what is delimiting your googleaddress variable.
Kind regards,
Sergio
Hi Josep,
you can achieve it just by using the substring function, in an assign node of a client action assign the new variables to a substing of the googleaddres variable.
For more information check its documentation:
https://success.outsystems.com/documentation/11/reference/outsystems_language/logic/built_in_functions/text/#Substr
hope it helps
Thank you for your suggestions - much appreciated. I have made progress.
Follow up question - How do ASSIGN the resulting TEXT values returned from the splitting action to my local variables [ADDRESS, CITY, STATE]. I am new to OS and not sure where exactly I can consume the resulting data. In the expression builder I do not see the resulting list or structure to use in a assign. Am I over complicating it?
My DEBUG results:
I am not seeing how I can make use of the values in the resulting structure list? My SPLIT action should consistently result in 4 list items = Address, City, State, ZIP, Country.
Thank you again for your quick reply!
you can select the text postion of the list instead of current, check image:
I tried that and this was the result... Do I have the wrong data type on my var?
just remove ".current" from the assigns, check closely my images :D
Thank you very much - I caught my mistake. The results are now as expected!
The Message below is a result of SplitString:
"Address: "+String_Split.List[0].Text.Value+" City:"+String_Split.List[1].Text.Value+" State:"+String_Split.List[2].Text.Value+" Country:"+String_Split.List[3].Text.Value
This is what I needed - thank you for your assistance that was VERY helpful for me today.
Have a great weekend!
- Joe
Great, glad to help you...and dont worry about the mistake I went through the same thing with this when I first used it xd
Have a nice weekend :)
The documentation online for SplitStr and SubStr are not great for amateurs like me.
Thanks!