Enable UDF in Transfer screen (IN304000) on release Status - acumatica

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);

Related

How to fire FieldSelecting event only in the screen?

I have a number of non persistent fields that get its value via FieldSelecting events. The events do the same queries and calculations so I decided to move them into an attribute that implements IPXFieldSelectingSubscriber interface. This works fine and it minimises duplicate codes. However, the event fires every single time the DAC is accessed. Be that in GIs or called in some other graphs. Is there such a flag to verify if the event is being fired only from a specific screen ?
The easiest way to do that would be to add the validation of which screen is accessing the DAC, you can do that by simply putting an if statement like below into your event handler.
if(graph.Accessinfo.ScreenID == "SO.30.10.00")
{
//execute the logic
}
else
{
//skip
}
An alternative solution would be to have the base field type declared on your DAC and then within a graph extension specific to the page you want the logic on, you would declare a CacheAttached event with the custom attribute.
DAC field :
public sealed class APInvoiceExtension : PXCacheExtension<APInvoice>
{
#region UsrTotal
public abstract class usrTotal : BqlDecimal.Field<usrTotal>
{
}
[PXDBDecimal]
[PXDefault(TypeCode.Decimal, "0.0", PersistingCheck = PXPersistingCheck.Nothing)]
[PXUIField(DisplayName = "Total")]
public decimal? UsrTotal { get; set; }
#endregion
}
Graph Extension :
public class APInvoiceEntryExtension : PXGraphExtension<APInvoiceEntry>
{
[PXMergeAttributes(Method = MergeMethod.Append)]
[CustomCalculationAttribute]
protected virtual void __(Events.CacheAttached<APInvoiceExtension.usrTotal> e)
{
}
}

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);
}
}

Create missing data on RowSelected

We have a graph extension that manages the tab we added to a screen. The tab displays data from our own DAC. We do not use a DAC extension, not going to go into the reasons right now.
When a user opens the main screen I want to create a record of our data if it does not exist, with some defaulting business logic.
I added a RowSelected event handler on the main DAC and it fires as I expect it to. When I add the code to create our missing record in the event handler Acuminator gives me error "PX1044 Changes to PXCache cannot be performed in event handlers."
I understand the error that Acuminator is raising, but I'm not sure where else to create our record. I cannot remember a section of the university specifically addressing this scenario.
Can anyone tell me how I would handle this scenario? And if possible, point me at the learning material that covers this scenario for broader information.
Unfortunatly there are only a few OK ways to do this and make Acuminator happy. You will risk data inconsistency.
https://github.com/Acumatica/Acuminator/blob/master/docs/diagnostics/PX1044.md
I would reccomend putting your data insertion code in Row Updated and hope the user updates something
I got a reply from Acumatica support, you can do this in a view select delegate.
Here's some example code, I haven't tested it though:
public class InventoryItemMaintExtension : PXGraphExtension<InventoryItemMaint>
{
public SelectFrom<MyCustomTable>.
Where<MyCustomTable.inventoryID.IsEqual<
InventoryItem.inventoryID.FromCurrent>>.
View AdditionalItemData;
public static bool IsActive() { return true; }
public IEnumerable additionalItemData()
{
var data = AdditionalItemData.SelectSingle();
if (data is null)
{
data = new MyCustomTable();
AdditionalItemData.Insert(data);
}
return AdditionalItemData.Select();
}
}
[PXCacheName("Additional Item Data")]
[Serializable]
public class MyCustomTable : IBqlTable
{
#region CashAccountID
[Inventory]
[PXDefault]
public virtual int? InventoryID { get; set; }
public abstract class inventoryID : PX.Data.BQL.BqlInt.Field<inventoryID> { }
#endregion
#region Required
[PXDBBool()]
[PXDefault(false)]
[PXUIField(DisplayName = "Required")]
public virtual bool? Required { get; set; }
public abstract class required : PX.Data.BQL.BqlBool.Field<required> { }
#endregion
}

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: how can i customize page IN501000 (Release IN Document)

As title, i don't know how can customize this page (processing page). I have extension with override Initialize as below
Base.INDocumentList.SetProcessDelegate(delegate(List<INRegister> list){ ReleaseDocExt(list); });
But ReleaseDocExt not run when i process item.
I was able to create an extension and override the release process. If I include this extension, system will show "Hello, World!" when trying to release any IN document from the batch processing screen:
namespace PX.Objects.IN
{
public class INDocumentRelease_Extension:PXGraphExtension<INDocumentRelease>
{
public override void Initialize()
{
Base.INDocumentList.SetProcessDelegate(delegate(List<INRegister> list){ ReleaseDocExt(list); });
}
public static void ReleaseDocExt(List<INRegister> list)
{
throw new PXException("Hello, World!!");
}
}
}
This code is not getting invoked when releasing a document from one of the inventory screens, like the Receipts (IN.30.10.00) screen. The reason is because these screens directly invoke a static method in the INDocumentRelease class, and don't create a graph to do it:
public PXAction<INRegister> release;
[PXUIField(DisplayName = Messages.Release, MapEnableRights = PXCacheRights.Update, MapViewRights = PXCacheRights.Update)]
[PXProcessButton]
public virtual IEnumerable Release(PXAdapter adapter)
{
PXCache cache = receipt.Cache;
List<INRegister> list = new List<INRegister>();
foreach (INRegister indoc in adapter.Get<INRegister>())
{
if (indoc.Hold == false && indoc.Released == false)
{
cache.Update(indoc);
list.Add(indoc);
}
}
if (list.Count == 0)
{
throw new PXException(Messages.Document_Status_Invalid);
}
Save.Press();
PXLongOperation.StartOperation(this, delegate() { INDocumentRelease.ReleaseDoc(list, false); });
return list;
}
There's therefore no opportunity for system to include your extension in this process.
If you absolutely need to customize this process, you'll also need to override the Release actions in the individual screens. This code could also be modified by Acumatica to avoid the use of static functions, and instead instantiate a INDocumentRelease instance that can be customized.
Finally, I would like to warn you about customizing the transaction release processes - make sure you know what you're doing!

Resources