How To Modify Activities Behavior On Business Accounts Page

Hello everybody,

today I want to write a few words on how to modify behavior of buttons Add task, Add event, Add email, Add activity, ..., Add work item of Business Accounts page.

The main issue of chaning it is in the fact, that it is not just ordinary buttons, but separate class, which has injection of logic. Part of it's declaration goes below:

public class CRActivityList<TPrimaryView> : CRActivityListBase<TPrimaryView, CRPMTimeActivity>
  where TPrimaryView : class, IBqlTable, new()
{
  public CRActivityList(PXGraph graph)
    : base(graph)
  {
  }
 
  public CRActivityList(PXGraph graphDelegate handler)
    : base(graphhandler)
  {
  }
}

To my surprise, in order to override it's behavior you'll need to inherit from CRActivityList, and add your logic, for example like this:

public class BusinessAccountMaintExt : PXGraphExtension<BusinessAccountMaint>
{
	[PXViewName(Messages.Activities)]
	[PXFilterable]
	[CRReference(typeof(BAccount.bAccountID), Persistent = true)]
	public CRActivityListModified<BAccount> Activities;
}
 
public class CRActivityListModified<TPrimaryView> : CRActivityList<TPrimaryView>
	where TPrimaryView : classIBqlTablenew()
{
	public CRActivityListModified(PXGraph graph)
		: base(graph)
	{
	}
 
	public CRActivityListModified(PXGraph graphDelegate handler)
		: base(graphhandler)
	{
	}
 
	public override IEnumerable NewTask(PXAdapter adapter)
	{
		try
		{
			base.NewTask(adapter);  // throws exception, catch it and add you needed logic
		}
		catch (PXRedirectRequiredException ex)
		{
			var g = (CRTaskMaint)ex.Graph;
			var a = g.Tasks.Current;
			a.Subject = "Test Subject";
			a = g.Tasks.Update(a);
 
			var timeactivity = g.TimeActivity.Current;
 
			throw;
		}
 
		return adapter.Get();
	}
 
	public override IEnumerable NewEvent(PXAdapter adapter)
	{
		try
		{
			base.NewEvent(adapter);
		}
		catch (PXRedirectRequiredException ex)
		{
			var g = (EPEventMaint)ex.Graph;
			var a = g.Events.Current;
			a.Subject = "Test Subject";
			a = g.Events.Update(a);
 
			var timeactivity = g.TimeActivity.Current;
 
			throw;
		}
 
		return adapter.Get();
	}
 
	public override IEnumerable NewMailActivity(PXAdapter adapter)
	{
		try
		{
			base.NewMailActivity(adapter);
		}
		catch (PXRedirectRequiredException ex)
		{
			var g = (CREmailActivityMaint)ex.Graph;
			var a = g.Message.Current;
			a.Subject = "Test Subject";
			a = g.Message.Update(a);
 
			var timeactivity = g.TimeActivity.Current;
 
			throw;
		}
 
		return adapter.Get();
	}
 
	public override IEnumerable NewActivity(PXAdapter adapter)
	{
		return base.NewActivity(adapter);
	}
 
	protected override IEnumerable NewActivityByType(PXAdapter adapterstring type)
	{
		try
		{
			base.NewActivityByType(adaptertype);
		}
		catch (PXRedirectRequiredException ex)
		{
			var g = (CRActivityMaint)ex.Graph;
			var a = g.Activities.Current;
			a.Subject = "Test Subject";
			a = g.Activities.Update(a);
 
			var timeactivity = g.TimeActivity.Current;
 
			throw;
		}
 
		return adapter.Get();
	}
}

Few comments to presented code.

  1. All pop ups appear after exception, so you'll not be able to avoid exceptions, no matter what
  2. Your addendums should be modified in catch
  3. throw; will re-throw exception one more time. This is particularly interesitng detail, which you can re-use in some other scenarios when you need to deal with pop ups

Summary

Acumatica is very flexible, and the base flexibility mechanism is inheritance and polymorphism, two pillars of OOP.  In case if you need to change behavior of Cases screen, you'll need to inherit-override CRPMTimeActivity class.

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

Strong Name Validation By Pass

 

Hello,

here I want to leave a short notice how to manage strong name validation in Windows. For this purpose you can manage via following keys in regedit:

To enable the strong-name bypass feature for all applications: switch the value for AllowStrongNameBypass to 1 in
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework keys

With those changes you'll get your validation turn off. If you want to set it on, then set AllowStrongNameBypass to 0

 

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\AcuPower.GehmanAccounting\bin\Debug\AcuPower.manAccounting.dll" "c:\Program Files\Acumatica ERP\manAccountingDev\Bin\" /F /Y
xcopy /s "c:\Sources\Kensium\AcuPower.GehmanAccounting\bin\Debug\AcuPower.manAccounting.pdb" "c:\Program Files\Acumatica ERP\manAccountingDev\Bin\" /F /Y

 

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.

 

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.

 

Fbql Brackets

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.

Adding Report Page To Customization

Hello everybody,


today I want to make post on how to add your report page (.rpx) to customization, so than you will be able to use it in another progect.

For this purpose open customization window as showed below and click "Reports" button:

Then click on plus and select report you want to change:

The name of your report page you can find, when run report from acumatica page in browser:

If you will follow those steps, you'll be able to add report to customization:

But this works only if your report is available in database.

Suppose your report is saved only in file, in ReportsDefault folder of your site. Then you should save it also to database.

For achieving this, acomplish following steps:

First: open Report Designer:

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.

 

 

How To Work With Unbounded Dac In Acumatica

How to work with unbounded DAC in Acumatica

Hi everybody,

today I want to leave a short note on how to deal with Unbounded DAC classes in Acumatica. Unbounded in other words means DACs that doesn't have dirrect persising target in database.

For Unbounded DAC classes to work like this, two steps are needed:

  1. Add attribue [PXVirtualDAC] to PXSelect or PXSelect.....
  2. Add attribute PXVirtual over your DAC class declaration

With those two details you'll have complete independence of your classes from Database.

No Comments

Add a Comment