0

Specified cast is not valid

Unable to cast object

I'm trying to override the "NoteID", base screen Header table field(Location<==Table). After override the NoteID field I got the above two error's.

(Newly I added the activities tab in "Customer Location" screen. Initially it was like this when I click on the add task button):

"Related Entity" field is in blank (It should come after we click on the "Add task" button

Like this screen "Related Entity" should come with fill after we click on the "Add task" button

I tried two ways to override the NoteID field (This is the first one):

[PXNonInstantiatedExtension]
public class CR_Location_ExistingColumn : PXCacheExtension<PX.Objects.CR.Location>
{
    #region NoteID  
    //public abstract class noteID : PX.Data.BQL.BqlGuid.Field<noteID>
    //{ }

    [PXMergeAttributes(Method = MergeMethod.Append)]
    [PXSearchable(
         PX.Objects.SM.SearchCategory.All,
          "{0}: {1} -{2}",
         new Type[]
         {
             typeof(Location.locationID),
            typeof(Location.locationCD),
            typeof(Location.descr)
         },
        new Type[]
         {
            typeof(Location.isActive),
            typeof(Location.locationCD),
            typeof(Location.descr),
         },
         NumberFields = new Type[] { typeof(Location.locationCD) },

         Line1Format = "{0}{1}{2:d}",
         Line1Fields = new Type[]{typeof(Location.locationCD),
            typeof(Location.descr),
           typeof(Location.isActive) },
             Line2Format = "{0}",
         Line2Fields = new Type[]{typeof(Location.locationCD)
         })]
    [PXNote(DescriptionField = typeof(Location.locationCD),
          Selector = typeof(Location.locationCD),
          ShowInReferenceSelector = true, BqlField = typeof(Location.noteID))]

    public Guid? NoteID { get; set; }
    #endregion
}

And this is the 2nd try:

    #region Location_NoteID

    public abstract class noteID : PX.Data.BQL.BqlGuid.Field<noteID> { }
    [PXSearchable(
         PX.Objects.SM.SearchCategory.All,
          "{0}: {1} -{2}",
         new Type[]
         {
             typeof(Location.locationID),
            typeof(Location.locationCD),
            typeof(Location.descr)
         },
        new Type[]
         {
            typeof(Location.isActive),
            typeof(Location.locationCD),
            typeof(Location.descr),
         },
         NumberFields = new Type[] { typeof(Location.locationCD) },

         Line1Format = "{0}{1}{2:d}",
         Line1Fields = new Type[]{typeof(Location.locationCD),
            typeof(Location.descr),
           typeof(Location.isActive) },
             Line2Format = "{0}",
         Line2Fields = new Type[]{typeof(Location.locationCD)
         })]
    [PXNote(DescriptionField = typeof(Location.locationCD),
          Selector = typeof(Location.locationCD),
          ShowInReferenceSelector = true, BqlField = typeof(Location.noteID))]
    [PXFormula(typeof(Default<Location.noteID>))]
    [PXMergeAttributes(Method = MergeMethod.Merge)]
    public virtual void Location_NoteID_CacheAttached(PXCache sender)
    {
    }

    #endregion

I'm new to the Acumatica coding environment. Where is the mistake and how to overcome this issue?

James Z
  • 12,209
  • 10
  • 24
  • 44
Ashok
  • 13
  • 6

1 Answers1

0

I have checked this and working for me. I hope the below code will help you.

   public class CustomerLocationMaintExt : PXGraphExtension<CustomerLocationMaint>
{
    #region Location_NoteID

    public abstract class noteID : PX.Data.BQL.BqlGuid.Field<noteID> { }
    [PXSearchable(
         PX.Objects.SM.SearchCategory.All,
          "{0}: {1} -{2}",
         new Type[]
         {
         typeof(Location.locationID),
        typeof(Location.locationCD),
        typeof(Location.descr)
         },
        new Type[]
         {
        typeof(Location.isActive),
        typeof(Location.locationCD),
        typeof(Location.descr),
         },
         NumberFields = new Type[] { typeof(Location.locationCD) },

         Line1Format = "{0}{1}{2:d}",
         Line1Fields = new Type[]{typeof(Location.locationCD),
        typeof(Location.descr),
       typeof(Location.isActive) },
             Line2Format = "{0}",
         Line2Fields = new Type[]{typeof(Location.locationCD)
         })]
    [PXNote(DescriptionField = typeof(Location.locationCD),
          Selector = typeof(Location.locationCD),
          ShowInReferenceSelector = true, BqlField = typeof(Location.noteID))]
    [PXFormula(typeof(Default<Location.noteID>))]
    [PXMergeAttributes(Method = MergeMethod.Append)]
    public virtual void Location_NoteID_CacheAttached(PXCache sender)
    {
    }

    #endregion
   
}

enter image description here

Naveen B
  • 55
  • 4
  • Hi Naveen, I have checked twice this code but when I click on the "Add Task" button still it is showing the black value in "Related Entities" field. In my scenario this code is not working properly. Can you plz suggest me how to override this code like " adding commit changes or modifying the code ??. – Ashok Sep 26 '20 at 12:14
  • Hi Ashok, In which screen you trying to create the task? Can you please provide us the more details on this issue – Naveen B Sep 26 '20 at 15:10
  • Hi Naveen, Actually I newly created the Activities tab in Customer Location(AR303020) screen and I'm adding the task using addtask button in that (AR303020) screen but it is showing the blank at that "Related Entity" field(You can see in the above img example). – Ashok Sep 28 '20 at 05:57
  • and I override this field's also: [PXCacheName(Messages.Location)] [PXFieldDescription] [PXMergeAttributes(Method = MergeMethod.Append)] public virtual void Location_BAccountID_CacheAttached(PXCache sender) { } [PXCacheName(Messages.Location)] [PXFieldDescription] [PXMergeAttributes(Method = MergeMethod.Append)] public virtual void Location_LocationCD_CacheAttached(PXCache sender) { } – Ashok Sep 28 '20 at 06:00
  • Hi Ashok, Can you please share the ADD TASK button code? – Naveen B Sep 28 '20 at 06:26