Forum Discussion

Re: Order results returned in Pipeline search query

I stumbled upon this thread last night while looking for a similar solution. I found something that worked after tons of trial, error, and googling. Here's a screenshot. 

It takes the array of results returned in step B, looks for the one with the highest attribute for the field called "specificity_score" and returns that RID to a field in the action step. It's not exactly sorting results but if you were looking for the "earliest" record, you could set the attribute to a "created_date" or similar, and use a min() filter instead of max()

ex: 

{% set desiredrecord = b|min(attribute="created_date")%}
{{desiredrecord.desired_field}}
 



------------------------------
Melissa Doran
Jr. Solutions Consultant
Quandary Consulting Group
mdoran@quandarycg.com
------------------------------

4 Replies

  • Danny's avatar
    Danny
    Qrew Trainee
    This worked out great for me! Thanks a lot for sharing this, Melissa!!


    ------------------------------
    Danny
    ------------------------------
    • MelissaDoran3's avatar
      MelissaDoran3
      Qrew Cadet
      Glad I could help! This will definitely be an often-used element in my toolkit going forward!

      ------------------------------
      Melissa Doran
      Jr Solutions Consultant
      Quandary Consulting Group

      linkedin.com/in/melissardoran
      mdoran@quandarycg.com
      ------------------------------
  • ChrisJefferson's avatar
    ChrisJefferson
    Qrew Member
    I get an error when I try and do this, it says there are too many results and I should use LOOP. (there are only 400 records from the search) 
    A = Trigger
    B = Search Results
    C = Update Record.

    I am trying to return the max version number (field) from the contacts table so I can use it in a Fetch JSON query so it limits the results returned from the external source.
    Too obscure? :-)

    ------------------------------
    Chris Jefferson
    ------------------------------
    • MelissaDoran3's avatar
      MelissaDoran3
      Qrew Cadet

      If it's the maximum from all records on the table, I would suggest using a 'helper' table. 
      You would relate all the contact records to the one single record on that table.
      Related help table = 1 (Default this field to 1, so all contacts are automatically related to the only record on that table) 

      Then get the max version number through a summary up to the help table, then either
      a) reference the help table directly in your pipeline
      or
      b) If the contact records are already part of your pipeline, lookup the max version number from the help table down to the contacts table. 



      ------------------------------
      Melissa Doran
      Solutions Consultant
      Quandary Consulting Group

      linkedin.com/in/melissardoran
      mdoran@quandarycg.com
      ------------------------------