Skip to main content
Solved

show only the records that i want to insert in database not all the records

  • February 22, 2023
  • 6 replies
  • 167 views

abdallaahmed61
Varsity III
Forum|alt.badge.img+1

Hello,

I made a screen that i can insert from it in database but it shows all the records from the table

how can i make the screen show only the records that im inserting to the DB

Best answer by Leonardo Justiniano

Hi @abdallaahmed61 

 

Yes it will show all the previous inserted records. I would prefer to see them, so you know the data was saved properly.

You can filter them out by only returning the inserted ones from the cache through the view delegate. Something like:

 

protected virtual IEnumerable yourView() // <- Notice that first character is lower case
{
    return YourView.Cache.Inserted;
}

 

You might need to test how the cache behaves after you save the data.

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

6 replies

aaghaei
Captain II
Forum|alt.badge.img+10
  • Captain II
  • 1203 replies
  • February 22, 2023

@abdallaahmed61 

what are you saying doesn’t Make much sense. Can you please advise how you are instructing the platform to show only newly inserted records in Cache and not the Persisted data from DB that doesn’t work? It seems you are new to Acumatica. If you like share your Customization Package and C# project code here plus a little bit more clarification about what are you trying to do that people can help.

 


Leonardo Justiniano
Jr Varsity II
Forum|alt.badge.img+4
abdallaahmed61 wrote:

Hello,

I made a screen that i can insert from it in database but it shows all the records from the table

how can i make the screen show only the records that im inserting to the DB

Hi @abdallaahmed61 

Your requirement sounds like a customized view for that screen (Let’s assume that for the following example). You can accomplish that effect of ownership of the record by filtering the view using your current user. You have to have the standard Acumatica columns for any DAC. I recommend to add them all to your DAC:

// -- Acumatica --

		#region Tstamp
		[PXDBTimestamp()]
        [PXUIField(DisplayName = "Tstamp")]
        public virtual byte[] Tstamp { get; set; }
        public abstract class tstamp : PX.Data.BQL.BqlByteArray.Field<tstamp> { }
        #endregion

        #region CreatedByID
        [PXDBCreatedByID()]
        public virtual Guid? CreatedByID { get; set; }
        public abstract class createdByID : PX.Data.BQL.BqlGuid.Field<createdByID> { }
        #endregion

        #region CreatedByScreenID
        [PXDBCreatedByScreenID()]
        public virtual string CreatedByScreenID { get; set; }
        public abstract class createdByScreenID : PX.Data.BQL.BqlString.Field<createdByScreenID> { }
        #endregion

        #region CreatedDateTime
        [PXDBCreatedDateTime()]
        public virtual DateTime? CreatedDateTime { get; set; }
        public abstract class createdDateTime : PX.Data.BQL.BqlDateTime.Field<createdDateTime> { }
        #endregion

        #region LastModifiedByID
        [PXDBLastModifiedByID()]
        public virtual Guid? LastModifiedByID { get; set; }
        public abstract class lastModifiedByID : PX.Data.BQL.BqlGuid.Field<lastModifiedByID> { }
        #endregion

        #region LastModifiedByScreenID
        [PXDBLastModifiedByScreenID()]
        public virtual string LastModifiedByScreenID { get; set; }
        public abstract class lastModifiedByScreenID : PX.Data.BQL.BqlString.Field<lastModifiedByScreenID> { }
        #endregion

        #region LastModifiedDateTime
        [PXDBLastModifiedDateTime()]
        public virtual DateTime? LastModifiedDateTime { get; set; }
        public abstract class lastModifiedDateTime : PX.Data.BQL.BqlDateTime.Field<lastModifiedDateTime> { }
        #endregion

        #region Noteid
        [PXNote()]
        public virtual Guid? Noteid { get; set; }
        public abstract class noteid : PX.Data.BQL.BqlGuid.Field<noteid> { }
        #endregion

 

Next is, adapting your screen view for that condition:

...

using PX.Data.BQL;
using PX.Data.BQL.Fluent;

...

public class YourGraph : PXGraph<YourGraph, YourDAC>
{        
   #region Views

   public SelectFrom<YourDAC>.Where<YourDAC.createdByID.IsEqual<AccessInfo.userID.FromCurrent>>.View YourView;

   #endregion

...

}

CreatedByID is automatically filled by Acumatica as it’s a system field.

 

You can also implement projections to accomplish this.

 

Hope this can help. If this example does not make sense to you, as @aaghaei suggested, please share what are you trying to customize. We can give you a hand.

 

 


abdallaahmed61
Varsity III
Forum|alt.badge.img+1
  • Author
  • Varsity III
  • 53 replies
  • February 23, 2023
aaghaei wrote:

@abdallaahmed61

what are you saying doesn’t Make much sense. Can you please advise how you are instructing the platform to show only newly inserted records in Cache and not the Persisted data from DB that doesn’t work? It seems you are new to Acumatica. If you like share your Customization Package and C# project code here plus a little bit more clarification about what are you trying to do that people can help.

 

I have an idea about how to make this but i just wanted to ask if there is a better way.

My idea is to make 2 table, 1 fake table that dosent have data and the other table is the one which i will insert in so, the fake table will be the table which will be shown in the screen .


abdallaahmed61
Varsity III
Forum|alt.badge.img+1
  • Author
  • Varsity III
  • 53 replies
  • February 23, 2023
Leonardo Justiniano wrote:
abdallaahmed61 wrote:

Hello,

I made a screen that i can insert from it in database but it shows all the records from the table

how can i make the screen show only the records that im inserting to the DB

Hi @abdallaahmed61 

Your requirement sounds like a customized view for that screen (Let’s assume that for the following example). You can accomplish that effect of ownership of the record by filtering the view using your current user. You have to have the standard Acumatica columns for any DAC. I recommend to add them all to your DAC:

// -- Acumatica --

		#region Tstamp
		[PXDBTimestamp()]
        [PXUIField(DisplayName = "Tstamp")]
        public virtual byte[] Tstamp { get; set; }
        public abstract class tstamp : PX.Data.BQL.BqlByteArray.Field<tstamp> { }
        #endregion

        #region CreatedByID
        [PXDBCreatedByID()]
        public virtual Guid? CreatedByID { get; set; }
        public abstract class createdByID : PX.Data.BQL.BqlGuid.Field<createdByID> { }
        #endregion

        #region CreatedByScreenID
        [PXDBCreatedByScreenID()]
        public virtual string CreatedByScreenID { get; set; }
        public abstract class createdByScreenID : PX.Data.BQL.BqlString.Field<createdByScreenID> { }
        #endregion

        #region CreatedDateTime
        [PXDBCreatedDateTime()]
        public virtual DateTime? CreatedDateTime { get; set; }
        public abstract class createdDateTime : PX.Data.BQL.BqlDateTime.Field<createdDateTime> { }
        #endregion

        #region LastModifiedByID
        [PXDBLastModifiedByID()]
        public virtual Guid? LastModifiedByID { get; set; }
        public abstract class lastModifiedByID : PX.Data.BQL.BqlGuid.Field<lastModifiedByID> { }
        #endregion

        #region LastModifiedByScreenID
        [PXDBLastModifiedByScreenID()]
        public virtual string LastModifiedByScreenID { get; set; }
        public abstract class lastModifiedByScreenID : PX.Data.BQL.BqlString.Field<lastModifiedByScreenID> { }
        #endregion

        #region LastModifiedDateTime
        [PXDBLastModifiedDateTime()]
        public virtual DateTime? LastModifiedDateTime { get; set; }
        public abstract class lastModifiedDateTime : PX.Data.BQL.BqlDateTime.Field<lastModifiedDateTime> { }
        #endregion

        #region Noteid
        [PXNote()]
        public virtual Guid? Noteid { get; set; }
        public abstract class noteid : PX.Data.BQL.BqlGuid.Field<noteid> { }
        #endregion

 

Next is, adapting your screen view for that condition:

...

using PX.Data.BQL;
using PX.Data.BQL.Fluent;

...

public class YourGraph : PXGraph<YourGraph, YourDAC>
{        
   #region Views

   public SelectFrom<YourDAC>.Where<YourDAC.createdByID.IsEqual<AccessInfo.userID.FromCurrent>>.View YourView;

   #endregion

...

}

CreatedByID is automatically filled by Acumatica as it’s a system field.

 

You can also implement projections to accomplish this.

 

Hope this can help. If this example does not make sense to you, as @aaghaei suggested, please share what are you trying to customize. We can give you a hand.

 

 

using this answer will still show the user all the data he has inserted in the table it might be hundreds of data


Leonardo Justiniano
Jr Varsity II
Forum|alt.badge.img+4

Hi @abdallaahmed61 

 

Yes it will show all the previous inserted records. I would prefer to see them, so you know the data was saved properly.

You can filter them out by only returning the inserted ones from the cache through the view delegate. Something like:

 

protected virtual IEnumerable yourView() // <- Notice that first character is lower case
{
    return YourView.Cache.Inserted;
}

 

You might need to test how the cache behaves after you save the data.


abdallaahmed61
Varsity III
Forum|alt.badge.img+1
  • Author
  • Varsity III
  • 53 replies
  • February 23, 2023
Leonardo Justiniano wrote:

Hi @abdallaahmed61 

 

Yes it will show all the previous inserted records. I would prefer to see them, so you know the data was saved properly.

You can filter them out by only returning the inserted ones from the cache through the view delegate. Something like:

 

protected virtual IEnumerable yourView() // <- Notice that first character is lower case
{
    return YourView.Cache.Inserted;
}

 

You might need to test how the cache behaves after you save the data.

thnx i will try it out.

thnx alot for your time


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