Reputation: 5
Can anybody help me with a custom button. I've added it, but it doesn't work. What did I do wrong?
public class ProjectEntry_Extension : PXGraphExtension<ProjectEntry>
{
public const string TestMsg = "Hello World";
public static bool IsActive()
{
return true;
}
[PXUIField(DisplayName = "TestMethod")]
[PXButton]
public void TestMethod()
{
throw new PXException(TestMsg);
}
}
Maybe someone can share a detailed and understandable manual on how to add a button using the extension library or perhaps a link to video instructions. I looked at the Aсumatiсa documentation - but apparently I misunderstood it.
Upvotes: 0
Views: 292
Reputation: 186
Try adding the PXAction type to your extension, and using IEnumerable for the method return type. The type used for the PXAction would correspond to the primary DAC for the screen.
public class ProjectEntry_Extension : PXGraphExtension<ProjectEntry>
{
public static bool IsActive() => true;
public const string TestMsg = "Hello World";
public PXAction<PMProject> testMethod;
[PXUIField(DisplayName = "TestMethod")]
[PXButton]
public virtual IEnumerable TestMethod(PXAdapter adapter)
{
throw new PXException(TestMsg);
// used to return on standard Actions
return adapter.Get();
}
}
For the button placed on the form, I'm not sure but I believe instead of using click you should expand the AutoCallBack section and use the name of your method as the value for the Command property. You may also need to set the AutoCallBack target value to ds.
Upvotes: 1
Reputation: 271
I would suspect the issue you are having is that you're missing the PXAction part of the button. See if this Acumatica help article gets you in the right direction. https://help-2021r1.acumatica.com/(W(7))/Help?ScreenId=ShowWiki&pageid=f1ef4253-f995-43f9-8c2e-86206d75c564
Upvotes: 0