I need to calculate value for one of the unbound field (in my customization, I have created these unbound field) in SO Line grid based on two columns in line items. Out of these two columns, 1st is UnitPrice and 2nd is custom bound column created in another customization. How to access these custom field (which is created in separate customization) into my customization.
Unbound field in my customization-
public abstract class usrMargin : IBqlField { }
protected decimal? _UsrMargin;
[PXDecimal]
[PXUIField(DisplayName = "Margin")]
public virtual decimal? UsrMargin { get; set; }
These value needs to be calculated as below-
Margin = 100 – ((“Std MFG Cost” ÷ “Unit Price”) * 100)
"Std MFG Cost" is that 2nd custom field created in separate customization.
While publishing customization, Acumatica creates all code files in App_RuntimeCode folder of the website. First check, what is the FullName of your DAC extension declaring 2nd custom bound field via different customization project.
You will be just fine utilizing any class from App_RuntimeCode in a different project as long as:
class FullName is used or in your code file there is using directive for namespace containing class created in a different project
both customization projects are published on your local development website
Related
I am Unable to Open Cash Sale Screen in Customization Editor of Acumatica, after I have added a new tab control with a Grid inside. I have assigned a custom DataView in the data member property of the Grid Control.
It Gives up the following error "The Customization Project Must Be Published before the screen can be edited. Error : The View CommissionCalcView does not exist".
Here "CommissionCalcView" is the name of my custom view, and it is Present in ARCashSaleEntry Extension of my project.
My Code Goes here....
using COMMISSIONMAPPING;
using PX.Objects.AR.Standalone;
namespace PX.Objects.AR
{
public class ARCashSaleEntry_Extension : PXGraphExtension<ARCashSaleEntry>
{
public PXSelect<CommissionCalculation,
Where<CommissionCalculation.cashSaleDocType,
Equal<ARCashSale.docType>,
And<CommissionCalculation.cashSaleRefNbr,
Equal<ARCashSale.refNbr>>>> CommissionCalcView;
#region Event Handlers
#endregion
}
}
Error Image
I have experienced this many times as well. The problem for me tends to be an error in how I define fields in a DAC extension or in improperly defining the view in the form.
In this case, you have BQL that is trying to compare CommissionCalculation (table selected in the BQL) to ARCashSale (table not selected in the BQL). Try adding Current<> on the ARCashSale references in the view so that it pulls the current value from the cache for ARCashSale in the base graph.
using COMMISSIONMAPPING;
using PX.Objects.AR.Standalone;
namespace PX.Objects.AR
{
public class ARCashSaleEntry_Extension : PXGraphExtension<ARCashSaleEntry>
{
public PXSelect<CommissionCalculation,
Where<CommissionCalculation.cashSaleDocType,
Equal<Current<ARCashSale.docType>>,
And<CommissionCalculation.cashSaleRefNbr,
Equal<Current<ARCashSale.refNbr>>>>> CommissionCalcView;
#region Event Handlers
#endregion
}
}
This was an issue with the development process and missing dlls, i removed the dll from the bin folder of my website and removed any key fields from my DAC, and rebuilt the project,
The problem was resolved
I would like to filter the records shown on the Projects screen. I've been given the directive to see if limiting the Selector for projects (re-writing the PXSelector for the ProjectID?) would also limit the records that show up on the screen, i.e., a user would not be able to navigate to records that aren't displayed by the Selector. I don't think that's the case, as the screen's view is not limited by what is chosen by the Selector - but I wanted to verify this.
Also - as far as limiting the records that show up in the Selector (possibly re-writing the Selector/BQL using a where clause?) - I looked at the source DAC, and for the life of me I can't figure it out. There is a PXSelector on the ContractID, which doesn't use the SubstituteKey that I'm familiar with, and the ContractCD also has several attributes with which I'm unfamiliar - namely the PXRestrictor AND the PXDimensionSelector.
Bottom line:
1.) What's the best way to limit the records for Project shown in the screen's Selector? Can I just add to the PXRestrictor attribute?
2.) Would limiting the Selector's results also limit what the user can navigate to on the screen using the navigation buttons?
Whenever you need to restrict access to primary records on a data entry screen, it's always required to customize both the lookup DAC key field and the primary data view. By design, in Acumatica key fields in DAC and the primary data view are completely independent, that is why it's required to modify both pieces to achieve the desired result.
For example, to deny access to canceled projects on the Projects screen, you should add PXRestrictorAttribute to PMProject's ContractCD field and also re-declare Project primary data view:
public class ProjectEntryExt : PXGraphExtension<ProjectEntry>
{
public class cancelled : Constant<string>
{
public cancelled() : base(ProjectStatus.Cancelled) {; }
}
[PXViewName(Messages.Project)]
public PXSelect<PMProject, Where<PMProject.baseType, Equal<PMProject.ProjectBaseType>,
And<PMProject.nonProject, Equal<False>, And<PMProject.isTemplate, Equal<False>,
And<PMProject.status, NotEqual<cancelled>,
And<Match<Current<AccessInfo.userName>>>>>>>> Project;
[PXMergeAttributes(Method = MergeMethod.Append)]
[PXRestrictor(typeof(Where<PMProject.status, NotEqual<cancelled>>),
"Given Project/Contract '{0}' is cancelled", typeof(PMProject.contractCD))]
public void PMProject_ContractCD_CacheAttached(PXCache sender) { }
}
I have a custom table for historical data. It's a one-time data dump directly into SQL so I'd prefer not to have to create a screen for it.
I have three columns in my table:
CompanyID INT
InvoiceNbr NVARCHAR(40)
Amount DECIMAL(19,4)
I create a new Customization Project and added a new DAC to the Code area that is linked to my custom table:
https://i.imgur.com/6mNjdou.png (Screenshot #1)
https://i.imgur.com/IdNLJkR.png (Screenshot #2)
Then I create a Generic Inquiry, but I don't get the Paper Clip and Note icons. I was hoping to use the Paper Clip to upload documents and attach them to the records in my custom table.
So, I added another column to my custom table:
NoteID UNIQUEIDENTIFIER
And I re-added the new DAC which now generates this code:
https://i.imgur.com/QvpWB5X.png (Screenshot #3)
Now I get the Paper clip and Note icons in my Generic Inquiry:
https://i.imgur.com/olCglBB.png (Screenshot #4)
I can add a note or attach a document and the icons change color which makes it seem like the notes and documents got attached to the records. But when I refresh the page, everything goes away. Also, I can tell that nothing is getting stored in the database.
So the Paper Clip and Note icons don't work.
I'm wondering if it's possible to get the Paper Clip and Note icons to work in my Generic Inquiry without building a custom screen. Is this possible?
Tim, for Notes and Attachments to work properly, your NoteID field should be decorated with the PXNote attribute, instead of the default combination of PXDBGuid- and PXUIFieldAttribute. Will everything work as expected after you replace NoteID field declaration with the code snippet below and republish the customization?
public abstract class noteID : PX.Data.IBqlField
{
}
[PXNote()]
public virtual Guid? NoteID { get; set; }
Currently I work with screen ap303000.aspx. I want to add new attribute to tab "Attributes". This tab is binded to view "Answers" which is declared in following way:
[PXViewName(CR.Messages.Answers)]
public CRAttributeList<Vendor> Answers;
little bit digging with metadata viewer in CRAttributeList shows that CRAttributeList is inherited from PXSelectBase and definitely reads records from CSAnswers table:
public class CRAttributeList<TReference> : PXSelectBase<CSAnswers> where TReference : IBqlTable
which gives me hint, that I need to insert something into table CSAnswers. Table CSAnswers by it's structure also doesn't give me enough information what should I put in table CSAnswers in order to have some attribute as bool and available to all Vendors and to turn it on by default?
You need to specify list of Attributes at Vendor Class (AP201000) level first.
Once Vendor class is specified, Attributes specified at Class level will be listed for which value can be assigned.
I have a custom field on the Payments and Applications screen. That when I void a payment I cannot edit my custom field on there. The payment is in the balanced state and it lets me edit the Hold checkbox as well as the application date. But I cant figure how to make my custom field editable as well?
Here is my DAC declaration on ARRegister Extension class
#region UsrMAFOManuallyAddToRex
[PXDBBool]
[PXUIField(DisplayName = "Manually Add Payments To Rex", Visibility = PXUIVisibility.Visible)]
public virtual bool? UsrMAFOManuallyAddToRex { get; set; }
public abstract class usrMAFOManuallyAddToRex : IBqlField { }
#endregion
First of all,
i am wondering why you need your field to be editable in a voided payment.
When i checked the source of acumatica, i saw in the row selected event of ARPayment have the code which disables the whole cache [which may include your custom field too], this might be the reason why it is disabled in a voided payment.
If you really want to enable, you might need a custom code to enable the cache and disable the rest.