Solved

How to retrieve the Acumatica InstanceID in code

  • 2 June 2023
  • 3 replies
  • 174 views

I am trying to retrieve the Acumatica Instance ID from within code as part of a licensing validation/restriction type verification. This would be for version 22R1 and newer.

 

Thanks !!

 

icon

Best answer by Evgeny Afanasiev 5 June 2023, 18:38

View original

3 replies

Userlevel 6
Badge +3

If Acumatica Instance ID is installation ID, then this example may help you:

using PX.Data;
using PX.Licensing;

namespace PX.Objects.SO
{
public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
{
[InjectDependency]
private ILicensing _licensing { get; set; }

protected void _(Events.RowSelected<SOOrder> e)
{
throw new PXException(_licensing.PrettyInstallationId);
}
}
}

 

Userlevel 7
Badge +17

Hi @rmillman33  I have an update from Acumatica support team that it is not recommended to validate the license using the Installation ID, there will be a challenges using this, hence we also modifying the License code as suggested by Acumatica. 

I request you check with Acumatica team before you working on this.

Userlevel 3
Badge

Hi @rmillman33,

As Naveen mentioned, using InstallationID and some other values that looks constant it questionable, and even forbidden by the Certification Guideline. The reason for those values might change, the InstallationID, for example is calculated on the start of the Application based on environment settings. So building business logic that would rely on that value is insufficient as might break just due to some server maintenance. 

I can suggest using Cloud Tenant ID instead - it is the GUID you can see on the Tenant screen, which is unique per Tenant, being assigned once and never changed (at least by Acumatica product itself).

Beside of extended level you can license (per Tenant rather per instance), there is a quite DI based interface that will allow you to get current Cloud tenant ID from anywhere in your code. See example below:

using PX.CloudServices.Tenants;
using PX.Data;

namespace PX.Objects.AR
{
public class ARPaymentEntry_Extension : PXGraphExtension<PX.Objects.AR.ARPaymentEntry>
{
[InjectDependency]
private ICloudTenantService _cloudTenantService { get; set; }

public PXAction<PX.Objects.AR.ARPayment> Test;

[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "test")]
protected void test()
{
Base.Document.Ask(_cloudTenantService.TenantId.ToString(), MessageButtons.OK);
}
}
}




 
 

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved