Solved

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

  • 22 February 2023
  • 6 replies
  • 124 views

Userlevel 3
Badge +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

icon

Best answer by Leonardo Justiniano 23 February 2023, 16:53

View original

6 replies

Userlevel 7
Badge +8

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

 

Userlevel 6
Badge +4

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.

 

 

Userlevel 3
Badge +1

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

Userlevel 3
Badge +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

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

Userlevel 6
Badge +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.

Userlevel 3
Badge +1

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


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