How To Deal With Px Data Pxexception Cannot Access The Uploaded File Failed To Get The Latest Revision Of The File Error Message

 

Hello everybody,

today I want describe how to deal with following Acumaitca error message: 

Publish Customization

Compiled projects: GAPRojectsBusinessAccounts,PayrollV2Acu2018Build20190328,EBizCharge2018R2,GACustomization
Validation started.
PX.Data.PXException: Cannot access the uploaded file. Failed to get the latest revision of the file a4353331-8f7f-4b3b-a881-2cdb4d5451e3
   at Customization.CstBinFile.GetFileFromDb() in C:\Bld\AC-FULL2018R226-JOB1\Sources\NetTools\PX.Web.Customization\CstDocumentDOM\CstBinFile.cs:line 120
   at Customization.CstBinFile.SaveFiles(FilesCollection context) in C:\Bld\AC-FULL2018R226-JOB1\Sources\NetTools\PX.Web.Customization\CstDocumentDOM\CstBinFile.cs:line 65
   at Customization.CstDocument.GetFiles(FilesCollection context) in C:\Bld\AC-FULL2018R226-JOB1\Sources\NetTools\PX.Web.Customization\CstDocumentDOM\CstDocument.cs:line 335
   at Customization.CstManager.ValidateDocument(CstDocument doc, Action`1 logMessageDelegate, Boolean patchLibInDB) in C:\Bld\AC-FULL2018R226-JOB1\Sources\NetTools\PX.Web.Customization\Global\CustomizationManager.cs:line 245
   at PX.Customization.CstValidationProcess.ValidateCurrentDocument(Action`1 logMessage) in C:\Bld\AC-FULL2018R226-JOB1\Sources\NetTools\PX.Web.Customization\Publish\CstValidationProcess.cs:line 399
   at PX.Customization.CstValidationProcess.CompileInternal() in C:\Bld\AC-FULL2018R226-JOB1\Sources\NetTools\PX.Web.Customization\Publish\CstValidationProcess.cs:line 223
   at PX.Customization.CstValidationProcess.<>c__DisplayClass6_0.<ProcessRequest>b__0() in C:\Bld\AC-FULL2018R226-JOB1\Sources\NetTools\PX.Web.Customization\Publish\CstValidationProcess.cs:line 133

 

The reason of this error can happen after you restore snapshot from some company in your instance. For example, recently I worked with one company, which had a lot of sesitive information in their Acumatica instance, and the only way of dealing with them was preparation by that company of some representative information and giving me snapshot. But after snapshot restoration, i had plenty of adventures, about which you can read below.

With help of resharper I have found that class CstBinFile has method GetFileFromDb, which looks like this:

public byte[] GetFileFromDb()
{
  if (this.IsBinContent)
    return this.BinContent;
  Guid id = this.FileID.Value;
  UploadFileRevision lastRevision = CstBinFile.GetLastRevision(id);
  if (lastRevision == null)
    throw new PXException(PXMessages.LocalizeFormatNoPrefixNLA("Cannot access the uploaded file. Failed to get the latest revision of the file {0}", (objectid));
  return lastRevision.Data;
}

As you can see from C# code presented, it takes latest revision. Method GetLastRevision have this line:

 
return (UploadFileRevision) PXSelectBase<UploadFileRevision, PXSelectReadonly<UploadFileRevision, Where<UploadFileRevision.fileID, 

Based on this, I decided to do the following:

  1. In database located table UploadFile, and by random choince modified column FileId, and set it to a4353331-8f7f-4b3b-a881-2cdb4d5451e3.
  2. The same step did in table UploadFileRevision.

and tried to make publish one more time.

This step helped to remove issue with that exact file, but didn't help to resovle issue with other guids. I spend some time on creation of new guids, but after 10 guids I become tired, and created following SQL code to automate it's creation:

declare @UploadFileRevision table(
	[CompanyID] [int] NOT NULL,
	[FileID] [uniqueidentifier] NOT NULL,
	[FileRevisionID] [int] NOT NULL,
	[Data] [varbinary](max) NOT NULL,
	[Size] [int] NOT NULL,
	[CreatedByID] [uniqueidentifier] NOT NULL,
	[CreatedDateTime] [datetime] NOT NULL,
	[Comment] [nvarchar](500) NULL,
	[OriginalName] [nvarchar](255) NULL,
	[OriginalTimestamp] [datetime] NULL,
	[CompanyMask] [varbinary](32) NOT NULL,
	[BlobHandler] [uniqueidentifier] NULL,
	[RecordSourceID] [smallint] NULL)
 
declare @uploadFile TABLE (
	[CompanyID] [int] NOT NULL,
	[FileID] [uniqueidentifier] NOT NULL,
	[Name] [nvarchar](255) NOT NULL,
	[CreatedByID] [uniqueidentifier] NOT NULL,
	[CreatedDateTime] [datetime] NOT NULL,
	[Versioned] [bit] NOT NULL,
	[CheckedOutBy] [uniqueidentifier] NULL,
	[CheckedOutComment] [nvarchar](500) NULL,
	[LastRevisionID] [int] NOT NULL,
	[PrimaryPageID] [uniqueidentifier] NULL,
	[PrimaryScreenID] [varchar](8) NULL,
	[IsHidden] [bit] NULL,
	[Synchronizable] [bit] NULL,
	[SourceType] [char](1) NULL,
	[SourceUri] [nvarchar](255) NULL,
	[SourceLogin] [nvarchar](255) NULL,
	[SourcePassword] [nvarchar](1024) NULL,
	[SourceIsFolder] [bit] NULL,
	[SourceMask] [nvarchar](255) NULL,
	[SourceNamingFormat] [char](1) NULL,
	[SourceLastExportDate] [datetime] NULL,
	[SourceLastImportDate] [datetime] NULL,
	[IsPublic] [bit] NOT NULL,
	[NoteID] [uniqueidentifier] NULL,
	[CompanyMask] [varbinary](32) NOT NULL,
	[RecordSourceID] [smallint] NULL,
	[SshCertificateName] [nvarchar](50) NULL)
 
 insert into @UploadFileRevision select top 1 * from UploadFileRevision
 insert into @uploadFile([CompanyID]
           ,[FileID]
           ,[Name]
           ,[CreatedByID]
           ,[CreatedDateTime]
           ,[Versioned]
           ,[CheckedOutBy]
           ,[CheckedOutComment]
           ,[LastRevisionID]
           ,[PrimaryPageID]
           ,[PrimaryScreenID]
           ,[IsHidden]
           ,[Synchronizable]
           ,[SourceType]
           ,[SourceUri]
           ,[SourceLogin]
           ,[SourcePassword]
           ,[SourceIsFolder]
           ,[SourceMask]
           ,[SourceNamingFormat]
           ,[SourceLastExportDate]
           ,[SourceLastImportDate]
           ,[IsPublic]
           ,[NoteID]
           ,[CompanyMask]
           ,[RecordSourceID]
           ,[SshCertificateName])    select top 1 	   [CompanyID],
           [FileID]
           ,[Name]
           ,[CreatedByID]
           ,[CreatedDateTime]
           ,[Versioned]
           ,[CheckedOutBy]
           ,[CheckedOutComment]
           ,[LastRevisionID]
           ,[PrimaryPageID]
           ,[PrimaryScreenID]
           ,[IsHidden]
           ,[Synchronizable]
           ,[SourceType]
           ,[SourceUri]
           ,[SourceLogin]
           ,[SourcePassword]
           ,[SourceIsFolder]
           ,[SourceMask]
           ,[SourceNamingFormat]
           ,[SourceLastExportDate]
           ,[SourceLastImportDate]
           ,[IsPublic]
           ,[NoteID]
           ,[CompanyMask]
           ,[RecordSourceID]
           ,[SshCertificateName]
		    from uploadFile
 
 -- 0cc8363d-dff7-4bc1-92df-62ad7f37ace0
 declare @fid uniqueidentifier
 set @fid = '0cc8363d-dff7-4bc1-92df-62ad7f37ace0'
 
 update @UploadFileRevision set FileID =@fid
 update @uploadFile set FileID =@fid
 
 insert into UploadFile ([CompanyID]
           ,[FileID]
           ,[Name]
           ,[CreatedByID]
           ,[CreatedDateTime]
           ,[Versioned]
           ,[CheckedOutBy]
           ,[CheckedOutComment]
           ,[LastRevisionID]
           ,[PrimaryPageID]
           ,[PrimaryScreenID]
           ,[IsHidden]
           ,[Synchronizable]
           ,[SourceType]
           ,[SourceUri]
           ,[SourceLogin]
           ,[SourcePassword]
           ,[SourceIsFolder]
           ,[SourceMask]
           ,[SourceNamingFormat]
           ,[SourceLastExportDate]
           ,[SourceLastImportDate]
           ,[IsPublic]
           ,[NoteID]
           ,[CompanyMask]
           ,[RecordSourceID]
           ,[SshCertificateName]) select [CompanyID]
           ,[FileID]
           ,[Name]
           ,[CreatedByID]
           ,[CreatedDateTime]
           ,[Versioned]
           ,[CheckedOutBy]
           ,[CheckedOutComment]
           ,[LastRevisionID]
           ,[PrimaryPageID]
           ,[PrimaryScreenID]
           ,[IsHidden]
           ,[Synchronizable]
           ,[SourceType]
           ,[SourceUri]
           ,[SourceLogin]
           ,[SourcePassword]
           ,[SourceIsFolder]
           ,[SourceMask]
           ,[SourceNamingFormat]
           ,[SourceLastExportDate]
           ,[SourceLastImportDate]
           ,[IsPublic]
           ,[NoteID]
           ,[CompanyMask]
           ,[RecordSourceID]
           ,[SshCertificateName] from @uploadFile
 insert into UploadFileRevision select * from @UploadFileRevision
 

And executed that script multiple times, but after 20-th execution I gave up, and decided to continue research. In order to find, where is the problem, I've decided to find which table in database is exact source, from which Acumatica reads records. For such purposes I always use stored procedure from this article

As a result, I have found, that Acumatica has table CustObject, in which there are plenty of objects, created by Acumatica. 

In order to make my life simpler, I've decided to clean table CustObject, but of course with previous creation of backup. 

delete  from CustObject

After that I've decided to publish cutomizations one more time, and was successful!

Summary

If you ever see error message Cannot access uploaded file ..... I'd recommend you just to delete data from table CustObject as fastest solution

No Comments

Add a Comment
 

 

Dashboardpagetitlemodule Does Not Implement Interface Member Px Web Ui Ititlemodule Getdefaultvisibility In Acumatica

 

Hello everybody,

today I want to describe how to live with following error message:

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS0535: 'DashboardPageTitleModule' does not implement interface member 'PX.Web.UI.ITitleModule.GetDefaultVisibility()'

Source Error:

 
Line 2:  using PX.Web.UI;
Line 3:  
Line 4:  public class DashboardPageTitleModule : ITitleModule
Line 5:  {
Line 6:  	public void Initialize(ITitleModuleController controller)


Source File: c:\Program Files\Acumatica ERP\GehmanAccountingDev\App_Code\Auxiliary\DashboardPageTitleModule.cs    Line: 4 


 




Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.3815.0

Some time it appears on some Acumatica versions. Steps for dealing with it are the following:

  1. Copy with replace all files from Acumatica folder [Acumatica installation folder]\Files\Bin, everything.
  2. Remove reference for your project in Visual studio
  3. In Post-build event command line: of Visual studion type something like this:

xcopy /s "c:\Sources\Kensium\KN.GehmanAccounting\bin\Debug\KN.manAccounting.dll" "c:\Program Files\Acumatica ERP\manAccountingDev\Bin\" /F /Y
xcopy /s "c:\Sources\Kensium\KN.GehmanAccounting\bin\Debug\KN.manAccounting.pdb" "c:\Program Files\Acumatica ERP\manAccountingDev\Bin\" /F /Y

On screenshot level it loos like this: 

With such maneure you'll get working workaround of replacing files in your built. 

No Comments

Add a Comment
 

 

Merge Few Customizations Into One

 

Hello everybody,

today I want to leave a short notice on how to join few customizations into one. Basically all you need is publish customizations you want to have merged, and then on Customization Projects form ( SM204500 ) click on button View Published and then click on Download package. In that way you'll get Customization.zip which will be merged result of published customizations.

No Comments

 

Add a Comment
 

 

How To Modify Pxintlist Dynamically In Acumatica

 

Hello everybody,

today I want to leave a short code sample on how to modify PXIntList or dropdown list in Acumatica. Below goes code sample of it:

protected virtual void _(Events.RowSelected<CROpportunity> e)
{
    if (e.Row == null)
        return;
    var opportunityExtension = e.Row.GetExtension<CROpportunityExt>();
 
    if (opportunityExtension.UsrProduct == 0)
    {
        var listInts = new List<int>();
        var listStrings = new List<String>();
 
        listInts.Add(0);
        listInts.Add(1);
        listInts.Add(2);
 
        listStrings.Add("String 1");
        listStrings.Add("String 2");
        listStrings.Add("String 3");
 
        PXIntListAttribute.SetList<CROpportunityExt.usrProposition>(e.Cache, e.Row, listInts.ToArray(), listStrings.ToArray());
    }
 
    if (opportunityExtension.UsrProduct == 1)
    {
        var listInts = new List<int>();
        var listStrings = new List<String>();
 
        listInts.Add(0);
        listInts.Add(3);
        listInts.Add(5);
 
        listStrings.Add("String 2");
        listStrings.Add("String 3");
        listStrings.Add("String 4");
 
        PXIntListAttribute.SetList<CROpportunityExt.usrProposition>(e.Cache, e.Row, listInts.ToArray(), listStrings.ToArray());
    }
}

This code sample has two most important parts: 

  1. RowSelected ( declared over new syntax )
  2. PXIntListAttribute.SetList<CROpportunityExt.usrProposition> call

With usage of those two principles you can easily get modifiable collection accoding to necessary conditions in your code.

No Comments

 

Add a Comment
 

 

Warning You Are Not In Maintenance Mode

 

Hello everybody,

today I want to make a post about new security feature of acumatica, which guard you from creating corrupted data. Suppose you are System Administrator and want to make snapshot for being able use it to set settings to new company, which you just created. However, some user might use it too, and this may cause the creation of bad records. For this reason, in latest versions of Acumatica (from 2017 R2), when you try to create snapshot, you'll recieve an warning message: 

Warning message informs, that you should switching the maintenance mode, so do it, as shown below, by click "SCHEDULE LOCKOUT":

 

Now you able, without any risk, create snapshot:

On the end, don't forget to remove the lockout by click "STOP LOCKOUT":

Using this technique, your Acumatica application will be safe and stable.

No Comments

Add a Comment
 

 

Creating New Company Set Settings

 

Hello everybody,
today I want share with you, how you can create new Company and set it settings.

For creating new company, we should go to "Tenants" screen:

Notice, that in old vercions of acumatica instead the "Tenants" was the "Companies":

Let create new company, and give it name "Exotic Places":

When process of creation is finished, we'll automatically be logged out:

 

To fix this, let's copy the settings from existing company to our. First of all let us sign out from "Exotic Places" and sign in to "Company". Then open "Tenants", chose the "Company" and click to "Create Snapshot" button:

We get a warning message, but it possible easily deal with it, only go to this link, to short post of my blog and you'll done it. After it let try again:

Press "Save" on the toolbar of the form, then import snapshot into our new company:

Now let's restore snapshot to "Exotic Places":

After it let explore, what have we done:

Summary: if you'll create new company, then you will need to set the settings for it. To do this, you can copy them from an existing company (as shown on the top):
1. Create the snapshot.
2. Export it.
3. Upload snapshot in new company.
4. Restore snapshot for it.

No Comments

Add a Comment
 

 

Fbql Brackets

 

Hello everybody,

today I want to speak about one very interesting feature of FBQL, which I don't know if exists in BQL. Function Brackets!

Take a look on following code sample:

var bracketsDemo = SelectFrom<SOOrder>.InnerJoin<SOLine>.On<SOLine.orderNbr.IsEqual<SOOrder.orderNbr>>.InnerJoin<SOShipLine>
	.On<SOShipLine.origOrderNbr.IsEqual<SOOrder.orderNbr>>.Where<
		Brackets<SOShipLine.confirmed.IsNotNull.
			And<SOShipLine.baseOrigOrderQty.IsNotNull>.
			And<SOShipLine.completeQtyMin.IsNotNull>.
			And<SOShipLine.confirmed.IsEqual<True>.
				Or<SOShipLine.confirmed.IsNull>>.
			And<SOShipLine.baseOriginalShippedQty.IsGreater<SOShipLine.unassignedQty>.
				Or<SOShipLine.baseOrigOrderQty.IsLess<SOShipLine.baseOriginalShippedQty>>>>.
		Or<SOShipLine.baseOrigOrderQty.IsNotNull>>.AggregateTo<GroupBy<SOOrder.orderNbr>,
		Min<SOOrder.curyDiscTot>>.OrderBy<SOOrder.curyFreightAmt.AscSOOrder.curyDocDisc.Desc>.View.Select(Base);

as you can see from the code, now in FBQL if you need to have Or operator, then as anohter option you may use Brackets.

No Comments

 

Add a Comment
 

 

How To Pass Data Into Processing Method With Help Of Lambda Expression

How to pass data into processing method with help of lambda expression

Hello everybody,

today I want to leave a short note on how to pass some additional parameters into Processing method of processing page with help of lambda expression. Syntax is pretty simple:

public class SSShipmentDateResetter : PXGraph<SSShipmentDateResetter>
{
	public PXFilter<ShipmentFilter> ShipmentFilter;
 
	public PXFilteredProcessing<SOShipment, ShipmentFilter> ShipmentsForProcessing;
 
	public SSShipmentDateResetter()
	{
		var shipmentFilter = ShipmentFilter.Current;
		ShipmentsForProcessing.SetProcessDelegate(shipments =>
		{
			ResetDate(shipmentFilter, shipments);
		});
	}
 
	public static void ResetDate(ShipmentFilter filter,  List<SOShipment> shipments)
	{
		
	}
}

for me such approach is a bit easier to use as it involes a bit less amout of typing.

If you want to have even simpler syntax, then following sample also may work for you:

public SSShipmentDateResetter()
{
	var filter = ShipmentFilter.Current;
	ShipmentsForProcessing.SetProcessDelegate(shipments => ResetDate(filter, shipments));
}

For simplicity sake, I've showed only constructor.

No Comments

 

Add a Comment
 

 

How To Enable Some Control In Acumatica

How to enable some control in Acumatica

Hello everybody,

today I want to leave a short note for the following situation:

Imagine that you need to enable some control in Acumatica ( for example Mark for PO ) on page Sales orders ( SO301000 ).

As usually for enabling control there are two ways:

  1. RowSelected
  2. Automation steps.

Recently I found third option, when neither 1 nor 2 did work. After spending some time I found third option: Cache has property AllowUpdate. After I've set it to true, I was able to modify lines in Document details. 

In your code it may look like this:

protected void SOLine_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected del)
{
        if (del != null)
              del(cache, e);
        SOLine row = (SOLine)e.Row;
        if (row == nullreturn;
        Base.Transactions.Cache.AllowUpdate = true;
        PXUIFieldAttribute.SetEnabled<SOLine.pOCreate>(cache, row, true);
        PXUIFieldAttribute.SetEnabled<SOLine.shipDate>(cache, row, true);
}

you still may need Row_Selected event handler, but not forget to add AllowUpdate = true.

No Comments

Add a Comment
 

 

How To Restore Snapshot Of Acumatica

How to restore snapshot of Acumatica

Hello everybody,

today I want to leave a post on how to restore Acumatica snapshots with help of Acumatica Wizard.

Before creating snapshot you may need to switch Acumatica to maintenance mode. Below are the steps for achieveing it:

1. Go to System --> Management --> Apply Updates, click on the button "Schedule Lockout" and specify the reason for lockout
2. Don't forget to remove the lockout after you'll restore Snapshot.

Steps are the following:

1. Create a snapshot of the tenant you wish to back up

2. Export that snapshot (I recoment  xml format).

3. In the folder where the corresponding Acumatica Wizard is installed (usually c:\program files\Acumatica ERP\), find the folder called  \Database\Data, where there are individual folders with snapshot data.

4. Create a new folder for your new snapshot

5. Extract the contents of the .zip exported snapshot into the new folder you created

6. Run the Acumatica Wizard

7. Choose the "Perform Application Maintenance" option

8. Select the site into which you wish to import this data

9. Choose the "Tenant Maintenance" option or "Company Maintenance":

10. Click on the "Advanced Settings" button at the bottom

12. Click on the "Insert Data" option next to the tenant where the data should be imported and select the new folder/snapshot you added in step #4 above:

13. Proceed through the wizard as normal. When the install process is complete you should have a tenant with restored data.

No Comments

Add a Comment