Skip to main content

In this form the text field of Probability(green) is dependent on the StageId(blue) is there a way I can remove this dependency and use my new custom field of Probability(yellow) to update the probability text field(green)??

 

 

Can anyone please provide any solution here ???


Hi @param2022 

Please override the following view in OpportunityMaint graph

public PXSelect<CROpportunityProbability,
Where<CROpportunityProbability.stageCode,
Equal<Current<CROpportunity.stageID>>>>
ProbabilityCurrent;

As you can see Probability field belongs to CROpportunityProbability

 


@Leonardo Justiniano thanks for suggesting this way can you tell me how can we override a view ? Or a reference to official documentation please ??


Hi @param2022 

 

You just need to define your new view with the same name in the graph extension like:

 

// Assuming you have a CROpportunityExt.UsrMyProbability
//
public class OpportunityMaint_Extension : PXGraphExtension<OpportunityMaint>
{
...

public PXSelect<CROpportunityProbability,
Where<CROpportunityProbability.stageCode,
Equal<Current<CROpportunityExt.UsrMyProbability>>>>
ProbabilityCurrent;

...
}

 

 


@Leonardo Justiniano I have tried what you suggested but it is still not working. The CROpportunityProbability probability(green one) is still updating with on change of stage field. I have tried overriding fieldUpdated for stage event also but that is also not working.


Hi @param2022 

You need also to refresh the view when changing the value. To accomplish that set CommitChanges to True on the field “UsrMyProbability”

 

This is the snippet:

namespace PX.Objects.CR
{

// Acuminator disable once PX1016 ExtensionDoesNotDeclareIsActiveMethod extension should be constantly active
public sealed class CROpportunityExt : PXCacheExtension<CROpportunity>
{
#region UsrMyProbability
PXDBString(15)]
PXUIField(DisplayName = "My Probability")]
PXStringList(new string ] { "A","L","N","P","Q","R","V","W"}, new string ] { "60", "0", "5", "10", "20", "80", "40", "100" })]
public string UsrMyProbability { get; set; }
public abstract class usrMyProbability : PX.Data.BQL.BqlString.Field<usrMyProbability> { }
#endregion
}

// Acuminator disable once PX1016 ExtensionDoesNotDeclareIsActiveMethod extension should be constantly active
public class OpportunityMaint_Extension : PXGraphExtension<OpportunityMaint>
{

public PXSelect<CROpportunityProbability,
Where<CROpportunityProbability.stageCode,
Equal<Current<CROpportunityExt.usrMyProbability>>>>
ProbabilityCurrent;

protected void _(Events.FieldUpdated<CROpportunityExt.usrMyProbability> e)
{
ProbabilityCurrent.View.RequestRefresh();
}

}
}

A FieldUpdated event must be created to refresh the view.

 

To remove the link with Stage field is more complicated. There are a lot of logic behind it ( Look at CROpportunityStages attribute implementation). I suggest a different approach trying to adapt Stage field instead.


Reply