Skip to main content
Question

The Project Field Does not retain the selected value

  • July 9, 2023
  • 9 replies
  • 115 views

aaghaei
Captain II
Forum|alt.badge.img+10

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

Zoltan Febert
Jr Varsity I
Forum|alt.badge.img+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>

 


aaghaei
Captain II
Forum|alt.badge.img+10
  • Author
  • Captain II
  • July 11, 2023

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


Zoltan Febert
Jr Varsity I
Forum|alt.badge.img+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:

 


aaghaei
Captain II
Forum|alt.badge.img+10
  • Author
  • Captain II
  • July 11, 2023

@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.


Zoltan Febert
Jr Varsity I
Forum|alt.badge.img+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.


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • July 12, 2023

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. 


aaghaei
Captain II
Forum|alt.badge.img+10
  • Author
  • Captain II
  • July 12, 2023

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.


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • July 12, 2023

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

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


aaghaei
Captain II
Forum|alt.badge.img+10
  • Author
  • Captain II
  • July 12, 2023

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.