0

How to Parse Text Into Multiple Form Fields on Button Click

I have a field with text that I am trying to parse into multiple form fields when a button is clicked.  For example I'd like to break the following text out into the fields below:

Buy 1 AAPL Apr 01 '21 $121 Call Executed @ $2.19

OrderType = Buy

Quantity = 1

Symbol = AAPL

Date = 04/01/2021

Strike = $121

SecurityType = Call

Price = $2.19

Thanks for the help.

2 replies

null
    • Fred
    • 3 yrs ago
    • Reported - view

    You might not need a button if each record has the base text string that you want to parse. Let say you have a field called origText. Then you would need to create an array out of it with split command. So you a new field, newArray, would look like:

     

    split(origText," ") <-- this puts a comma in place of each space found and creates an array.

     

    Then you can update your fields like OrderType to be:

     

    item(newArray,0) <--everything starts at 0, this pulls out Buy

     

    Then update the remaining fields to pull the correct spot.

     

    If you really want the Date to be a date field then I haven't quite worked out. It is more flexible to have the month, day, year separated. Maybe someone can help here.

     

    You may want to drop the $ in front of Strike and Price so they can be numbers, but that is up to you.

    • dmccormick
    • 3 yrs ago
    • Reported - view

    Thanks for the suggestion, that is very helpful.  I will be copying in the text from a trade alert so I think I need the button so I can just update the current record.