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>
Related
I have a very simple Maint page, it has no events
public PXCancel<RCDistributorSalesStat> Cancel;
public PXSave<RCDistributorSalesStat> Save;
public SelectFrom<RCDistributorSalesStat>.View Records;
and everytime I save the first record entered I get an error and it has added a second blank line and throws errors that required fields are missing.
I found a similar question to this on here about having multiple ISKey set, though I only have one.
#region DistributorSalesStatID
[PXDBIdentity(IsKey = true)]
public virtual int? DistributorSalesStatID { get; set; }
public abstract class distributorSalesStatID : PX.Data.BQL.BqlInt.Field<distributorSalesStatID> { }
#endregion
#region InventoryID
[StockItem(Visibility = PXUIVisibility.SelectorVisible, DescriptionField = typeof(InventoryItem.inventoryCD), Enabled = true)]
[PXRestrictor(typeof(Where<InventoryItem.baseUnit.IsEqual<BQLConstants.Straw>>), null)]
[PXForeignReference(typeof(Field<inventoryID>.IsRelatedTo<InventoryItem.inventoryID>))]
public virtual int? InventoryID { get; set; }
public abstract class inventoryID : PX.Data.BQL.BqlInt.Field<inventoryID> { }
#endregion
#region StatisticDate
[PXDBDate()]
[PXUIField(DisplayName = "Statistic Date")]
public virtual DateTime? StatisticDate { get; set; }
public abstract class statisticDate : PX.Data.BQL.BqlDateTime.Field<statisticDate> { }
#endregion
#region CustomerID
[CustomerActive(
//typeof(Search<BAccountR.bAccountID, Where<True, Equal<True>>>),
Visibility = PXUIVisibility.SelectorVisible,
DescriptionField = typeof(Customer.acctName),
Filterable = true) ]
//[CustomerOrOrganizationInNoUpdateDocRestrictor]
[PXForeignReference(typeof(Field<RCDistributorSalesStat.customerID>.IsRelatedTo<PXAccess.BAccount.bAccountID>))]
public virtual int? CustomerID { get; set; }
public abstract class customerID : PX.Data.BQL.BqlInt.Field<customerID> { }
#endregion
#region CustomerLocationID
[LocationActive(typeof(Where<Location.bAccountID, Equal<Current<customerID>>,
And<MatchWithBranch<Location.cBranchID>>>),
DescriptionField = typeof(Location.descr),
Visibility = PXUIVisibility.SelectorVisible)]
[PXDefault(typeof(Coalesce<Search2<BAccountR.defLocationID,
InnerJoin<CRLocation, On<CRLocation.bAccountID, Equal<BAccountR.bAccountID>, And<CRLocation.locationID, Equal<BAccountR.defLocationID>>>>,
Where<BAccountR.bAccountID, Equal<Current<customerID>>,
And<CRLocation.isActive, Equal<True>,
And<MatchWithBranch<CRLocation.cBranchID>>>>>,
Search<CRLocation.locationID,
Where<CRLocation.bAccountID, Equal<Current<customerID>>,
And<CRLocation.isActive, Equal<True>, And<MatchWithBranch<CRLocation.cBranchID>>>>>>))]
[PXForeignReference(
typeof(CompositeKey<
Field<customerID>.IsRelatedTo<Location.bAccountID>,
Field<customerLocationID>.IsRelatedTo<Location.locationID>
>))]
public virtual int? CustomerLocationID { get; set; }
public abstract class customerLocationID : PX.Data.BQL.BqlInt.Field<customerLocationID> { }
#endregion
#region SalesAmount
[PXDBDecimal()]
[PXUIField(DisplayName = "Sales Amount")]
public virtual Decimal? SalesAmount { get; set; }
public abstract class salesAmount : PX.Data.BQL.BqlDecimal.Field<salesAmount> { }
#endregion
#region SalesUnits
[PXDBInt()]
[PXUIField(DisplayName = "Sales Units")]
public virtual int? SalesUnits { get; set; }
public abstract class salesUnits : PX.Data.BQL.BqlInt.Field<salesUnits> { }
#endregion
#region QuantityOnHand
[PXDBInt()]
[PXUIField(DisplayName = "Quantity On Hand")]
public virtual int? QuantityOnHand { get; set; }
public abstract class quantityOnHand : PX.Data.BQL.BqlInt.Field<quantityOnHand> { }
#endregion
I am unsure what is causing the unwanted row to try and persist.
I have changed my keys around, I removed my IsKey on the PXDBIdentity and set two other fields as the key in the DAC and the DB. That seems to have the desired effect as no blank row gets created during Save. Upon further testing it appears that for our listview page I was missing "px:Selector" rows inside of my RowTemplate in my Grid.
I am trying to create a processing page to extract data from several tables which will be used to update the EDI service item list. I keep getting an error that states the specified cast for BasePrice is not valid.
This is simply an internal DAC in the BLC. There is no physical table in the database. If I exclude my BasePrice field everything works fine. If I include it, the insert gets the error. See the code below.
public class EDInventoryProcess : PXGraph<EDInventoryProcess>
{
public PXCancel<EDInventoryFilter> Cancel;
public PXFilter<EDInventoryFilter> Filter;
[PXFilterable]
public PXFilteredProcessingOrderBy<EDInventory, EDInventoryFilter,
OrderBy<Asc<EDInventory.partnerID, Asc<EDInventory.inventoryCD>>>> EDItem;
protected virtual IEnumerable eDItem()
{
EDItem.Cache.Clear();
var cmd = new PXSelectJoin<InventoryItem,
InnerJoin<INItemXRef, On<InventoryItem.inventoryID, Equal<INItemXRef.inventoryID>>,
InnerJoin<EDPartnerInfo, On<INItemXRef.bAccountID, Equal<EDPartnerInfo.customerID>>>>,
Where<INItemXRef.alternateType, Equal<INAlternateType.cPN>,
And<InventoryItem.itemStatus, Equal<InventoryItemStatus.active>>>>(this);
cmd.View.Clear();
var ret = cmd.Select();
if (ret != null)
{
EDInventoryFilter filt = (EDInventoryFilter)Filter.Cache.Current;
EDInventory edInv = new EDInventory();
foreach (PXResult<InventoryItem, INItemXRef, EDPartnerInfo> record in ret)
{
edInv = new EDInventory();
InventoryItem item = (InventoryItem)record;
INItemXRef xref = (INItemXRef)record;
EDPartnerInfo partner = (EDPartnerInfo)record;
edInv.PartnerID = partner.PartnerID;
edInv.InventoryID = item.InventoryID;
edInv.InventoryCD = item.InventoryCD;
edInv.ItemDescr = item.Descr;
edInv.ItemStatus = item.ItemStatus;
edInv.BaseUnit = item.BaseUnit;
edInv.SalesUnit = item.SalesUnit;
edInv.PurchaseUnit = item.PurchaseUnit;
edInv.BasePrice = Convert.ToDecimal(item.BasePrice);
//This is the lint that generates the error.
edInv = EDItem.Insert(edInv);
EDItem.Cache.SetStatus(edInv, PXEntryStatus.Held);
yield return edInv;
}
}
EDItem.Cache.IsDirty = false;
}
Here is the DAC definition:
[Serializable]
public partial class EDInventoryFilter : IBqlTable
{
#region TradingPartner
public abstract class tradingPartner : PX.Data.IBqlField
{
}
protected string _TradingPartner;
[PXString(15)]
[PXUIField(DisplayName = "Trading Partner")]
[PXStringList(new string[] { }, new string[] { })]
public virtual String TradingPartner { get; set; }
#endregion
#region Action
public abstract class action : PX.Data.IBqlField { }
protected string _Action;
[PXString(15)]
[PXUIField(DisplayName = "Action")]
[PXStringList(new string[] { "P" }, new string[] { "Push to EDI" })]
public virtual String Action { get; set; }
#endregion
}
[Serializable]
public partial class EDInventory : IBqlTable
{
#region PartnerID
public abstract class partnerID : IBqlField { }
[PXString(30, IsUnicode = true, IsKey = true)]
[PXDefault("")]
[PXUIField(DisplayName = "Partner")]
public virtual string PartnerID { get; set; }
#endregion
#region InventoryID
public abstract class inventoryID : PX.Data.IBqlField { }
protected Int32? _InventoryID;
[PXInt]
[PXUIField(DisplayName = "Inventory ID", Visibility = PXUIVisibility.Visible, Visible = false)]
public virtual Int32? InventoryID { get; set; }
#endregion
#region InventoryCD
public abstract class inventoryCD : PX.Data.IBqlField { }
protected String _InventoryCD;
[PXDefault()]
[InventoryRaw(IsKey = true, DisplayName = "Inventory ID")]
public virtual String InventoryCD { get; set; }
#endregion
#region ItemDescr
public abstract class itemDescr : PX.Data.IBqlField { }
protected String _ItemDescr;
[PXString(255, IsUnicode = true)]
[PXUIField(DisplayName = "Item Description")]
public virtual String ItemDescr { get; set; }
#endregion
#region ItemStatus
public abstract class itemStatus : PX.Data.IBqlField { }
protected String _ItemStatus;
[PXString(2, IsFixed = true)]
[PXDefault("AC")]
[PXUIField(DisplayName = "Item Status", Visibility = PXUIVisibility.SelectorVisible)]
public virtual String ItemStatus { get; set; }
#endregion
#region BaseUnit
public abstract class baseUnit : PX.Data.IBqlField { }
protected String _BaseUnit;
[PXString]
[PXDefault("")]
[PXUIField(DisplayName = "Base Unit", Visibility = PXUIVisibility.SelectorVisible)]
public virtual String BaseUnit { get; set; }
#endregion
#region SalesUnit
public abstract class salesUnit : PX.Data.IBqlField { }
protected String _SalesUnit;
[PXString]
[PXDefault("")]
[PXUIField(DisplayName = "Sales Unit", Visibility = PXUIVisibility.SelectorVisible)]
public virtual String SalesUnit { get; set; }
#endregion
#region PurchaseUnit
public abstract class purchaseUnit : PX.Data.IBqlField { }
protected String _PurchaseUnit;
[PXString]
[PXDefault("")]
[PXUIField(DisplayName = "Purchase Unit", Visibility = PXUIVisibility.SelectorVisible)]
public virtual String PurchaseUnit { get; set; }
#endregion
#region BasePrice
public abstract class basePrice : PX.Data.IBqlField { }
protected Decimal? _BasePrice;
[PXPriceCost()]
[PXDefault(0.0)]
[PXUIField(DisplayName = "Default Price", Visibility = PXUIVisibility.SelectorVisible)]
public virtual Decimal? BasePrice { get; set; }
#endregion
}
I just discovered what might be the answer. I was listing the default value as
[PXDefault(0.0)]
but I found another reference for decimal default as
[PXDefault(TypeCode.Decimal, "0.0")]
which seems to work. I no longer get the error and my processing screen displays as expected. I had assumed the default value drew its type from the object.
Yes for Decimal fields set [PXDefault(TypeCode.Decimal, "0.0")] attribute to avoid casting issues.
I have a grid embedded in a popup that stores user selected items from another grid. The user highlights the desired row, clicks a button, and it is added as a new row in the grid based on the information of the highlighted row. For some reason, it is not adding a new row, but instead it is overwriting the current one:
Adding new row for the first time:
Trying to add second row:
The first image I selected to add a new row the first time. The second image shows that when I add a second row, it overwrites the current row instead of inserting a new row. I tried to do this whole process at first with a PXFilter and found that PXFilters only allow for one row to be stored. I then created a blank table of the same name as the filter with all of the fields, changed the view to PXSelect, and thought it might be that, but it didn't fix it.
The code for the Add to MTO button is:
public PXAction<PMProject> addToMTO;
[PXUIField(DisplayName = "Add to MTO")]
[PXButton]
protected virtual void AddToMTO()
{
SOSiteStatusSelected row = sitestatus.Current;
if (row == null)
return;
bool isMade = false;
//NOTE: If you have a more efficient method to check if a view contains a row, please include that in the answer.
foreach (MTOLSelected testLine in SelectedItems.Select())
{
if (testLine.ItemID == row.InventoryID)
{
isMade = true;
break;
}
}
if (!isMade)
{
MTOLSelected line = new MTOLSelected();
SelectedItems.Insert(line);
line.ItemID = row.InventoryID;
line.ItemCD = row.InventoryCD;
line.Price = row.CuryUnitPrice;
line.Descr = row.Descr;
SelectedItems.Update(line);
}
else
{
SelectedItems.Ask("This item is already moved into the MTO List", MessageButtons.OK);
}
}
The DAC is:
[Serializable]
public class MTOLSelected : IBqlTable
{
[PXDBIdentity]
[PXUIField(DisplayName = "MTOLID")]
public int? Id { get; set; }
public abstract class id : IBqlField { }
//Might more Drawing Number and Qty Required to this new table
#region ItemID
[PXDBInt()]
[PXUIField(DisplayName = "ID")]
public virtual int? ItemID { get; set; }
public abstract class itemID : IBqlField { }
#endregion
#region ItemCD
[PXDBString(15)]
[PXUIField(DisplayName = "Item CD")]
public virtual string ItemCD { get; set; }
public abstract class itemCD : IBqlField { }
#endregion
#region Descr
[PXDBString(255)]
[PXUIField(DisplayName = "Desc")]
public virtual string Descr { get; set; }
public abstract class descr : IBqlField { }
#endregion
#region Qty
[PXDBInt()]
[PXUIField(DisplayName = "Qty")]
public virtual int? Qty { get; set; }
public abstract class qty : IBqlField { }
#endregion
#region Price
[PXDBDecimal()]
[PXUIField(DisplayName = "Price")]
public virtual decimal? Price { get; set; }
public abstract class price : IBqlField { }
#endregion
#region Length
[PXDBDecimal()]
[PXUIField(DisplayName = "Length")]
public virtual decimal? Length { get; set; }
public abstract class length : IBqlField { }
#endregion
#region Feet
[PXDBInt()]
[PXUIField(DisplayName = "Feet")]
public virtual int? Feet { get; set; }
public abstract class feet : IBqlField { }
#endregion
#region Inches
[PXDBDecimal()]
[PXUIField(DisplayName = "Inches")]
public virtual decimal? Inches { get; set; }
public abstract class inches : IBqlField { }
#endregion
}
Your DAC appears to need IsKey on the Identity field: [PXDBIdentity(IsKey=true)]
FormulaID is the identity field and it's new developed screen, but I am not able to get the selector. I have tried all the ways that I know to achieve that:
Maintaining parent and child relationships
Dataview with BQL Query
Below are the definitions of the FormulaID and FormulaCD from DAC:
#region FormulaID
public abstract class formulaID : PX.Data.IBqlField
{
}
protected int? _FormulaID;
[PXDBIdentity(IsKey =true)]
[PXUIField(Enabled = false)]
public virtual int? FormulaID
{
get
{
return this._FormulaID;
}
set
{
this._FormulaID = value;
}
#endregion
#region FormulaCD
public abstract class formulaCD : PX.Data.IBqlField
{
}
protected string _FormulaCD;
[PXDBString(30,IsUnicode = true)]
[PXUIField(DisplayName = "Formula ID", Visibility = PXUIVisibility.SelectorVisible)]
[PXSelector(typeof(Search<TSFormula.formulaCD>),
typeof(TSFormula.descr),SubstituteKey = typeof(TSFormula.formulaCD), ValidateValue = false)]
public virtual string FormulaCD
{
get
{
return this._FormulaCD;
}
set
{
this._FormulaCD = value;
}
}
#endregion
In my example below, the PXDBIdentity integer field is not enabled and not visible. The String field is marked isKey=true with the PXSelector described. The ASPX page markup offers the px:PXSelector tag for the String field as shown:
<px:PXSelector ID="edContractNumber" runat="server" DataField="ContractNumber"
AutoRefresh="True" DataSourceID="ds" NullText="<NEW>">
<GridProperties FastFilterFields="ShortName">
<Columns>
<px:PXGridColumn DataField="ContractNumber" Width="90px"></px:PXGridColumn>
<px:PXGridColumn DataField="ShortName" Width="120px"></px:PXGridColumn>
</Columns>
</GridProperties>
</px:PXSelector>
Here are the DAC fields:
#region ContractID
public abstract class contractID : PX.Data.IBqlField
{
}
[PXDBIdentity()]
[PXDefault(0)]
[PXUIField(Visible = false, Enabled = false)]
public virtual int? ContractID
{
get;
set;
}
#endregion
#region ContractNumber
public abstract class contractNumber : PX.Data.IBqlField
{
}
[PXDBString(IsKey = true)]
[PXDefault()]
[PXSelector(typeof(Search3<MyDAC.contractNumber,
OrderBy<Desc<MyDAC.contractID>>>),
new Type[] {
typeof(MyDAC.shortName),
typeof(MyDAC.contractNumber)},
DirtyRead = true)]
[PXUIField(DisplayName = "Contract Number", Required = true)]
public virtual string ContractNumber { get; set; }
#endregion
I'm creating a Process to import items from an external API source into records in Acumatica.
I've created an unbound DAC that is used to represent the entries available from the external API.
[Serializable]
public class ImportItem : IBqlTable
{
[PXBool]
[PXUIField(DisplayName = "Selected")]
public bool? Selected { get; set; }
public abstract class selected : IBqlField { }
[PXString]
[PXUIField(DisplayName = "External Ref Nbr")]
public string RefNbr { get; set; }
public abstract class refNbr : IBqlField { }
}
In a Process graph I implement the delegate of the main view to create and return the Resultset (normally generated from the API data). I then have a screen bound to this graph with a grid view that displays the items to allow the user to select the ones to import. The main Process delegate will then create the records in Acumatica for the selected items.
public class ImportItemsProcess : PXGraph<ImportItemsProcess>
{
public PXProcessing<ImportItem> ImportItems;
public PXCancel<ImportItem> Cancel;
public ImportItemsProcess()
{
ImportItems.SetProcessCaption("Import");
ImportItems.SetProcessAllCaption("Import All");
ImportItems.SetProcessDelegate(ProcessImportItems);
}
protected virtual IEnumerable importItems(PXAdapter adapter)
{
PXResultset<ImportItem> items = new PXResultset<ImportItem>();
/* Would create ImportItems from external API data here */
items.Add(new PXResult<ImportItem>(new ImportItem() { RefNbr = "1" }));
items.Add(new PXResult<ImportItem>(new ImportItem() { RefNbr = "2" }));
items.Add(new PXResult<ImportItem>(new ImportItem() { RefNbr = "3" }));
return items;
}
public static void ProcessImportItems(List<ImportItem> importItems)
{
throw new PXException("ProcessImportItems() has been called");
}
}
And the ASPX page:
<asp:Content ID="cont1" ContentPlaceHolderID="phDS" runat="Server">
<px:PXDataSource ID="ds" runat="server" Visible="True" Width="100%" PrimaryView="ImportItems" TypeName="APIImporter.ImportItemsProcess" >
</px:PXDataSource>
</asp:Content>
<asp:Content ID="cont2" ContentPlaceHolderID="phL" runat="Server">
<px:PXGrid ID="grid" runat="server" Height="400px" Width="100%" Style="z-index: 100"
AllowPaging="True" AllowSearch="True" AdjustPageSize="Auto" DataSourceID="ds" SkinID="Primary" TabIndex="1500" TemporaryFilterCaption="Filter Applied">
<Levels>
<px:PXGridLevel DataMember="ImportItems">
<RowTemplate>
<px:PXCheckBox ID="edSelected" runat="server" AlreadyLocalized="False" DataField="Selected" Text="Selected" CommitChanges="true">
</px:PXCheckBox>
<px:PXTextEdit ID="edRefNbr" runat="server" AlreadyLocalized="False" DataField="RefNbr" DefaultLocale="">
</px:PXTextEdit>
</RowTemplate>
<Columns>
<px:PXGridColumn DataField="Selected" TextAlign="Center" Type="CheckBox" Width="60px" CommitChanges="true">
</px:PXGridColumn>
<px:PXGridColumn DataField="RefNbr">
</px:PXGridColumn>
</Columns>
</px:PXGridLevel>
</Levels>
<AutoSize Container="Window" Enabled="True" MinHeight="200" />
</px:PXGrid>
</asp:Content>
When written as the simplified example here the Process delegate is never invoked. I suspect is has something to do with when the Process button is clicked the callback to the server runs the view's delegate function that re-creates the list of ImportItem objects and that the framework can not relate the newly created objects to the ones in the postback without a Key field. However, if I add an IsKey attribute to the RefNbr of the DAC...
[PXString(IsKey = true)]
[PXUIField(DisplayName = "External Ref Nbr")]
public string RefNbr { get; set; }
...now when selecting an item on the Screen I'm immediately given a line-level error with the message "Error: The argument is out of range. Parameter name: table".
In the data view delegate, you have to add the items to the Cache in addition to returning them. Try below:
protected virtual IEnumerable importItems()
{
int iCachedData = 0;
foreach (var row in ImportItems.Cache.Cached)
{
iCachedData++;
yield return row;
}
if (iCachedData == 0)
{
for (int iCounter = 1; iCounter <= 5; iCounter++)
{
ImportItem item = new ImportItem() { RefNbr = iCounter };
item = ImportItems.Insert(item);
ImportItems.Cache.SetStatus(item, PXEntryStatus.Held);
yield return item;
}
}
}
Good luck!
Try adding abstract classes for your DAC fields first.
If that doesn't resolve your issue please add your ASPX code to your question.
[Serializable]
public class ImportItem : IBqlTable
{
#region Selected
public abstract class selected : IBqlField { }
[PXBool]
[PXUIField(DisplayName = "Selected")]
public bool? Selected { get; set; }
#endregion
#region RefNbr
public abstract class refNbr : IBqlField { }
[PXString]
[PXUIField(DisplayName = "External Ref Nbr")]
public string RefNbr { get; set; }
#endregion
}
I have tried the Processing Graph functionality Using Bound DAC but not Database Table.
This is useful in the case when you want to Access some API and fetch the records in processing screen without saving into the Database. I am not including aspx code here.
The Highlight point in this code in [PXVirtualDAC] and the Key Field in DAC because of this we can achieve this functionality without creating a table. You can say that a Virtual DAC - without bound any database table.
public class TestUnboundProcessing : PXGraph<TestUnboundProcessing>
{
#region Unbound DAC
public class UnboundDAC : IBqlTable
{
#region Selected
[PXDBBool]
[PXUIField(DisplayName = "Selected")]
public virtual bool? Selected { get; set; }
public abstract class selected : PX.Data.IBqlField { }
#endregion
[PXDBString(50, IsUnicode = true,IsKey =true)]
[PXUIField(DisplayName = "Id")]
public string Id { get; set; }
public abstract class id : PX.Data.IBqlField { }
[PXDBString(100, IsUnicode = true)]
[PXUIField(DisplayName = "Author")]
public string Author { get; set; }
public abstract class author : PX.Data.IBqlField { }
[PXDBString(1000, IsUnicode = true)]
[PXUIField(DisplayName = "Body")]
public string Body { get; set; }
public abstract class body : PX.Data.IBqlField { }
}
#endregion
#region Processing Filter DAC
[Serializable]
public partial class TestFilter : PX.Data.IBqlTable
{
#region LastSyncDate
[PXDate()]
[PXDefault(typeof(AccessInfo.businessDate))]
[PXUIField(DisplayName = "Last Sync Date", Visibility = PXUIVisibility.Visible)]
public virtual DateTime? LastSyncDate { get; set; }
public abstract class lastSyncDate : PX.Data.IBqlField { }
#endregion
#region ProjectID
[PXDBString(10, IsUnicode = true)]
[PXUIField(DisplayName = "Project ID")]
public virtual String ProjectID { get; set; }
public abstract class projectID : PX.Data.IBqlField { }
#endregion
#region IssueID
[PXDBString(10, IsUnicode = true)]
[PXUIField(DisplayName = "Issue ID", Visibility = PXUIVisibility.SelectorVisible)]
public virtual String IssueID { get; set; }
public abstract class issueID : PX.Data.IBqlField { }
#endregion
}
#endregion
#region Filter + Delegate Overrides
public PXFilter<TestFilter> Filter;
public PXCancel<TestFilter> Cancel;
[PXVirtualDAC]
[PXFilterable]
public PXFilteredProcessing<UnboundDAC, TestFilter> UnboundView;
protected virtual IEnumerable unboundView()
{
GetUnboundDACList();
foreach (UnboundDAC item in UnboundView.Cache.Cached)
{
yield return item;
}
}
private void GetUnboundDACList()
{
UnboundView.Cache.Insert(new UnboundDAC() { Id = "1", Author = "Test 1", Body = "Comment 1" });
UnboundView.Cache.Insert(new UnboundDAC() { Id = "2", Author = "Test 2", Body = "Comment 2" });
UnboundView.Cache.Insert(new UnboundDAC() { Id = "3", Author = "Test 3", Body = "Comment 3" });
//return UnboundView.Cache;
}
#endregion
#region Constructor + Process
public TestUnboundProcessing()
{
TestFilter filter = Filter.Current;
UnboundView.SetProcessDelegate(delegate (List<UnboundDAC> docList)
{
UnboundProcessing(docList, filter);
}
);
}
#endregion
#region Processing functions
public static void UnboundProcessing(List<UnboundDAC> docList, TestFilter aFilter)
{
TestUnboundProcessing graph = CreateInstance<TestUnboundProcessing>();
graph.SaveRecords(graph, docList, aFilter);
}
public void SaveRecords(TestUnboundProcessing aProcessingGraph, List<UnboundDAC> docList, TestFilter aFilter)
{
bool isErrorOccured = false;
CRActivityMaint graph = PXGraph.CreateInstance<CRActivityMaint>();
foreach (UnboundDAC item in docList)
{
try
{
CRActivity addedActivity = new CRActivity();
addedActivity.UIStatus = ActivityStatusListAttribute.Completed;
addedActivity.Type = "N";
addedActivity.Location = item.Id;
addedActivity.Subject = item.Author;
addedActivity.Body = item.Body;
addedActivity.IsPrivate = true;
graph.Activities.Insert(addedActivity);
}
catch (Exception ex)
{
isErrorOccured = true;
PXProcessing<JRComment>.SetError(docList.IndexOf(item), ex.Message);
}
}
if (graph.Activities.Cache.Cached.Count() > 0)
{
graph.Actions.PressSave();
}
if (isErrorOccured)
{
throw new PXException("One or more record processed unsuccessful");
}
}
#endregion
#region Filter Events
protected virtual void TestFilter_LastSyncDate_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
{
UnboundView.Cache.Clear();
}
protected virtual void TestFilter_ProjectID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
{
UnboundView.Cache.Clear();
}
protected virtual void TestFilter_IssueID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
{
UnboundView.Cache.Clear();
}
#endregion