Forum Discussion

SergioSanchez's avatar
SergioSanchez
Qrew Trainee
6 years ago

API_DOQUERY Javascript add OR statement

I have the following piece of code (this is the part I am having issues with):

 db.rnaRequests.doQuery({
      rid: {GTE:rid},
      analysisCopyRequired: "1",
      requestType: {CT: 'Research'}
    })

The JS is working properly. I just need to add an OR statement to the "requestType" query: I need to pick records containing either Research or Bookings.... any idea on how to add that into the current code? Thanks and sorry for the silly question. I just inherited this JS file. 
  • Thanks a lot Chayce for such a prompt response. Almost there... but unfortunately it is only picking the 'Research' records and ignoring the 'Bookings'... Also, we would like to pick records under 'Research - Refresh' category as well, that's the reason of the usage of "CT" within the API call... any idea? 
  • Do you by chance have a link to the specific JS library you're using? Did you pull it from GitHub that you can provide here?

    Regardless of the above - can you provide your updated query object? 

    As far as the contains - you should be able to use the same format as you were for rid  - so 

          rid: {GTE:rid},
          analysisCopyRequired: "1",
          or: [{requestType: {'CT':'Research'}},{requestType: {'CT':'Bookings'}}]

    Chayce Duncan | Director of Strategic Solutions
    (720) 739-1406 | chayceduncan@quandarycg.com
    Quandary Knowledge Base
  • I would like to send you the js file we use. It is a local file, we don't pull from GitHub. Would you mind to let me know a way to share this privately? Thanks and regards. 

  • Hey Chayce. I just want to inform that your previous suggestion totally worked! :) I was having issues but it was because of some misspellings there... but again, overall your solution is working perfectly. Thanks a lot for your support. 
    • SergioSanchez's avatar
      SergioSanchez
      Qrew Trainee
      Including solution for further reference:

      db.rnaRequests.doQuery({

            rid: {GTE:rid},

            analysisCopyRequired: "1",

            or: [

                  {requestType: {'CT':'Research'},

                  {requestType: {'CT':'Bookings'}

            ],

          })