Acumatica action not executing in import scenario - acumatica

Good day
I have an Import scenario that executes an action that I wrote. The action does work when I click it on the customer screen but when I try to execute it from an import scenario its as if it doesn't execute. I have added a breakpoint in C# to see if it ever executes but it doesn't "break".
Here is the code i am trying to execute:
public PXAction<Customer> UpdateCreditRemaining;
[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "Recalculate Credit details")]
protected void updateCreditRemaining()
{
try
{
Customer row = (Customer)this.Base.BAccount.Current;
BAccountExt curBAccountExt = row.GetExtension<BAccountExt>();
curBAccountExt.UsrUpdateDateTime = DateTime.Now.ToString();
Base.BAccount.Update(row);
// Base.Persist();
}
catch(Exception ex)
{ }
}
Here is my import Scenario
Hope someone has had the same problem and can help.

You have not updated the record with your DAC Extension object, nor have you saved it. Try this...
Base.BAccount.Update(curBAccountExt);
Base.Save.Press();
Once you update your code, try adding as a button to the page, and then press the button to see if it works as expected. Generally speaking, if it works as a button, then it should work in the import scenario.
Your code, updated:
public PXAction<Customer> UpdateCreditRemaining;
[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "Recalculate Credit details")]
protected void updateCreditRemaining()
{
try
{
Customer row = (Customer)Base.BAccount.Current;
BAccountExt curBAccountExt = row.GetExtension<BAccountExt>();
curBAccountExt.UsrUpdateDateTime = DateTime.Now.ToString();
Base.BAccount.Update(curBAccountExt);
Base.Save.Press();
}
catch(Exception ex)
{ }
}

Related

put check of a field in the tab

i want to ask your help from you.
I want to mark an existing field within a tab, the display name is project.
When selecting the template field, at that moment it brings the information from the tasks tab, at that moment I want it to have the check marked.
Here I attach an image.
Here I attach the codes that I have tried to use, but that has not worked.
These are the 3 commands I used, but it doesn't work.
1.- code
[PXDBBool()]
[PXDefault(true, PersistingCheck = PXPersistingCheck.Nothing)]
[PXUIField(DisplayName = "Default")]
protected virtual void PMTask_IsDefault_CacheAttached(PXCache cache)
{
}
2.- code
protected virtual void _(Events.FieldDefaulting<PMTask, PMTask.isDefault> e)
{
if (e.Row!=null)
{
/*defaul check, It doesn't work*/
e.Cache.SetValue<PMTask.isDefault>(e.Row, true);
}
}
3.- code
protected virtual void _(Events.FieldUpdated<PMProject, PMProject.templateID> e)
{
if (e.Row!=null)
{
/*defaul check, It doesn't work*/
var pmtask = Base.Tasks.Current;
pmtask.IsDefault = true;
}
}
Let me know what I'm doing wrong or maybe I'm doing something I shouldn't, thanks everyone.
Try using the below event handler. It will set the checkbox to true if the Template ID is set to a value and to false if the Template ID is cleaned.
protected virtual void _(Events.FieldUpdated<PMProject, PMProject.templateID> e)
{
if (e.Row is PMProject row)
{
e.Cache.SetValue<PMTask.isDefault>(e.Row, row.TemplateID!=null);
}
}

Enable UDF in Transfer screen (IN304000) on release Status

I am trying to enable an UDF in transfer screen on release status, but the UDF is not getting enabled.
May anyone help me on this issue. I have debugged the code as well, while debugging, the code is getting executed but the result is not taking any effect on the screen. I can see the cursor blinking on that field as well. Thanks in advance. Following is my Code :
namespace PX.Objects.IN
{
public class INTransferEntry_Extension : PXGraphExtension<INTransferEntry>
{
#region Event Handlers
protected void INRegister_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
if (e.Row == null)
{
return;
}
bool shouldDisable = ((INRegister)e.Row).Hold == false && ((INRegister)e.Row).Released == true;
if (shouldDisable)
{
PXUIFieldAttribute.SetEnabled<INRegisterExt.usrExpReturnDate>(cache, e.Row, true);
}
}
#endregion
}
}
DAC FIELD
namespace PX.Objects.IN
{
public class INRegisterExt : PXCacheExtension<PX.Objects.IN.INRegister>
{
#region UsrExpReturnDate
[PXDBDate]
[PXUIField(DisplayName="Expected Return Date")]
public virtual DateTime? UsrExpReturnDate { get; set; }
public abstract class usrExpReturnDate : PX.Data.BQL.BqlDateTime.Field<usrExpReturnDate> { }
#endregion
}
}
The document is in released status. There are mechanisms to prevent field editing when a document is in a closed state. It is not recommended to enable fields in this situation.
To enable the fields you need to revert the mechanism blocking editing. It is often the AllowUpdate property of the data view that is used to do so but it can also be automation steps or the workflow system.
When re-enabling AllowUpdate, you need to disable and re-enable the fields:
Base.transfer.AllowUpdate = true;
PXUIFieldAttribute.SetEnabled(sender, e.Row, false);
PXUIFieldAttribute.SetEnabled<INRegisterExt.usrExpReturnDate>(cache, e.Row, true);

ControlName does not work for idential Wincontrols in codedui

I have this issue with some Win controls. There is a Date DropDowns that I want to access, however both start and end Date identical (todays date), so replay goes to first one -start Date- everytime, both for Start Date and End Date comboboxes.
My question is related to this old post and I see issue in this post still not fixed / answered
CodedUI : PropertyNames.ControlName doesn't work
When I spy over comboboxes I see ControlNames are unique so I tried to use control names for the controls , through UIMap.uitest I added ControlName to SearchProperties collection and write the values however now it can not find.
public WinControl UIItem17Ocak2019PerşemDropDown
{
get
{
if ((this.mUIItem17Ocak2019PerşemDropDown == null))
{
this.mUIItem17Ocak2019PerşemDropDown = new WinControl(this);
#region Search Criteria
this.mUIItem17Ocak2019PerşemDropDown.SearchProperties[UITestControl.PropertyNames.ControlType] = "DropDown";
this.mUIItem17Ocak2019PerşemDropDown.SearchProperties[UITestControl.PropertyNames.Name] = "17 Ocak 2019 Perşembe";
this.mUIItem17Ocak2019PerşemDropDown.SearchProperties["ControlName"] = "bBasT";
this.mUIItem17Ocak2019PerşemDropDown.WindowTitles.Add("Filtre");
#endregion
}
return this.mUIItem17Ocak2019PerşemDropDown;
}
}
here is exception I am getting
Message: Test method
CodedUITestProject2.KayitTablolari_HurdaListesi.HurdaListesiTabloKontrol threw exception: Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException: The playback failed to find the control with the given search properties. Additional Details: TechnologyName: 'MSAA'ControlType: 'DropDown' Name: '17 Ocak 2019 Perşembe' ControlName: 'bBasT' ---System.Runtime.InteropServices.COMException: Bir COM bileşenine yapılan çağrıdan HRESULT E_FAIL hatası döndürüldü.
Or is there a way for order of controls in the window? such as "not click first but click second combobox in the window."
I found a solution, as described in below page, controlName is not for individual controls but for windowed controls, such as WinWindow.
https://blogs.msdn.microsoft.com/vstsqualitytools/2010/01/15/understanding-the-window-search-and-windowed-properties/
Following on Rasim Avci's anwser, below code illustrates generated code from a UIMap. The program under test was a windows Forms project containing a Form with a ComboBox on it.
[GeneratedCode("Coded UITest Builder", "15.0.26208.0")]
public class UIForm1Window : WinWindow
{
public UIForm1Window()
{
#region Search Criteria
this.SearchProperties[WinWindow.PropertyNames.Name] = "Form1";
this.SearchProperties.Add(new PropertyExpression(WinWindow.PropertyNames.ClassName, "WindowsForms10.Window", PropertyExpressionOperator.Contains));
this.WindowTitles.Add("Form1");
#endregion
}
#region Properties
public UICbStartDateWindow UICbStartDateWindow
{
get
{
if ((this.mUICbStartDateWindow == null))
{
this.mUICbStartDateWindow = new UICbStartDateWindow(this);
}
return this.mUICbStartDateWindow;
}
}
public UICbEndDateWindow UICbEndDateWindow
{
get
{
if ((this.mUICbEndDateWindow == null))
{
this.mUICbEndDateWindow = new UICbEndDateWindow(this);
}
return this.mUICbEndDateWindow;
}
}
#endregion
#region Fields
private UICbStartDateWindow mUICbStartDateWindow;
private UICbEndDateWindow mUICbEndDateWindow;
#endregion
}
[GeneratedCode("Coded UITest Builder", "15.0.26208.0")]
public class UICbStartDateWindow : WinWindow
{
public UICbStartDateWindow(UITestControl searchLimitContainer) :
base(searchLimitContainer)
{
#region Search Criteria
this.SearchProperties[WinWindow.PropertyNames.ControlName] = "cbStartDate";
this.WindowTitles.Add("Form1");
#endregion
}
#region Properties
public WinComboBox UICbStartDateComboBox
{
get
{
if ((this.mUICbStartDateComboBox == null))
{
this.mUICbStartDateComboBox = new WinComboBox(this);
#region Search Criteria
this.mUICbStartDateComboBox.SearchProperties[WinComboBox.PropertyNames.Name] = "cbStartDate";
this.mUICbStartDateComboBox.WindowTitles.Add("Form1");
#endregion
}
return this.mUICbStartDateComboBox;
}
}
#endregion
#region Fields
private WinComboBox mUICbStartDateComboBox;
#endregion
}
In bellow image, the control hierarchy is illustrated. It clearly shows the UICbStartDateWindow as parent for the ComboBox.
As you can see, the generated code should follow what is described in the link from Rasim Avci's answer.

Acumatica Extension on SOSitesStatusSelected

I've been having this problem on Acumatica extension for days now and can't seem to figure out the resolution. I've added an action on the Inventory Lookup Dialog of Sales Order screen (see screenshot below), the action is task to update the QtySelected to 1 and also to update my added Field which is the Brand to "testBrand". It is an extension of the SOSitesStatusSelected table, but whenever i clicked on the action, it only updates QtySelected and not my added Field Brand.
You may refer to my code below, thank you and I appreciate all the help.
//DAC
#region UsrBrand
[PXUIField(DisplayName = "Brand", Visible = true, Enabled = true)]
public virtual string UsrBrand{get;set;}
public abstract class usrBrand : IBqlField{}
#endregion
//BLC
public PXAction<PX.Objects.SO.SOOrder> updateAttributes;
[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "Update Attributes")]
protected void UpdateAttributes()
{
this.Base.sitestatus.AllowInsert= true;
this.Base.sitestatus.AllowUpdate= true;
foreach (SOSiteStatusSelected line in this.Base.sitestatus.Select())
{
line.QtySelected = 1;
this.Base.sitestatus.Update(line);
SOSiteStatusSelectedExt rowExt = this.Base.sitestatus.Cache.GetExtension<SOSiteStatusSelectedExt>(line);
rowExt.UsrBrand = "testBrand";
this.Base.sitestatus.Cache.Update(rowExt);
}
}
In this case your extension SOSiteStatusSelectedExt is not a separate item. It's a part of the base record actually. So you don't need to update it separately.
line.QtySelected = 1;
SOSiteStatusSelectedExt rowExt = this.Base.sitestatus.Cache.GetExtension<SOSiteStatusSelectedExt>(line);
rowExt.UsrBrand = "testBrand";
this.Base.sitestatus.Update(line);

Print button on CR306000 to print case data

I have a custom button on CR306000 to try to print current loaded case information by calling one customized report. Navigation URL current set to:
~/Frames/ReportLauncher.aspx?ID=Inquirycase.rpx&CASEID=####
I will need to have custom programming to assign current case ID to replace "####", but don't know where and how to reference that custom button and modify its property. Please help. Thanks.
You could add a report parameter called 'CaseID' to your report and call it using the following code using an AEF extension like this:
public class CRCaseMaintExtension : PXGraphExtension<CRCaseMaint>
{
public override void Initialize()
{
base.Initialize();
//if adding to an existing menu button do that here...
// Example:
//Base.Inquiry.AddMenuAction(this.CustomReportButton);
}
public PXAction<CRCase> CustomReportButton;
[PXButton]
[PXUIField(DisplayName = "Custom Report", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
public virtual IEnumerable customReportButton(PXAdapter adapter)
{
if (Base.Case.Current != null)
{
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters["CaseID"] = Base.Case.Current.CaseID.ToString();
//enter in your report id/number here
string reportNumber = "Inquirycase";
//opens the report using the defined parameters
throw new PXReportRequiredException(parameters, reportNumber, "Custom Report");
}
return adapter.Get();
}
}
I have not tested the above but this should get you most of the way there.

Resources