Trying to make a customized checkbox to stay true for all newly created documents.
Attributes:
[PXDBBool()] [PXDefault(TRUE)] [PXUIField(DisplayName = "Update Projects")]
ASPX:
<px:PXCheckBox CommitChanges="True" ID="edUpdateProject" runat="server" DataField="UpdateProject" ></px:PXCheckBox>
Can you try this [PXDefault(true)]. make true as small letters.
The below code is working for one of my customizations. This code may help you.
#region Status
[PXDBBool()]
[PXDefault(true,PersistingCheck =PXPersistingCheck.Nothing)]
[PXUIField(DisplayName = "Active")]
public virtual bool? Status { get; set; }
public abstract class status : PX.Data.BQL.BqlBool.Field<status> { }
#endregion
Related
Good day
I have a checkbox on my shipment page called Special Labels.
The client wants the field to display as a Yes/No dropdown box or something in that line.
Is this possible?
I think you could handle this a couple of ways:
Option 1 (PXDropdown):
Create a string field for a Yes/No dropdown and use its value to set your boolean field:
#region ActiveString
public abstract class activeString : PX.Data.IBqlField
{
}
[PXString]
[PXDefault("false")]
[YesNo.List()]
[PXUIField(DisplayName = "Active")]
public virtual string ActiveString { get; set; }
#endregion
#region Active
public abstract class active : PX.Data.IBqlField
{
}
[PXDBBool]
[PXDefault(true)]
[PXUIField(DisplayName = "Active", Visible = false, Enabled = false)]
public virtual bool? Active {
get { return Convert.ToBoolean(this.ActiveString ?? "false"); }
set { value = Convert.ToBoolean(this.ActiveString ?? "false"); }
}
#endregion
The dropdown ASPX markup:
<px:PXDropdown ID="edActive" runat="server"
DataField="ActiveString" Size="XS" >
<AutoCallBack Command="Save" Target="form">
</AutoCallBack>
</px:PXDropdown>
Option 2 (PXSelector):
Create a small table in the database for a selector, such as:
CREATE TABLE [dbo].[UsrTrueFalse]
(
[BoolValue] bit NOT NULL,
[TextValue] [varchar](3) NOT NULL
)
and create a DAC over the table:
[System.SerializableAttribute()]
public class UsrTrueFalse : IBqlTable
{
#region BoolValue
public abstract class boolValue : PX.Data.IBqlField
{
}
[PXDBBool]
[PXUIField(DisplayName = "Bool Value")]
public virtual bool? BoolValue { get; set; }
#endregion
#region TextValue
public abstract class textValue : PX.Data.IBqlField
{
}
[PXDBString(3)]
[PXUIField(DisplayName = "Text Value")]
public virtual string TextValue { get; set; }
#endregion
}
and then add a PXSelector attribute on your boolean field:
#region Active
public abstract class active : PX.Data.IBqlField
{
}
[PXDBBool]
[PXDefault(true)]
[PXSelector(typeof(Search<UsrTrueFalse.boolValue>),
DescriptionField = typeof(UsrTrueFalse.textValue))]
[PXUIField(DisplayName = "Active")]
public virtual bool? Active { get; set; }
#endregion
The PXSelector ASPX markup:
<px:PXSelector ID="edActive" runat="server" DataField="Active" DataSourceID="ds" Size="XS" DisplayMode="Text">
<AutoCallBack Command="Save" Target="form">
</AutoCallBack>
</px:PXSelector>
I have a selected checkbox on a custom grid is not triggering the Fieldupdated event.
protected void MyTable_Selected_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated del)
{
del?.Invoke(cache, e);
var row = (MyTable)e.Row;
if(row.Selected == true )
{
//
}
}
The following is the code in aspx page
<px:PXCheckBox ID="edSelected" runat="server" AlreadyLocalized="False" CommitChanges="True" DataField="Selected" Text="Selected">
</px:PXCheckBox>
DAC definition for the field
#region Selected
public abstract class selected : IBqlField { }
/// <summary>
/// Used for selection on screens.
/// </summary>
[PXDBBool]
//[PXDefault(false)]
[PXUIField(DisplayName = "Selected")]
public virtual bool? Selected { get; set; }
#endregion
When i click in the grid there is a red mark appears and the value is not committed on server side.
I had the same problem and I figured out the property "BatchUpdate" was set to "true" on the Grid, which prevents the changes to be commited to the server.
Once I set it to false it works fine :
I am just having a simple selector for contacts in my custom sreen. User can choose the Business Account, Prospect, customer.. and the related contacts should load to the selector. Below is my selector DAC definition.
I found weird that the Selector loads data for the first 2 Business account selection, After that for all subsequent selection the contact information is not available. If i rebuild my project again this data appears. Looks like some additional conditions are getting appended. But i am not sure what is going wrong. Please assist.
#region ContactOpportunity
public abstract class contactOpportunity : PX.Data.IBqlField { }
[PXDBInt]
[PXUIField(DisplayName = "Contact")]
[PXSelector(typeof(Search2<Contact.contactID,
InnerJoin<BAccount, On<BAccount.bAccountID, Equal<Contact.bAccountID>>>,
Where<BAccount.bAccountID, Equal<Current<UsrQuotation.baccountOpportunity>>,
And<Contact.isActive, Equal<True>>>>),
SubstituteKey = typeof(Contact.displayName), Filterable = true)]
public virtual Int32? ContactOpportunity { get; set; }
#endregion
For those who encounter similar issue,
After i change the DAC to BAccountCRM it works as usual. I dont know what actually happens when i use the other DAC.
#region ContactOpportunity
public abstract class contactOpportunity : PX.Data.IBqlField { }
[PXDBInt]
[PXUIField(DisplayName = "Contact")]
[PXSelector(typeof(Search2<Contact.contactID,
InnerJoin<BAccountCRM, On<BAccountCRM.bAccountID, Equal<Contact.bAccountID>>>,
Where<BAccountCRM.bAccountID, Equal<Current<UsrQuotation.baccountOpportunity>>,
And<Contact.isActive, Equal<True>>>>),
SubstituteKey = typeof(Contact.displayName), Filterable = true)]
public virtual Int32? ContactOpportunity { get; set; }
#endregion
I need to create a Contact lookup in SO screen (SO301000). I have already created user defined custom field as below. I is listing all contacts but it is not refreshing based on when select customer. Do I have to write any event for CustomerID to refresh these Contact lookup? Does anyone has any idea?
[PXDBInt]
[PXUIField(DisplayName = "Contact")]
[PXSelector(typeof(Search2<Contact.contactID,
LeftJoin<BAccount, On<BAccount.bAccountID, Equal<Contact.bAccountID>>>>),
DescriptionField = typeof(Contact.displayName), Filterable = true, DirtyRead = true)]
[PXRestrictor(typeof(Where<Contact.isActive, Equal<True>>), PX.Objects.CR.Messages.ContactInactive, typeof(Contact.displayName))]
[PXDBChildIdentity(typeof(Contact.contactID))]
public virtual int? UsrCustContactID { get; set; }
public abstract class usrCustContactID : IBqlField { }
You are missing Where Clause and you need to use BAccount2 instead of BAccount. SOOrderEntry Graph has data view defined with Vendor DAC which gets initialized first/before BAccount and framework will substitute it with Vendor DAC. To prevent this, you need to use BAccount2 DAC in your BQL.
using System;
using PX.Data;
using PX.Objects.SO;
using PX.Objects.CR;
namespace DemoPkg
{
public class SOOrderPXExt : PXCacheExtension<SOOrder>
{
#region UsrContactID
public abstract class usrContactID : IBqlField { }
[PXDBInt()]
[PXUIField(DisplayName = "Contact", Visibility = PXUIVisibility.Visible)]
[PXSelector(typeof(Search2<Contact.contactID,
LeftJoin<BAccount2, On<BAccount2.bAccountID, Equal<Contact.bAccountID>>>>),
DescriptionField = typeof(Contact.displayName), Filterable = true, DirtyRead = true)]
[PXDefault(PersistingCheck = PXPersistingCheck.Nothing)]
[PXFormula(typeof(Default<CRCase.customerID>))]
[PXRestrictor(typeof(Where<Contact.contactType, NotEqual<ContactTypesAttribute.bAccountProperty>,
And<Where<BAccount2.bAccountID, Equal<Current<SOOrder.customerID>>,
Or<Current<SOOrder.customerID>, IsNull>>>>), PX.Objects.CR.Messages.ContactBAccountDiff)]
[PXRestrictor(typeof(Where<Contact.isActive, Equal<True>>), PX.Objects.CR.Messages.ContactInactive,
typeof(Contact.displayName))]
public virtual Int32? UsrContactID { get; set; }
#endregion
}
}
And make sure you have AutoRefresh set to true in aspx for PXSelector control of this field.
I see you do not have a where condition in your selector to be based on the given customer. Try updating your selector to match something like this...
[PXSelector(typeof(Search2<Contact.contactID,
LeftJoin<BAccount, On<BAccount.bAccountID, Equal<Contact.bAccountID>>>,
Where<BAccount.bAccountID, Equal<Current<SOOrder.customerID>>>>),
DescriptionField = typeof(Contact.displayName), Filterable = true, DirtyRead = true)]
In your page also make sure your selector has AutoRefresh="true"
Example:
<px:PXSelector ID="edWeightUOM" runat="server"
DataField="WeightUOM" Size="S" AutoRefresh="true" />
I have a custom processing page. The main DAC of the data view is ARRegister, but there is the data view delegate. Both the view & delegate join ARCashSale & ARInvoice to the main DAC, The reason for this is...some records are cash sales, and others are invoices, overdue charges, ect. A few grid columns are included, which displays data specific to a cash sale. I invoke a static method in my process graph to assign the process delegate. The method runs with no errors.
In the data view delegate, I check the doc type for each record returned from the BQL.
If cash sale, then
yield return new PXResult<ARRegister, ARCashSale>(register, cashsale)
ELSE
yield return new PXResult<ARRegister>(register)
The reason for the delegate is to check some other conditions which cannot be determined using standard BQL. I notice the data in the column specific to a cash sale disappears after the user selects 'Process All'. I am unable to determine the reason. Checking to see if others have experienced this.
DataView
public PXProcessingJoin<ARRegister,
LeftJoin<cs.ARCashSale, On<ARRegister.docType, Equal<cs.ARCashSale.docType>, And<ARRegister.refNbr, Equal<cs.ARCashSale.refNbr>>>,
LeftJoin<ARInvoice, On<ARRegister.docType, Equal<ARInvoice.docType>, And<ARRegister.refNbr, Equal<ARInvoice.refNbr>>>,
InnerJoin<Customer,On<ARRegister.customerID,Equal<Customer.bAccountID>>>>>,
Where2<Where<ARRegister.released, Equal<True>, And<ARRegister.branchID, Equal<Current<AccessInfo.branchID>>>>,
And<Where<Customer.finChargeApply,Equal<True>>>>> Registers;
This is an older question, but I had a similar issue.
You need to add a boolean field named "Selected" to DACs you want to process.
The way I solved it was using a local DAC.
You can make it inherit from ARRegister and just add the required field.
In my case I used PXProjection, inherited from the main DAC and added the fields I needed from the joined DACs. Note that you need to add the BqlField = typeof(DAC.field) property to the type attribute of these fields to map them to the correct DAC.
Then in the PXProcessing view you just use your local DAC.
Also, it is very useful to try the Request Profiler screen (SM205070) when troubleshooting BQL.
Basically in processing screens sub DAC (other than Main DAC in view), filed values will not persist once the process completed.
In this case, the PXProjection will help us to persist the values even after completion of the process for the rows/records in processing screens.
Please find the sample Projection View and DAC below.
[PXProjection(typeof(Select2<SOShipment, InnerJoin<SOOrderShipment,
On<SOOrderShipment.shipmentNbr, Equal<SOShipment.shipmentNbr>,
And<SOShipment.status, Equal<SOShipmentStatus.confirmed>>>,
InnerJoin<SOOrder, On<SOOrderShipment.orderType, Equal<SOOrder.orderType>,
And<SOOrderShipment.orderNbr, Equal<SOOrder.orderNbr>>>>>>))]
Projection DAC:
[Serializable]
public class ProjectionShipmentDAC : IBqlTable
{
#region Selected
public abstract class selected : IBqlField
{
}
protected bool? _Selected = false;
[PXBool]
[PXDefault(false, PersistingCheck = PXPersistingCheck.Nothing)]
[PXUIField(DisplayName = "Selected")]
public virtual bool? Selected
{
get
{
return _Selected;
}
set
{
_Selected = value;
}
}
#endregion
#region Status
[PXDBString(1, IsFixed = true, BqlField = typeof(SOShipment.status))]
[PXUIField(DisplayName = "Status")]
[SOShipmentStatus.List()]
public virtual string Status { get; set; }
public abstract class status : IBqlField { }
#endregion
#region ShipmentNbr
[PXDBString(15, IsKey = true, IsUnicode = true, BqlField = typeof(SOShipment.shipmentNbr))]
[PXUIField(DisplayName = "Shipment Nbr.")]
public virtual string ShipmentNbr { get; set; }
public abstract class shipmentNbr : IBqlField { }
#endregion
#region ShipDate
[PXDBDate(BqlField = typeof(SOShipment.shipDate))]
[PXUIField(DisplayName = "Shipment Date")]
public virtual DateTime? ShipDate { get; set; }
public abstract class shipDate : IBqlField { }
#endregion
#region CustomerID
[PXDBInt(BqlField = typeof(SOShipment.customerID))]
[PXUIField(DisplayName = "Customer")]
[PXSelector(typeof(Customer.bAccountID), new Type[] { typeof(Customer.acctCD), typeof(Customer.acctName) },
SubstituteKey = typeof(Customer.acctCD), DescriptionField = typeof(BAccount.acctName))]
public virtual int? CustomerID { get; set; }
public abstract class customerID : IBqlField { }
#endregion
#region Shipped Quantity
[PXDBDecimal(BqlField = typeof(SOShipment.shipmentQty))]
[PXUIField(DisplayName = "Shipped Quantity")]
public virtual decimal? ShipmentQty { get; set; }
public abstract class shipmentQty : IBqlField { }
#endregion
}
Have you played around with MatrixMode and/or SyncPosition on your page grid? You might need SyncPosition="True"
Also, does the issue occur if not using process all? (process 1 or 2 rows)