Skip to main content

I have created an action in a custom screen graph which is responsible for setting some field values base on few complex conditions. These conditions are based on DACs except the main DAC of the screen. Since it does few DB updates can’t use the Row Selected event also. is there any way to call that method just after initialization of the screen?

Note: Topic Should corrected as “How to call an action just after initialization of a custom Screen”

Hi @PDharmasena10 

 

You could use the RowInserted handler, which is called when the record is inserted into the database.

You can repeat these for the DACs that you need to update.

 

Alternatively, if the record is made from an action, you can make use the action to update the values within all the DACs as long as you have them declared as views.

 

Hope this helps,

Aleks


Hi @aiwan 

As I think Row Inserted fires only when new row is inserted. isn’t it? But my requirement is to triggers the action when just after page loads and when page is refreshed.


Yes that’s true, @PDharmasena10 

 

I think I misunderstood your question.

 

If you create a method to update the fields as you need, you should be able to call it in the RowSelected handler; I think using YourGraph.YourView.Update(); in your method will be beneficial, because you cannot create a graph instance within a event handler so just be aware of that.


Hey @PDharmasena10 !

I don’t know the structure of your custom screen, but you might want to try creating a custom method and calling it inside a data view delegate.
Note that this would call your custom method every time the data view query is executed, so depending on your requirements, you may need to have logic in your custom method to conditionally run the needed updates.

        #region Data Views
public SelectFrom<HeaderRecord>.View Header;

public SelectFrom<DetailRecord>.Where<DetailRecord.documentID.IsEqual<HeaderRecord.documentID.FromCurrent.Value>>.View Details;
#endregion



#region Data View Delegates
//This delegate method will be called when the 'Details' view query is executed, instead of the 'Details' query itself.
//The original data from the Details query will be returned unchanged, but your custom method will also be called.
public IEnumerable details()
{
PXView select = new PXView(this, false, Details.View.BqlSelect);
Int32 totalrow = 0;
Int32 startrow = PXView.StartRow;

List<object> result = select.Select(PXView.Currents, PXView.Parameters, PXView.Searches,
PXView.SortColumns, PXView.Descendings, PXView.Filters, ref startrow, PXView.MaximumRows, ref totalrow);
PXView.StartRow = 0;

//Your custom method
SomeCustomMethodHere();

return result;
}

#endregion

#region Logic

protected void SomeCustomMethodHere()
{
//Custom logic to do whatever
}
#endregion

 

Hope this is helpful!


Note that this would call your custom method every time the data view query is executed, so depending on your requirements, you may need to have logic in your custom method to conditionally run the needed updates.

Theoretically, you could add a dummy data view with a data view delegate that may reduce the complexity.


Reply