Skip to main content
Solved

How to remove dependency of probability in Opportunities screen ?


param2022
Jr Varsity II
Forum|alt.badge.img

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

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

6 replies

param2022
Jr Varsity II
Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 94 replies
  • May 27, 2022

Can anyone please provide any solution here ???


Leonardo Justiniano
Jr Varsity I
Forum|alt.badge.img+5

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

 


param2022
Jr Varsity II
Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 94 replies
  • May 30, 2022

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


Leonardo Justiniano
Jr Varsity I
Forum|alt.badge.img+5

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;

...
}

 

 


param2022
Jr Varsity II
Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 94 replies
  • May 31, 2022

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


Leonardo Justiniano
Jr Varsity I
Forum|alt.badge.img+5

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


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