Author Topic: Looping vs building requests  (Read 1449 times)

johnlewisdesign

  • Member
  • *
  • Posts: 81
Looping vs building requests
« on: November 12, 2014, 08:22:50 AM »
Hi guys

Everything I need to do requires 16 hours of loops it seems. Is there a way to build ONE REQUEST with MULTIPLE ITEMS then send ONE REQUEST? At the moment it's

loop
  validate qb plugin
  close open sessions
  open qb session
  build request
  send request
  return result
Repeat til done

What I would like to do is

validate qb plugin
close open sessions
open qb session
  loop
    build request
  Repeat til done

send request
return result

Is this possible? All my things are 16k items etc, which means waiting a LONG time and praying the session stays up.

Thanks,

John

Jerel Malong

  • Global Moderator
  • Member
  • *****
  • Posts: 97
Re: Looping vs building requests
« Reply #1 on: November 12, 2014, 08:49:46 AM »
Hi John,

Your "Like to do" method is actually what i was going to recommend doing. Not sure why you are doing the loop currently as is. You only need to validate the plug-in at the start, as well as end any previous sessions and start a new one.

Geoffrey Gerhard

  • Guru
  • Member
  • ****
  • Posts: 468
Re: Looping vs building requests
« Reply #2 on: November 12, 2014, 09:42:31 AM »
Your post and Jerel's reply both remind me of questions I've never answered for myself.

1) What's the point of evaluating PCQB_EndSession in one step, then evaluating PCQB_BeginSession (...) in the following step?

I can see where that might have been useful when QBOE was the target, since its token-based sessions were prone to time-outs. But it's a HUGE time-sink when a session is already open. And if you always end the session when you're through, why add the end session?

1a) What happens if you issue a BeginSession without ending the previous session?

2) Under what condition does the plug-in support multiple requests? Evaluating PCQB_RqNew followed by PCQB_SGetXML( "Request"  ; "" ) shows only the XML of the new Request. Does the plug-in retain a stack that's not revealed by PCQB_SGetXML?

Geoffrey Gerhard
Creative Solutions Incorporated
14000 Creekside Drive
Matthews, NC  28105
704) 814-6852

Chris Turner

  • Administrator
  • Member
  • *****
  • Posts: 28
    • Productive Computing, Inc.
Re: Looping vs building requests
« Reply #3 on: November 12, 2014, 10:00:48 AM »
Hi Geoff, let me address your questions:

1) What's the point of evaluating PCQB_EndSession in one step, then evaluating PCQB_BeginSession (...) in the following step?
A) Calling PCQB_EndSession ensures that the active session currently held (if there is one) is gracefully closed, setting up the environment for the PCQB_BeginSession( ... ) call, because...

1a) What happens if you issue a BeginSession without ending the previous session?
A) ... if BeginSession is called a second time without calling EndSession, an error occurs and is reported. Intuit development guidelines dictate that every BeginSession has a corresponding EndSession, and a new call to BeginSession should not be made until the previous session is ended.

As an aside, we advise as a good practice to make an EndSession call prior to the BeginSession call in the case of an incomplete session, such as cancelling out during debugging, or an Exit Script call or Halt Script call made before calling an EndSession call... There are a number of scenarios in which the session may unintentionally be left open, and so as a precaution, we call PCQB_EndSession just before PCQB_BeginSession.

2) Under what condition does the plug-in support multiple requests? Evaluating PCQB_RqNew followed by PCQB_SGetXML( "Request"  ; "" ) shows only the XML of the new Request. Does the plug-in retain a stack that's not revealed by PCQB_SGetXML?
A) A "multiple request" scenario would be a succession of requests within the same session, which follows the following workflow:

Begin Session
Loop
  New Request
  Fill request
  Execute request
  Handle results
  Loop until done
End Loop
End Session

Calling PCQB_RqNew clears out the xml currently in the request buffer and instantiates a new request. As it stands, the standard Rq and Rs functions have no support for making a number of requests that are executed with a single PCQB_RqExecute command (as described in johnlewisdesign's "Like to do" workflow).
Chris Turner
Product Support Specialist
Productive Computing, Inc.

johnlewisdesign

  • Member
  • *
  • Posts: 81
Re: Looping vs building requests
« Reply #4 on: November 12, 2014, 10:21:51 AM »
Thanks for responses,


That was a brain dump - I am not validating multiple times (my bad, should be one under that), I was pointing at the huge XML file and send once part - so basically you can't build one big XML file and send it in one hit then? Obviously I make a silent script and run it using RDC so it runs regardless, but I've come in to find FileMaker crashed out at 10% before now.

I've got 10k stock to remove, then 3k invoices to remove and re-add before Friday which is - at the moment - unrealistic. Any time savers would be hugely beneficial for me right now.

Thanks guys!

John
« Last Edit: November 12, 2014, 10:25:46 AM by johnlewisdesign »

Geoffrey Gerhard

  • Guru
  • Member
  • ****
  • Posts: 468
Re: Looping vs building requests
« Reply #5 on: November 12, 2014, 12:28:05 PM »
I asked the first question because I explicitly create/destroy a $$SessionFlag. All scripts check that value before evaluating the Begin/EndSession calls and thus reduce the time it takes when debugging and/or halting a script might have left a session open.

The second question was relevant because Intuit's documentation seems to say you can bundle requests. My experience was that it wasn't supported when I tested it with raw qbXML, but I wasn't sure if the lack of support was a plug-in or API restriction, and whether the restriction could be surmounted if I used native PCQB_function calls to create multiple requests. This is not the first time that Intuit docs don't match reality--I notice they now have a disclaimer that some documented features are not implemented/fully functional.

Thanks, Chris!

Geoffrey Gerhard
Creative Solutions Incorporated
14000 Creekside Drive
Matthews, NC  28105
704) 814-6852