update variable with a query result

  • 0
  • 1
  • Question
  • Updated 3 years ago
  • Answered

Here is my code

http://pastie.org/10802782

Basically what I'm trying to do is a perform a query then assign a variable from the result so that I can use that variable in another query call. I'm sure I'm missing something simple. Thanks

Photo of chuck

chuck

  • 0 Points

Posted 3 years ago

  • 0
  • 1
Photo of chuck

chuck

  • 0 Points
Here is my updated code http://pastie.org/10802899 I'll explain how Im using this in case someone else needs something similiar. I have a table of tasks and multiple forms, i use the copy master detail to copy X amount of records, each record has a different form template. One one record there will be a date field that I want to grab from another record. To this I needed to get the related master record id then pass that ID to another Do_query to get the value i wanted from the correct record. So this does that but now Im stuck again and what I'm trying to do from here is take that date value and populate a date field on the current record but minus three days from that date and I need to exclude weekends and holidays. Is there any libraries in use by quickbase now that can do this or is there another way? Any help is greatly appreciated
Photo of chuck

chuck

  • 0 Points
All the references I find make custom datepickers and I just want to calculate it then enter the value without letting the user to select it. I'm fine with creating an array of the holidays but was hoping there was a way to get rid of weekends, so itll take the date, attempt to subtract 3 days, if thats a holiday or weekend, substract another day until isHoliday and isWeekend are both false.
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 29,924 Points 20k badge 2x thumb
There are several conceptual problems with your code. You are querying for a record whose [Record ID#] has a particular value. Although this query could at most return one record you are processing the XML response with an $().each loop. Rather than jump into correcting this and some other potential problems it would be best to answer these two questions

(1) What is the context in which this code is getting executed? What are the navigation steps that bring you to execute this code and where do the requestID and recordID variables get their value?

(2) What are the tables involved with this code and how are they related? What are the relevant field names and fids you are working with?
Photo of chuck

chuck

  • 0 Points
Hey Dan, good to see you're still around! Yes my setup is a little tricky. The value I'm trying to get is from within the same table (Tasks). There is a relationship to a Requests table. On a master request you'll have 12 related tasks. But each task has a different form, thus a different record for each form. I copy those records when adding a new request.

The end goal is: On record A I need to calculate a date thats 3 days before a date on record B. The way I get that is by the Related Request. So to get that I used Do_Query. I was expecting the XML response to only contain one record. I'd like to have the most efficient code but I'm not a pro so just doing what I can. Open to suggestions. so in the code once it gets the requestID from the first query. the second query uses that to get the proper record and correct date field value. Hope this makes more sense. I have all this now I'm just trying to exclude holidays and weekends which I got the weekends part last night, just need to create an array of holidays.
Photo of chuck

chuck

  • 0 Points
To answer my follow up comment I had about the dates in case anyone else needs it. This is what I'm using now to do this. Basicall just add the dates to exclude in the holidays object.

http://pastie.org/10805474