0

Is it possible to bypass a required look up filter criteria through apex? For example for a certain scenario it will not throw the filter criteria but it's still there. Been searching the internet regarding this one, but can't seem to get a clear answer.

For example

My Filter criteria is like this.

(Distributor: Account Record TypeEQUALSPartner) AND
(Distributor: Account IDNOT EQUAL TOOpportunity: Primary Partner ID) AND
(Distributor: Partner TypeEQUALSDistributor)

Now there is a scenario where in it's allright to have the Distributor : Parner type = null or blank. and it's only applicable for that scenario so addin the null value in the filter criteria is a no no.

If it's not possible to by pass using apex code. Can you give me any idea or workaround regarding this one?

My Code somewhat look like this.

Protected List<Opportunity> allOpportunites;
public void createRenewalOpps(){
//add renewalOpps Values
allOpportunities.addAll(renewalOpps.values)
}

public void ManageOpportunities(){
//the filter look up criteria is in the Opportunity object
//error will be thrown in the DML call since in my data the distributor : 
//partner type is blank


upsert allOpportunities; //Error will be thrown
}
4

The most basic solution is to add a "bypass validation" checkbox to your record that no users have access to, which your code can can set to true when the validation rule should be bypassed. Your filter then becomes

Distributor: Bypass Filter OR
(
    (Distributor: Account Record TypeEQUALSPartner) AND
    (Distributor: Account IDNOT EQUAL TOOpportunity: Primary Partner ID) AND
    (Distributor: Partner TypeEQUALSDistributor)
)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.