Author Topic: payroll items and rates  (Read 1302 times)

david1000

  • Member
  • *
  • Posts: 21
payroll items and rates
« on: October 03, 2012, 12:11:04 AM »
Hi, I have been using the script below to add payroll items and rates without a problem. However, I cannot set multiple payroll items and rates. I have tried a number of ways without success. Does anyone have any ideas how to do this?

Set Error Capture [ On ]
Set Variable [ $vResult ; Value:PCQB_EndSession ]
Set Variable [ $vResult ; Value:PCQB_RqNew( "EmployeeQuery" ;"" ) ]
Set Variable [ $vResult ; Value:PCQB_RqAddFieldWithValue( "ListID" ;payments::list_id) ]
Set Variable [ $vResult ; Value:PCQB_BeginSession( "" ; "" ) ]
If [ $$vResult ≠ 0 ]
Set Variable [ $vResult ; Value:PCQB_BeginSession( "" ; "" ) ]
If [ $vResult ≠ 0 ]
Exit Script [ ]
End If
End If
If [ 0 <> PCQB_RqExecute ]
Set Variable [ $vResult ; Value:PCQB_RqExecute ]
If [ $$vResult <> 0 ]
Exit Script [ ]
End If
End If
Set Variable [ $vEditSequence ; Value:PCQB_RsGetFirstFieldValue( "EditSequence" ) ]
Set Variable [ $vResult ; Value:PCQB_RqNew( "EmployeeMod" ;"" ) ]
Set Variable [ $vResult ; Value:PCQB_RqAddFieldWithValue( "ListID" ;payments::list_id) ]
Set Variable [ $vResult ; Value:PCQB_RqAddFieldWithValue( "EditSequence" ;$$vEditSequence) ]
Set Variable [ $vCounter ; Value:1 ]
Set Variable [ $vResult ; Value:PCQB_RqAddRelatedRecord( "EmployeePayrollInfoMod::Earnings" ) ]
Set Variable [ $vResult ; Value:PCQB_RqAddFieldWithValue( "Earnings::PayrollItemWageRef::FullName";payments::
payroll_item ) ]
Set Variable [ $vResult ; Value:PCQB_RqAddFieldWithValue( "Earnings::Rate"; payments::hourly_rate ) ]
Set Variable [ $vResult ; Value:PCQB_RqCloseRelatedRecord ]
Set Variable [ $vResult ; Value:PCQB_RqAddFieldWithValue( "EmployeePayrollInfoMod::UseTimeDataToCreatePaychecks";
"UseTimeData") ]
If [ 0 <> PCQB_RqExecute ]
Exit Script [ ]
End If
Set Variable [ $$vResult ; Value:PCQB_EndSession ]
Set Error Capture [ Off ]

Geoffrey Gerhard

  • Guru
  • Member
  • ****
  • Posts: 468
Re: payroll items and rates
« Reply #1 on: October 03, 2012, 06:13:06 AM »
I see you're setting a counter  as if you intend to loop through this part...

Set Variable [ $vResult ; Value:PCQB_RqAddRelatedRecord( "EmployeePayrollInfoMod::Earnings" ) ]
Set Variable [ $vResult ; Value:PCQB_RqAddFieldWithValue( "Earnings::PayrollItemWageRef::FullName";payments::
payroll_item ) ]
Set Variable [ $vResult ; Value:PCQB_RqAddFieldWithValue( "Earnings::Rate"; payments::hourly_rate ) ]
Set Variable [ $vResult ; Value:PCQB_RqCloseRelatedRecord ]

...but there's no enclosing Loop. I've never integrated multiple PayrollItem elements, but it appears you'll need to iterate through these steps until you've added them all to your request.

There's often good troubleshooting information available in the raw xml the plug-in generates. If you insert a step that sets a $$variable to PCQB_SGetXML( "Request" ; "" ) just above the If that contains the PCQB_Execute, you'll get that raw xml as the result. Feel free to post that result here if you want an extra set of eyes to look it over.

HTH!

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

david1000

  • Member
  • *
  • Posts: 21
Re: payroll items and rates
« Reply #2 on: October 11, 2012, 06:34:06 PM »
Hi Geoffrey, thanks for the reply and sorry for my slow reply - Ive been snowed under in another section of the project.
Yes, as you guessed, the counter was related to a loop.
However, the loop function failed and the response indicated it didn't want to accept multiple entries.
I will set up the loop version again and post the error to show the response.
Again thanks for your reply.