Question

The Project Field Does not retain the selected value

  • 9 July 2023
  • 9 replies
  • 86 views

Userlevel 7
Badge +9

Hello All,

I am adding a restrictor to ProjectID as follows:

[PXRestrictor(
typeof(Where<PMProject.defaultBranchID.IsInSubselect<SelectFrom<PX.SM.UserPreferences>
.Where<PX.SM.UserPreferences.userID.IsEqual<AccessInfo.userID.FromCurrent>>
.SearchFor<PX.SM.UserPreferences.defBranchID>>>),
"Invalid Project")]

The Selector works fine and shows the desired list but when I select a project from the list which is valid, the field does not hold the value and it clears it out. I checked the SQL query for the Selector and it is fine as well and returns the desired ResultSet. Any idea what is happening on the interface? 


9 replies

Userlevel 6
Badge +3

I think the problem is in your SearchFor:

SearchFor<PX.SM.UserPreferences.defBranchID>

Shouldn’t it be something like this instead?

SearchFor<PX.PM.PMProject.projectID>

 

Userlevel 7
Badge +9

No, it is correct, it searches “PMProject.defaultBranchID” in “PX.SM.UserPreferences.defBranchID” 

Userlevel 6
Badge +3

I tried to add your Restrictor to ProjectID on Sales Order Entry. It worked the same way you described, but I got some trace errors:

 

Userlevel 7
Badge +9

@zfebert56 

im not getting errors but it doesn’t retain the selected value. I am guessing it is because Acumatica doesn’t apply IsNull on Searched value but I’m not sure how it can be addressed. As a workaround for now I have written a custom selector class but it is redundant and I don’t like it.

Userlevel 6
Badge +3

@aaghaei 

I tried to add an unbound field to PMProject and default it to user’s default branch, but I got an Incorrect syntax near ')'. SQL error when I opened the selector, so that didn’t work either.

Userlevel 7
Badge +17

Hi @aaghaei  As per your DAC properties, I think it might be an issue with the .aspx control. 

It might be an PXSegmentedMask, you can change it to PXSelector. It should work.

 

If you still wanted to use the PXSegmentedMask at .aspx page, then you need to change the DAC properties. 

Userlevel 7
Badge +9

Hi @Naveen Boga Thank you for the insight. Yes, ProjectID is a SegmentMask and I will need to keep it that way. So I guess I do not have much of options but to keep the Custom “PXDimensionSelectorAttribute” that I had to write even though it is mostly redundant.

Userlevel 7
Badge +17

@aaghaei  I think it should work with PXDimensionSelectorAttribute as well.

Can you please share the DAC field along with PXRestrictor here?

Userlevel 7
Badge +9

Sure @Naveen Boga 

Here is the ProjectID properties from the original DAC 

namespace PX.Objects.FS
{
[Serializable]
[PXCacheName(TX.TableName.APPOINTMENT)]
[PXPrimaryGraph(typeof(AppointmentEntry))]
[PXGroupMask(typeof(InnerJoinSingleTable<Customer, On<Customer.bAccountID, Equal<FSAppointment.customerID>, And<Match<Customer, Current<AccessInfo.userName>>>>>))]
public partial class FSAppointment : PX.Data.IBqlTable
{
// some other fields

#region ProjectID
public abstract class projectID : PX.Data.BQL.BqlInt.Field<projectID> { }

[ProjectDefault]
[PXUIEnabled(typeof(Where<Current<FSServiceOrder.sOID>, Less<Zero>,
And<Current<FSServiceContract.billingType>,
NotEqual<FSServiceContract.billingType.Values.standardizedBillings>>>))]
[ProjectBase(typeof(FSServiceOrder.billCustomerID))]
[PXRestrictor(typeof(Where<PMProject.isActive, Equal<True>>), PM.Messages.InactiveContract, typeof(PMProject.contractCD))]
[PXRestrictor(typeof(Where<PMProject.isCancelled, Equal<False>>), PM.Messages.CancelledContract, typeof(PMProject.contractCD))]
[PXForeignReference(typeof(FK.Project))]
public virtual int? ProjectID { get; set; }
#endregion

// some other fields
}
}

and here is part of my graph ext related to this issue

namespace Test
{
public class TestAppointmentEntryExt : PXGraphExtension<AppointmentEntryWorkflow, AppointmentEntryVisibilityRestriction, AppointmentEntry>
{
public static bool IsActive() => true;

#region FSAppointment CacheAttached ProjectID
[PXMergeAttributes(Method = MergeMethod.Append)]
[PXRemoveBaseAttribute(typeof(ProjectDefaultAttribute))]
[PXDefault(PersistingCheck = PXPersistingCheck.Null)]
[PXRestrictor(typeof(Where<PMProject.nonProject.IsNotEqual<True>>), "Invalid Project")]
[PXCustomizeBaseAttribute(typeof(PXDefaultAttribute), nameof(PXDefaultAttribute.SearchOnDefault), false)]
[PXRestrictor(
typeof(Where<PMProject.defaultBranchID.IsInSubselect<SelectFrom<PX.SM.UserPreferences>
.Where<PX.SM.UserPreferences.userID.IsEqual<AccessInfo.userID.FromCurrent>>
.SearchFor<PX.SM.UserPreferences.defBranchID>>>),
"Invalid Project")]
protected void _(Events.CacheAttached<FSAppointment.projectID> e) { }
#endregion
}
}

 

in addition to the “AppointmentEntry” I need Base1 and Base2 in the GraphExt that is why they are included in the Ext.

I have not made any changes to the Appointments Screen for ProjectID in the form header.

 

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved