Skip to main content
Solved

'AllowEdit = True' but getting 'Specified Cast is not Valid' error in trace

  • November 19, 2024
  • 9 replies
  • 83 views

Forum|alt.badge.img+8
  • Captain II
  • 362 replies

Hi Guys,

 

Im having a little issue with redirections.

I receive these errors:

After I attempt redirection from here:

The ‘Press and Glue Log’ works fine…

My DAC key fields:

 #region DocNbr
public abstract class docNbr : BqlString.Field<docNbr> { }
[PXDBString(15, IsKey = true, IsUnicode = true)]
[AutoNumber(typeof(ISOSetup.autoNumberingQC),
    typeof(GCQCRecord.date))]
[PXSelector(typeof(GCQCRecord.docNbr),
    typeof(GCQCRecord.batchNbr),
    typeof(GCQCRecord.date),
    typeof(GCQCRecord.sOOrderNbr),
    typeof(GCQCRecord.status),
     ValidateValue = false)]
[PXUIField(DisplayName = "Doc Nbr", Enabled = false)]
public virtual string DocNbr
{
    get;
    set;
}
#endregion


#region BatchNbr
public abstract class batchNbr : BqlString.Field<batchNbr> { }
[PXDBString(15, IsKey = true, IsUnicode = true)]
[PXSelector(typeof(AMBatch.batNbr),
    typeof(AMBatch.docType))]
[PXRestrictor(typeof(Where<AMBatch.docType.IsEqual<Messages.move>>), Messages.MoveNotFound, typeof(AMBatch.docType))]
[PXUIField(DisplayName = "Batch Nbr")]
public virtual string BatchNbr
{
    get;
    set;
}
#endregion

 #region Date
 public abstract class date : BqlDateTime.Field<date> { }
 [PXDBDate(IsKey = true, UseSmallDateTime = true)]
 [PXDefault(typeof(AccessInfo.businessDate), PersistingCheck = PXPersistingCheck.Nothing)]
 [PXUIField(DisplayName = "Date")]
 public virtual DateTime? Date
 {
     get;
     set;
 }
 #endregion

My DB:

Has this happened to anyone/does anyone know how to fix this?

 

Aleks

Best answer by darylbowman

aiwan wrote:

Unfortunately, this just gave me an object reference not set to an instance of an object error.

What did? I’m 99% sure that’s why you’re getting the errors in your trace.

 

aiwan wrote:

...I know there is a way to link an action to a field, do you know what article talks about this?

https://stackoverflow.com/a/34190669/3718361

View original
Did this topic help you find an answer to your question?

9 replies

darylbowman
Captain II
Forum|alt.badge.img+13

Your DAC specifies the Date field as a nullable object (DateTime?, [which is correct]) but your data table specifies ‘not null’


Forum|alt.badge.img+8
  • Author
  • Captain II
  • 362 replies
  • November 19, 2024

Thanks ​@darylbowman 

 

Unfortunately, this just gave me an object reference not set to an instance of an object error.

 

I already have this as a customisation live, I know there is a way to link an action to a field, do you know what article talks about this?

 

Aleks

 


darylbowman
Captain II
Forum|alt.badge.img+13
  • 1683 replies
  • Answer
  • November 19, 2024
aiwan wrote:

Unfortunately, this just gave me an object reference not set to an instance of an object error.

What did? I’m 99% sure that’s why you’re getting the errors in your trace.

 

aiwan wrote:

...I know there is a way to link an action to a field, do you know what article talks about this?

https://stackoverflow.com/a/34190669/3718361


Forum|alt.badge.img+8
  • Author
  • Captain II
  • 362 replies
  • November 19, 2024

Forgot to mention, the object type must be DateTime error still occurs.


Forum|alt.badge.img+8
  • Author
  • Captain II
  • 362 replies
  • November 19, 2024

Changing from DateTime? to DateTime DAC declaration.

 

Thank you!


darylbowman
Captain II
Forum|alt.badge.img+13

I would change the SQL field to be nullable instead:

ALTER TABLE GCQCRecord ALTER COLUMN Date datetime2 null

 

Make sure to reload your customization script so it doesn’t erase your table next time you publish.


Forum|alt.badge.img+8
  • Author
  • Captain II
  • 362 replies
  • November 19, 2024

I was about to say i tried that but i tried changing the data type to datetime instead of datetime2 which is what it currently is.

 

I’ll try changing it to null and removing it from the PK.


Forum|alt.badge.img+8
  • Author
  • Captain II
  • 362 replies
  • November 19, 2024

And sorry if i wasnt clear enough, this issue isn’t happening on a live environment, only on my local while i have been testing the addition of those panels to the move screen.


Forum|alt.badge.img+8
  • Author
  • Captain II
  • 362 replies
  • November 20, 2024

I resorted to using the stack overflow post you shared ​@darylbowman and adding the link command to the field.

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings