I have a question relating to CRM DateTime problem. In opportunity form has custom DateTime field(Tender submission Date) that shows on form 'Date only' Format.
And other string field (Tender Date) that modifies date when Tender submission date changes. Let say...
Tender submission date is 29/06/2011 12:00:00
Tender Date should be 29/06/2012
I create the plug-in for Create Post-operation and Update Pre-operation. I retrieves TenderSubDate.Day, Month and Year.
Crm Time zone is (GMT+08:00) Kuala Lumpur,Singapore then want to change (GMT-06:00) Central Time(US & Canada).
The problem is that when i update Tender date based on Tender submission date, the program return one day less than or grater than Tender sub date. Let say..
First Secnario
Tender submission date is 29/06/2012 12:00:00am
Program returns 28/06/2012(it's wrong and it should be 29/06/2012)
Second secnario
Tender submission date is 1/08/2012 12:00:00am
Program returns 32/07/2012(it's wrong and it should be 1/08/2012)
what should i do in my program. please give me some idea. Here is my plug in code
public class TenderSubDateChange : IPlugin
{
#region Class Level Variables
//IServiceProvider _serviceProvider;
//IOrganizationServiceFactory _serviceFactory = null;
//IOrganizationService _service = null;
//IPluginExecutionContext _context = null;
Entity _target = null;
Entity _preImage = null;
Entity _postImage = null;
Guid _currentUser;
#endregion
#region IPlugin Members
public void Execute(IServiceProvider serviceProvider)
{
try
{
string message = null;
IPluginExecutionContext _context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
#region Organization Services
// Obtain the organization service reference.
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(_context.UserId);
#endregion
var ServiceContext = new OrganizationServiceContext(service);
_currentUser = _context.UserId;
message = _context.MessageName.ToLower();
if (message == "create")//message == "create" ||
{
if (_context.InputParameters.Contains("Target") && _context.InputParameters["Target"] != null)
_target = (Entity)_context.InputParameters["Target"];
if (_context.PreEntityImages.Contains("PreImage") && _context.PreEntityImages["PreImage"] != null)
_preImage = (Entity)_context.PreEntityImages["PreImage"];
if (_context.PostEntityImages.Contains("PostImage") && _context.PostEntityImages["PostImage"] != null)
_postImage = (Entity)_context.PostEntityImages["PostImage"];
DateTime hm_tenderdate;
if (_target.Attributes.Contains("hm_tendersubmissiondate"))
{
hm_tenderdate = (DateTime)_target.Attributes["hm_tendersubmissiondate"];
_target.Attributes["hm_tendersubdate"] = (hm_tenderdate.Day) + "/" + hm_tenderdate.Month + "/" + hm_tenderdate.Year;
service.Update(_target);
}
}
if (message == "update")//message == "create" ||
{
if (_context.InputParameters.Contains("Target") && _context.InputParameters["Target"] != null)
_target = (Entity)_context.InputParameters["Target"];
if (_context.PreEntityImages.Contains("PreImage") && _context.PreEntityImages["PreImage"] != null)
_preImage = (Entity)_context.PreEntityImages["PreImage"];
if (_context.PostEntityImages.Contains("PostImage") && _context.PostEntityImages["PostImage"] != null)
_postImage = (Entity)_context.PostEntityImages["PostImage"];
DateTime hm_tenderdate;
if (_target.Attributes.Contains("hm_tendersubmissiondate"))
{
hm_tenderdate = (DateTime)_target.Attributes["hm_tendersubmissiondate"];
_target.Attributes["hm_tendersubdate"] = (hm_tenderdate.Day) + "/" + hm_tenderdate.Month + "/" + hm_tenderdate.Year;
}
}
}
catch (Exception ex)
{
throw new InvalidPluginExecutionException(ex.Message, ex);
}
}
#endregion
}
I faced this issue before and drove me crazy and the solution is to convert UTC time to local time
DateTime tenderDate = ((DateTime)target["new_tender"]).ToLocal();
Related
I want to create Customer Location from Sales Order Ship to Contact and Address. The following code works fine when order is saved and a new location is created.
The problem is: After I created a new order with order type “SO” and save the location, I go back to the Order Entry point screen, then click add new order. In new order screen, I select order type “QT” and select the same customer, the ADDRESS tab info are all blank. If I click save button, I got the error message “Error: ‘CustomerID’cannot be empty”. It seems the Customer is not selected. I have to select Customer again.
This only happens when location is saved, and create a new order with different order type and same customer. If I don't go back to the Order Entry point screen, and click + from Sales Order screen directly, it works fine.
namespace PX.Objects.SO
{
// Acuminator disable once PX1016 ExtensionDoesNotDeclareIsActiveMethod extension should be constantly active
public class SOOrderEntry_CBIZExtension : PXGraphExtension<PX.Objects.SO.SOOrderEntry>
{
#region Event Handlers
public delegate void PersistDelegate();
[PXOverride]
public void Persist(PersistDelegate baseMethod)
{
SOShippingContact shippingContact = Base.Shipping_Contact.Select();
SOShippingAddress shippingAddress = Base.Shipping_Address.Select();
SOOrder order = Base.CurrentDocument.Select();
SOOrderExt orderExt = order.GetExtension<SOOrderExt>();
if (orderExt != null && orderExt.UsrSaveLocation == true
&& !(string.IsNullOrEmpty(shippingContact.FullName)))
{
// get LOCATION segment length
Segment seg = SelectFrom<Segment>.Where<Segment.dimensionID.IsEqual<#P.AsString>>.View.
SelectSingleBound(Base, null, "LOCATION");
int locationLength = 10;
if (seg != null)
locationLength = seg.Length.Value;
// Get Location Name
string[] nameList = shippingContact.FullName.Split(' ');
string locationFirstName = nameList[0];
if (locationFirstName.Length > locationLength)
locationFirstName = locationFirstName.Substring(0, locationLength);
// Check if Customer location already exist
Location location = SelectFrom<Location>.Where<Location.bAccountID.IsEqual<#P.AsInt>.
And<Location.locationCD.IsEqual<#P.AsString>>>.View.
SelectSingleBound(Base, null, Base.Document.Current.CustomerID, locationFirstName);
if (location == null)
{
// New Customer location
// Create Location Instance
LocationMaint locationMaint = PXGraph.CreateInstance<CustomerLocationMaint>();
var loc = (Location) locationMaint.Location.Cache.CreateInstance();
loc.BAccountID = Base.Document.Current.CustomerID;
locationMaint.Location.Cache.SetValueExt<Location.locationCD>(loc, locationFirstName);
loc.LocType = LocTypeList.CustomerLoc;
loc = locationMaint.Location.Insert(loc);
loc.Descr = shippingContact.FullName;
loc = locationMaint.Location.Update(loc);
if (shippingContact.OverrideContact == true)
{
loc.OverrideContact = true;
loc = locationMaint.Location.Update(loc);
string firstName = nameList[0];
string lastName = "";
if (nameList.Length > 1)
lastName = nameList[1];
Contact cont = locationMaint.Contact.Current;
cont.FullName = shippingContact.FullName;
cont.FirstName = firstName;
cont.LastName = lastName;
cont.Attention = shippingContact.Attention;
cont.Phone1 = shippingContact.Phone1;
cont.Phone1Type = shippingContact.Phone1Type;
cont.EMail = shippingContact.Email;
cont = locationMaint.Contact.Update(cont);
}
if (shippingAddress.OverrideAddress == true)
{
loc.OverrideAddress = true;
loc = locationMaint.Location.Update(loc);
var addr = locationMaint.Address.Current;
addr.AddressLine1 = shippingAddress.AddressLine1;
addr.AddressLine2 = shippingAddress.AddressLine2;
addr.City = shippingAddress.City;
addr.CountryID = shippingAddress.CountryID;
addr.State = shippingAddress.State;
addr.PostalCode = shippingAddress.PostalCode;
addr = locationMaint.Address.Update(addr);
}
// Save the customer location
locationMaint.Actions.PressSave();
}
}
// Call bas method
baseMethod();
Base.Shipping_Contact.Cache.Clear();
Base.Shipping_Address.Cache.Clear();
Base.Document.View.RequestRefresh();
Base.Document.Cache.IsDirty = false;
}
#endregion
}
}
Basically i want to create a new action button On Print Invoice and Memos screen to print a report for selected invoices.
Why we are creating new action button is, here we need to print different formats for each invoice (SO type) so when user selects 3 different records in grid
for an example
1. INV1234 and so type is TS then i need to print xyz report
2. INV9875 and this has not created through SO then i need to print ABC report
3. CRM4567 and SO type is TS (like above 1 option)
so here 1 & 3 should print in one page (Like same how process button is working in default acumatica)
2 option report should print in new tab.
If i get a sample code on to print same report in single page and other one in another tab is fine.
Below is the code
public PXAction<PrintInvoicesFilter> PrintReport;
[PXUIField(DisplayName = "Print Sales Invoice with Price", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
[PXLookupButton]
public virtual IEnumerable printReport(PXAdapter adapter, [PXString] string reportID)
{
PXReportRequiredException ex = null;
foreach (ARInvoice doc in Base.ARDocumentList.Cache.Cached)
{
var parameters = new Dictionary<string, string>();
if (doc.Selected == true)
{
ARTran TranData = PXSelectReadonly<ARTran, Where<ARTran.tranType, Equal<Required<ARTran.tranType>>,
And<ARTran.refNbr, Equal<Required<ARTran.refNbr>>>>>.Select(Base, doc.DocType, doc.RefNbr);
if (TranData != null)
{
if (TranData.SOOrderType == "WS" || TranData.SOOrderType == "WO" || TranData.SOOrderType == "TS" || TranData.SOOrderType == "IM")
{
if (reportID == null) reportID = "KR501011";
if (reportID == "KR501011")
{
parameters["DocType"] = doc.DocType;
parameters["RefNbr"] = doc.RefNbr;
}
ex = PXReportRequiredException.CombineReport(ex, "KR501011", parameters,false);
}
if (TranData.SOOrderType == "RX")
{
if (reportID == null) reportID = "KR501016";
if (reportID == "KR501016")
{
parameters["DocType"] = doc.DocType;
parameters["RefNbr"] = doc.RefNbr;
}
ex = PXReportRequiredException.CombineReport(ex, "KR501016", parameters,false);
}
if (string.IsNullOrEmpty(TranData.SOOrderType))
{
if (reportID == null) reportID = "KR501038";
if (reportID == "KR501038")
{
parameters["DocType"] = doc.DocType;
parameters["RefNbr"] = doc.RefNbr;
}
ex = PXReportRequiredException.CombineReport(ex, "KR501038", parameters,false);
}
}
}
}
if (ex != null)
{
ex.Mode = PXBaseRedirectException.WindowMode.New;
ex.SeparateWindows = false;
throw ex;
}
Thanks in advance.
Redirecting to multiple report or combining multiple report in a single document can only be achieved with method PXReportRequiredException.CombineReport.
The redirection exception has two options to control how the reports are combined:
Print all report as a single PDF file – ex.SeparateWindows = false;
Open each separate report in a new tab – ex.SeparateWindows = true;
Your requirement asked for 1 and 2 at the same time which is not possible. You can only choose option 1 or 2. To get both you would need two actions button to launch the reports.
The reason for the limitation is because to redirect to a report you have to throw an exception. Once the exception is thrown you can't execute code anymore to launch a new report. It is possible to print multiple reports with a single exception as explained below but you have to choose between all reports in same tab (same document) or one report per tab (one document per report).
Blog Source: https://asiablog.acumatica.com/2017/03/launch-multiple-reports-with-one-exception.html
Code example from that blog source:
PXReportRequiredException ex = null;
if(row.ARRefNumber != null)
{
Dictionary<string, string> dictionary = new Dictionary<string, string>();
dictionary["DocType"] = row.ARDocType;
dictionary["RefNbr"] = row.ARRefNumber;
ex = PXReportRequiredException.CombineReport(ex, row.ARBatchNumber == null ? "AR610500" : "AR622000", dictionary, false);
}
if (row.APRefNumber != null)
{
APInvoice inv = PXSelectorAttribute.Select<DocHeader.aPRefNumber>(Document.Cache, row) as APInvoice;
Dictionary<string, string> dictionary = new Dictionary<string, string>();
dictionary["DocType"] = row.APDocType;
dictionary["RefNbr"] = row.APRefNumber;
dictionary["PeriodTo"] = PX.Objects.GL.OpenPeriodAttribute.FormatForDisplay(inv.FinPeriodID);
dictionary["PeriodFrom"] = PX.Objects.GL.OpenPeriodAttribute.FormatForDisplay(inv.FinPeriodID);
ex = PXReportRequiredException.CombineReport(ex, row.APBatchNumber == null ? "AP610500" : "AP622000", dictionary, false);
}
if (ex != null)
{
ex.Mode = PXBaseRedirectException.WindowMode.New;
ex.SeparateWindows = true;
throw ex;
}
I have a requirement to create shipment document, shipment confirmation and update In on a Sales order Transfer document.
The following code is used for shipment confirmation
public string CreateShipment()
{
bool flag = false;
string _retval = string.Empty;
using (IEnumerator<PXResult<SOOrderShipment>> enumerator = Base.shipmentlist.Select(Array.Empty<object>()).GetEnumerator())
{
if (enumerator.MoveNext())
{
SOOrderShipment current = enumerator.Current;
flag = true;
}
}
if (flag)
{
string Mess = "Error: Shipment already created.";
throw new PXException(Mess);
}
SOShipmentEntry sOShipmentEntry = PXGraph.CreateInstance<SOShipmentEntry>();
//SOOrderEntry sOOrderEntry = PXGraph.CreateInstance<SOOrderEntry>();
//sOOrderEntry.Caches.Clear();
SOOrder sOOrder = Base.Document.Current;
int? nullable = new int?(0);
int? customerLocationID = new int?(0);
if (sOOrder != null)
{
nullable = sOOrder.CustomerID;
customerLocationID = sOOrder.CustomerLocationID;
}
int? siteID = new int?(0);
//SOShipmentEntry sOShipmentEntry1 = PXGraph.CreateInstance<SOShipmentEntry>();
SOShipment destinationDocument = sOShipmentEntry.Document.Insert();
destinationDocument.ShipmentType = "T";
destinationDocument = sOShipmentEntry.Document.Update(destinationDocument);
destinationDocument.Operation = "I";
destinationDocument = sOShipmentEntry.Document.Update(destinationDocument);
using (IEnumerator<PXResult<SOLine>> enumerator1 = PXSelectReadonly<SOLine, Where<SOLine.orderType, Equal<Required<SOLine.orderType>>, And<SOLine.orderNbr, Equal<Required<SOLine.orderNbr>>>>>.Select(Base, new object[] { Base.Document.Current.OrderType, Base.Document.Current.OrderNbr }).GetEnumerator())
{
if (enumerator1.MoveNext())
{
SOLine line = (SOLine)enumerator1.Current;
siteID = line.SiteID;
}
}
destinationDocument.SiteID = siteID;
destinationDocument.DestinationSiteID = sOOrder.DestinationSiteID;
destinationDocument = sOShipmentEntry.Document.Update(destinationDocument);
//sOOrderEntry.Document.Current = sOOrder;
if (Base.Document.Current != null)
{
DocumentList<SOShipment> documentList = new DocumentList<SOShipment>(sOShipmentEntry);
sOShipmentEntry.CreateShipment(Base.Document.Current, sOShipmentEntry.Document.Current.SiteID, sOShipmentEntry.Document.Current.ShipDate, new bool?(false), "I", documentList);
if (sOShipmentEntry.Document.Current.ShipmentNbr != null)
{
SOOrderEntry sOOrderEntry1 = PXGraph.CreateInstance<SOOrderEntry>();
sOOrderEntry1.Clear();
sOOrderEntry1.Document.Current = sOOrder;
int? openShipmentCntr = Base.Document.Current.OpenShipmentCntr;
if ((openShipmentCntr.GetValueOrDefault() > 0 ? openShipmentCntr.HasValue : false))
{
sOOrder.Status = SOOrderStatus.Shipping;
sOOrder.Hold = new bool?(false);
sOOrderEntry1.Document.Update(sOOrder);
sOOrderEntry1.Save.Press();
_retval = sOShipmentEntry.Document.Current.ShipmentNbr;
}
}
}
return _retval;
}
The following code confirms the shipment and update IN.
private void ConfirmShipment(string shipmentnbr)
{
SOShipmentEntry sOShipmentEntry = PXGraph.CreateInstance<SOShipmentEntry>();
SOOrderEntry sOOrderEntry = PXGraph.CreateInstance<SOOrderEntry>();
sOShipmentEntry.Clear();
sOOrderEntry.Clear();
sOOrderEntry.Document.Current = PXSelect<SOOrder, Where<SOOrder.orderType, Equal<Required<SOOrder.orderType>>, And<SOOrder.orderNbr, Equal<Required<SOOrder.orderNbr>>>>>.Select(sOOrderEntry, Base.Document.Current.OrderType, Base.Document.Current.OrderNbr);
sOShipmentEntry.Document.Current = PXSelect<SOShipment,Where<SOShipment.shipmentNbr, Equal<Required<SOShipment.shipmentNbr>>>>.Select(sOShipmentEntry,shipmentnbr);
if(sOShipmentEntry.Document.Current!= null && sOOrderEntry.Document.Current != null)
{
sOShipmentEntry.ConfirmShipment(sOOrderEntry, sOShipmentEntry.Document.Current);
sOShipmentEntry.UpdateIN.Press();
}
}
I am able to select sales order in purchase receipt transfer document, but the shipment document status still shows open and not completed.
I have tried the run confirm shipment on the document which is already confirmed through code from the menu of shipment document and I am getting the following error
“Shipment counters are corrupted.”
I'm trying to extend the calculation of terms for invoices (Field TermsID, on Bills and Ajustments screen (AP301000)
The standard behaviour of Acumatica is : When you update the termsID field, it automatically updates the dueDate field and the discountDate field
So my idea was to look at the code in APInvoiceEntry and look for the TermsID_FieldUpdated
protected virtual void APInvoice_TermsID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
{
Terms terms = (Terms)PXSelectorAttribute.Select<APInvoice.termsID>(sender, e.Row);
if (terms != null && terms.InstallmentType != TermsInstallmentType.Single)
{
foreach (APAdjust adj in Adjustments.Select())
{
Adjustments.Cache.Delete(adj);
}
}
}
But it doesnt seem to do anything except delete the cache of the adjustments. And I dont know what to extend in order to add another way of calculating the terms dates.
(The goal is to allow the following calculation :
- I take the invoice date, add 30 days, if i'm below the 10th day of the next month, i set the due date to the 10th day of the next month, else I set the due date to the 10th day of the next next month).
Thanks,
I added a FieldUpdated event handler on DueDate and examined the call stack to find the method which modify DueDate:
It's the [Terms(...)] attribute that contains the logic:
#region TermsID
public abstract class termsID : IBqlField
{
}
/// <summary>
/// The <see cref="PX.Objects.CS.Terms">credit terms</see> associated with the document (unavailable for prepayments and debit adjustments).\
/// Defaults to the <see cref="Vendor.TermsID">credit terms of the vendor</see>.
/// </summary>
[PXDBString(10, IsUnicode = true)]
[PXDefault(typeof(Search<Vendor.termsID,
Where<Vendor.bAccountID, Equal<Current<APInvoice.vendorID>>,
And<Current<APInvoice.docType>, NotEqual<APDocType.debitAdj>>>>),
PersistingCheck = PXPersistingCheck.Nothing)]
[PXUIField(DisplayName = "Terms", Visibility = PXUIVisibility.Visible)]
[APTermsSelector]
[Terms(typeof(APInvoice.docDate), typeof(APInvoice.dueDate), typeof(APInvoice.discDate), typeof(APInvoice.curyOrigDocAmt), typeof(APInvoice.curyOrigDiscAmt))]
public virtual string TermsID
{
get;
set;
}
#endregion
Inside the Terms attribute you'll find the code modifying due date.
You could look into providing a custom attribute or bypassing that logic.
public static void CalcTermsDates(Terms terms, DateTime? docDate, out DateTime? dueDate, out DateTime? discDate)
{
dueDate = null;
discDate = null;
if (docDate != null && terms != null)
{
DateTime DocDate = docDate.Value;
switch (terms.DueType)
{
case TermsDueType.FixedNumberOfDays:
dueDate = DocDate.AddDays((double)terms.DayDue00);
break;
case TermsDueType.Prox:
DateTime sameDayOfNextMonth = DocDate.AddMonths(1);
DateTime firstDayOfNextMonth = new DateTime(sameDayOfNextMonth.Year, sameDayOfNextMonth.Month, 1);
dueDate = firstDayOfNextMonth.AddDays((double)terms.DayDue00);
break;
case TermsDueType.DayOfNextMonth:
dueDate = new PXDateTime(DocDate.Year, DocDate.Month, (int)terms.DayDue00).AddMonths(1);
break;
case TermsDueType.DayOfTheMonth:
int monthShift = DocDate.Day > (int)terms.DayDue00 ? 1 : 0;
dueDate = new PXDateTime(DocDate.Year, DocDate.Month, (int)terms.DayDue00).AddMonths(monthShift);
break;
case TermsDueType.Custom:
int nextmonth = 0;
if (DocDate.Day >= terms.DayFrom00 && DocDate.Day <= terms.DayTo00)
{
if (terms.DayDue00 <= terms.DayTo00)
{
nextmonth = 1;
}
dueDate = new PXDateTime(DocDate.Year, DocDate.Month, (int)terms.DayDue00).AddMonths(nextmonth);
}
if (DocDate.Day >= terms.DayFrom01 && DocDate.Day <= terms.DayTo01)
{
if (terms.DayDue01 <= terms.DayTo01)
{
nextmonth = 1;
}
dueDate = new PXDateTime(DocDate.Year, DocDate.Month, (int)terms.DayDue01).AddMonths(nextmonth);
}
break;
case TermsDueType.EndOfMonth:
dueDate = new DateTime(DocDate.Year, DocDate.Month, 1).AddMonths(1).AddDays(-1);
break;
case TermsDueType.EndOfNextMonth:
dueDate = new DateTime(DocDate.Year, DocDate.Month, 1).AddMonths(2).AddDays(-1);
break;
default:
break;
}
if (terms.InstallmentType == TermsInstallmentType.Multiple)
{
discDate = dueDate;
}
else
{
switch (terms.DiscType)
{
case TermsDueType.FixedNumberOfDays:
discDate = DocDate.AddDays((double)terms.DayDisc);
break;
case TermsDueType.Prox:
DateTime sameDayOfNextMonth = DocDate.AddMonths(1);
DateTime firstDayOfNextMonth = new DateTime(sameDayOfNextMonth.Year, sameDayOfNextMonth.Month, 1);
discDate = firstDayOfNextMonth.AddDays((double)terms.DayDisc);
break;
case TermsDueType.DayOfNextMonth:
discDate = new PXDateTime(DocDate.Year, DocDate.Month, (int)terms.DayDisc).AddMonths(1);
break;
case TermsDueType.DayOfTheMonth:
int monthShift;
if (terms.DueType == TermsDueType.DayOfNextMonth && DocDate.Day <= (int)terms.DayDue00)
monthShift = DocDate.Day >= (int)terms.DayDisc ? 1 : 0;
else if (terms.DueType == TermsDueType.EndOfNextMonth)
monthShift = DocDate.Day >= (int)terms.DayDisc ? 1 : 0;
else
monthShift = DocDate.Day > (int)terms.DayDue00 ? 1 : 0;
discDate = new PXDateTime(DocDate.Year, DocDate.Month, (int)terms.DayDisc).AddMonths(monthShift);
break;
case TermsDueType.EndOfMonth:
discDate = new DateTime(DocDate.Year, DocDate.Month, 1).AddMonths(1).AddDays(-1);
break;
case TermsDueType.EndOfNextMonth:
discDate = new DateTime(DocDate.Year, DocDate.Month, 1).AddMonths(2).AddDays(-1);
break;
default:
break;
}
}
if (discDate > dueDate)
{
discDate = dueDate;
}
}
}
You can create a new attribute (ex: MyTerms) deriving from an existing one (ex: Terms) and override methods (ex: CalcTerms). You then redefine/extend the field that is using that attribute (TermsID) so it uses your attribute (MyTerms) instead of (Terms).
The major issue is when the code you want to change is in methods that can't be overridden, in that case you need to copy paste the code wholesale in your custom attribute and forgo inheritance.
The starting point for that is the Attribute Code. To get it, use VIEW SOURCE feature in customization project editor:
Then use 'Find in files' to get the attribute code:
Implement a APInvoice_DueDate_FieldUpdated event handler, it will be raised when the term is changed.
I would like to join the following statement with EPEmployee table on EPEmployee's BAccountID with FSAppointmentEmployee's EmployeeID column then put where condition on EPEmployee's UserID with currently logged in employee's user id in the current BQLCommand for PXAdapter, so that I can see the list of appointments that are assigned to current employee only.
public static PXAdapter PrepareCustomNavAdapter(PXAction action, PXAdapter adapter, bool prevNextAction = false)
{
var select = adapter.View.BqlSelect;
select = select
.WhereAnd<Where<EPEmployee.userID,Equal<AccessInfo.userID>>>()
.OrderByNew<OrderBy<
Desc<FSAppointment.createdDateTime,
Desc<FSAppointment.srvOrdType,
Desc<FSAppointment.refNbr>>>>>();
var newAdapter = new PXAdapter(new PXView(action.Graph, true, select))
{
MaximumRows = adapter.MaximumRows
};
object current = action.Graph.Views[action.Graph.PrimaryView].Cache.Current;
if (prevNextAction)
{
var sortColumns = new string[adapter.SortColumns.Count() + 1];
adapter.SortColumns.CopyTo(sortColumns, 1);
sortColumns[0] = "CreatedDateTime";
newAdapter.SortColumns = sortColumns;
var descendings = new bool[adapter.Descendings.Count() + 1];
adapter.Descendings.CopyTo(descendings, 1);
descendings[0] = true;
newAdapter.Descendings = descendings;
var searches = new object[adapter.Searches.Count() + 1];
adapter.Searches.CopyTo(searches, 1);
if (current != null && current is FSAppointment)
searches[0] = ((FSAppointment)current).CreatedDateTime;
newAdapter.Searches = searches;
}
else if (current != null)
{
adapter.Currents = new object[] { current };
}
return newAdapter;
}
So that, only these two employees would be able to see that appointment.
Thank you.
AccessInfo is a Singleton, you should decorate it with Current class:
Where<EPEmployee.userID, Equal<Current<AccessInfo.userID>>>