Author Topic: Why many "setVariable" with the same variable?  (Read 1492 times)

Paolobkk

  • Member
  • *
  • Posts: 2
Why many "setVariable" with the same variable?
« on: February 22, 2013, 03:27:39 AM »
Hello everyone,

Just landed on this Forum looking for a little help on how to use the FM Books connector Plug-in.

I've downloaded all the documentation and demo file, and I've been studying for few days about how to script using the Plug-in functions.

Looking at the scripts of the demo file I've seen many script steps setting always the same variable:

Set Variable[$$Result; Value:PCQB_RqAddFieldWithValue( "CustomerRef::ListID" ; Customer::ListID )]
Set Variable [$$Result; Value:PCQB_RqAddFieldWithValue( "TxnDate"; Invoice::Invoice Date)]
Set Variable [$$Result; Value:PCQB_RqAddFieldWithValue( "PONumber";Invoice::PO Ref)]
Set Variable [$$Result; Value:PCQB_RqAddFieldWithValue( "DueDate"; Invoice::Due Date)]
Set Variable [$$Result; Value:PCQB_RqAddFieldWithValue( "ShipDate"; Invoice::Ship Date)] #Prep Line Items (Request)


I couldn't find any explanation on the use of this variable and I didn't notice any following script step where it's used for something.

Can anyone address me in the right direction? :o

Thanks and have a great day!!
FMPA11
FMS11
FMPA12
FMSA12

- “When you find yourself in a hole, quit digging.”
- "Some people learn by reading, some people learn by observation, ...and some people have to pee on the electric fence"

Geoffrey Gerhard

  • Guru
  • Member
  • ****
  • Posts: 470
Re: Why many "setVariable" with the same variable?
« Reply #1 on: February 22, 2013, 07:20:43 AM »
The Set Variable step provides a place to call the function. The variable name is irrelevant, and so is the scope--it could be $Whatever. Many people use the $$Result convention so that they can interact with QB in a subscript, and then check the value of $$Result in the calling script to be sure the interaction was successful.

Some argue that a stack of Set Variable steps is easier to read and understand than it would be to stack the calls up in a single Set Variable's calc like this...

Set Variable[$$Result; Value:
PCQB_RqAddFieldWithValue( "CustomerRef::ListID" ; Customer::ListID )
PCQB_RqAddFieldWithValue( "TxnDate"; Invoice::Invoice Date)
PCQB_RqAddFieldWithValue( "PONumber";Invoice::PO Ref)PCQB_RqAddFieldWithValue( "DueDate"; Invoice::Due Date)
Set Variable [$$Result; Value:PCQB_RqAddFieldWithValue( "ShipDate"; Invoice::Ship Date) ]

...which would return the same result. The only result that's really relevant is the one returned by PCQB_RqExecute, which is what triggers the actual interaction with QB.

HTH!

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

Paolobkk

  • Member
  • *
  • Posts: 2
Re: Why many "setVariable" with the same variable?
« Reply #2 on: February 22, 2013, 06:57:45 PM »
Great!

Finally got it!

We are installing QB in our company and I have to integrate it with my FM11 database.

The documentation on FM books connector is technical and precise but I didn't find very helpful tutorials on scripting... so I have to dig in much more!  :-\

Thank you so much for your help! :)
FMPA11
FMS11
FMPA12
FMSA12

- “When you find yourself in a hole, quit digging.”
- "Some people learn by reading, some people learn by observation, ...and some people have to pee on the electric fence"

scstock

  • Member
  • *
  • Posts: 10
Re: Why many "setVariable" with the same variable?
« Reply #3 on: March 03, 2013, 07:57:25 AM »
I'm so glad someone asked this question! - thanks Geoffrey for the clear response too.