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)??
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)??
Best answer by Leonardo Justiniano
Hi
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.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.