How to access PR_TaxProfileLocation

Hi Experts,

We are working on a script that will bulk import TaxProfiles into Payroll. We are utilizing the PR_TaxProfile_bus. But we need to get to PR_TaxProfileLocation. The Sage Help states that this can be accessed as oTaxProfileLocation (similar to oLines for SalesOrders etc.). But I am not able to get a handle to te oTaxProfileLocation object. Do I have to use a different name?

Thanks!

Bastian

  • 0

    Are you in Tax Profile Maintenance when running the script OR is it a BOI script?  If on the screen, appears this should work:

    'oTaxProfileLocation is a child object of PR_TaxProfile_bus. I got that from typing OBJ at the command window while on the screen and expanding PR_TaxProfile_bus then looking at its Objects.


    Set oTaxProfileLocation = oBusObj.AsObject(oBusObj.oTaxProfileLocation)

    Now you can keep using the VB object variable oTaxProfileLocation which happens to have same name as Sage object name. If it causes confusion you can change it to say:

    Set oTPL = oBusObj.AsObject(oBusObj.oTaxProfileLocation) 'then use oTPL as needed

  • 0 in reply to Alnoor_C

    Thanks Alnoor, I am using BOI through PowerShell. I am trying to establish the object the same way as I do it for SalesOrder Lines (I use oTaxProfileLocation instead of oLines), but it gives me an error. Below is the code. I use the same flags as the C# DispatchObject, and as mentioned, it works fine to get a handle of oLines.

    $m_flgGetProperty = [System.Reflection.BindingFlags]::Public + [System.Reflection.BindingFlags]::Static + [System.Reflection.BindingFlags]::IgnoreCase + [System.Reflection.BindingFlags]::GetProperty
    $oTaxProLoc = $oTaxProfile.GetType().InvokeMember("oTaxProfileLocation", $m_flgGetProperty, $null, $oTaxProfile, $null)

  • 0 in reply to BillyVanilli

    Bastian w/o consideration to PowerShell, this is how I typically use the C# DispatchObject. I haven't tested it myself for Tax Profiles but if this variation works better, you could adapt it for PowerShell.

    using (DispatchObject oPvx = new DispatchObject("ProvideX.Script"))
    // Run Init from oPvx pointing to \Home then instantiante session object as oSS
    using (DispatchObject oTaxProfile = new DispatchObject(oPvx.InvokeMethod("NewObject", "PR_TaxProfile_bus", oSS.GetObject())))
    try
    {
        // code before
        using (DispatchObject oTaxProfileLocation = new DispatchObject(oTaxProfile.GetProperty("oTaxProfileLocation")))
        // code after
    }
    catch (Exception e)
    {
        // catch code if necessary
    }

  • 0 in reply to Alnoor_C

    Thanks Alnoor. In PowerShell I go around the DispatchObject by calling the methods that the DispatchObject would call. That works.

    I just tested the TaxProfile in BOI/vbScript. That also doesn't work. I can see the TaxProfile Maintenance task in the MasterConsole, but it keeps telling me that it doesn't know any of the regular methods (e.g. SetKeyValue). I am unable to test it directly in Sage as the table is not exposed to attach events (it is also not available in Visual Integrator).

    Is it possible that this data is just not exposed at all? We need to get a couple of hundred records in, and keying those would be a pain.