Forum Discussion

MelissaFreel's avatar
MelissaFreel
Qrew Member
12 months ago

Jinja Templates to isolate a token

Hi:

I am trying to build webhook pipline where I need to supply a token that is returned from the request.  The token is embedded in a long text string separated with delimiters.  When I go to use this token, I am able to use a split jinja template to get at the "front" part of the token. 

{{b.content.split(':"')[1]}}

However, there is another irrelevant text string after the token separated with a ','   Can somone suggest how I nest my jinja templates to do this and do I do another "split" or???

Please and thank you!

Melissa 



------------------------------
Melissa Freel
------------------------------

4 Replies

  • An example of the string will help

    {{ b.content.split(':"')[1].split(',')[0] }}


    Based on gut feel , you want to split the string twice, once with : and then with , . 
    Above is based on scenario , these two delimiters would always be present otherwise this will throw an error. 



    ------------------------------
    Prashant Maheshwari
    ------------------------------
    • MarkShnier__You's avatar
      MarkShnier__You
      Icon for Qrew Legend rankQrew Legend

      I pasted Melissa's whole question into chat GPT,  my only change was to insert the word QuickBase before the work Webhook.  

      It gave me this response  with a handy button to copy the code.


      To extract the token from the long text string and remove any irrelevant text after it using Jinja templates, you can nest another split function to further split the string using the comma (,) delimiter. Here's an example of how you can achieve this:

      {{ b.content.split(':"')[1].split(',')[0] }}

      In the above code, b.content.split(':"')[1] is used to split the text string and retrieve the token. Then, split(',')[0] is nested to split the resulting token again using the comma delimiter and retrieve the relevant part before the comma.

      Make sure to adapt this code snippet according to your specific implementation and the structure of your long text string.

      ......... it's more than a little spooky.  



      ------------------------------
      Mark Shnier (Your Quickbase Coach)
      mark.shnier@gmail.com
      ------------------------------

    • MelissaFreel1's avatar
      MelissaFreel1
      Qrew Cadet

      Prashant:

      Thanks!  This is what I was thinking, but was unsure of the "seperator" to join the two splits.  You gave me the "." and that is what I needed. 



      ------------------------------
      Melissa Freel
      ------------------------------
    • MelissaFreel1's avatar
      MelissaFreel1
      Qrew Cadet

      Mark!  Why didn't I just do that?  I used chatGPT to write a power automate for a series of excel files.....I should have just applied the same problem solving!.  

      Hope all is well with you!

      Melissa



      ------------------------------
      Melissa Freel
      ------------------------------