Skip to main content

Hi. I’m trying to include a confirmation message box with yes no on Remove Hold action button. If click yes then i want to change the status of the Remove hold. If click no then nothing should change. Here’s is my code.

 public delegate IEnumerable ReleaseFromHoldDelegate(PXAdapter adapter);
PXOverride]
public IEnumerable ReleaseFromHold(PXAdapter adapter, ReleaseFromHoldDelegate baseMethod)
{
ARInvoice row = Base.Document.Current;

if(row.CustomerID != null &&
Base.Document.Ask("Are you sure you want to remove hold this?", MessageButtons.YesNo)
!= WebDialogResult.Yes) return adapter.Get();

return baseMethod(adapter);
}

When i click either yes or no in the confirmation box it gives me an error like this:

 

How can i solve this please ?

Hi @ifelix,

could you please try below code..

I have not tried it but hope it works for you.

public delegate IEnumerable ReleaseFromHoldDelegate(PXAdapter adapter);

[PXOverride]
public IEnumerable ReleaseFromHold(PXAdapter adapter, ReleaseFromHoldDelegate baseMethod)
{
ARInvoice row = Base.Document.Current;

if (row.CustomerID != null &&
Base.Document.Ask("Are you sure you want to remove hold from this?", MessageButtons.YesNo)
!= WebDialogResult.Yes)
{
Base.IsDirty = true; //set IsDirty to true
return adapter.Get();
}

return baseMethod(adapter);
}

Regards,

Sagar


Hi @ifelix,

could you please try below code..

I have not tried it but hope it works for you.

public delegate IEnumerable ReleaseFromHoldDelegate(PXAdapter adapter);

>PXOverride]
public IEnumerable ReleaseFromHold(PXAdapter adapter, ReleaseFromHoldDelegate baseMethod)
{
ARInvoice row = Base.Document.Current;

if (row.CustomerID != null &&
Base.Document.Ask("Are you sure you want to remove hold from this?", MessageButtons.YesNo)
!= WebDialogResult.Yes)
{
Base.IsDirty = true; //set IsDirty to true
return adapter.Get();
}

return baseMethod(adapter);
}

Regards,

Sagar

Hi there. When i apply this code i get an error like this one. Any idea why ?

 


Hi @ifelix,

Could you please replace Base.IsDirty = true; to  row.cache.IsDirty = true;

Hope, it helps!

Regards,

Sagar

 

 


Hi @ifelix,

Could you please replace Base.IsDirty = true; to  row.cache.IsDirty = true;?

Hope, it helps!

Regards,

Sagar

 

Hi@sagar07 ,

And it says something like this:

\App_RuntimeCode\SOInvoiceEntry.cs(89): error CS1061: 'ARInvoice' does not contain a definition for 'cache' and no accessible extension method 'cache' accepting a first argument of type 'ARInvoice' could be found (are you missing a using directive or an assembly reference?)

 


Hi @ifelix ,

  Base.Document.Cache.IsDirty = true;

Should be work.

Regards,

Sagar


Reply