Happy Business Starts Here

CustomActionPlugin not being run

Highlighted
Master

CustomActionPlugin not being run

I'm trying to get a CustomActionPlugin run every time something is updated in the product selector.  I've set the condtions to be that a calculated value of 1 is equal to 1 .

The action is then my custom action. It doesn't get called 😞 (nothing in the debug logs or rule logs)

 

BUT - if i also add a 2nd action to put up a validation method then it does work - i.e. both the message is displayed AND my plugin is called and can take actions. This feels like a bug?

7 REPLIES 7
Highlighted
Zuora Alumni

Re: CustomActionPlugin not being run

Hi @Nigel Please let me know the version of ZQuote you are on? Also is it ok to share your CustomActionPlugin code that works and that does not work? You can private message the CustomActionPlugin  and your SFDC org id , if it is ok with you

 

Thank you
Doyeli






If you found my answer helpful, please give me a kudo ↑
Help others find answers faster by accepting my post as a solution √

Highlighted
Master

Re: CustomActionPlugin not being run

<removed this as I mixed up my forum posts and put the wrong thing here>

Highlighted
Master

Re: CustomActionPlugin not being run

Ah wait - just trying it again now and it was called! so looks like I got something wrong before (but no idea what I changed!).  I'll see if it happens again.

Highlighted
Zuora Alumni

Re: CustomActionPlugin not being run

Thank you for  the update.

 

Doyeli






If you found my answer helpful, please give me a kudo ↑
Help others find answers faster by accepting my post as a solution √

Highlighted
Master

Re: CustomActionPlugin not being run

Sorry - I got utterly confused with my plugins here! I was intitially talking about a plugin for a Rule in the rules engine and not the Javascript. We're still having the same issue with the CustomActionPlugin. The code for that was as below:

 

global with sharing class NigelCustomActionPlugin implements zqu.CustomActionPlugin {
    global void perform(zqu.DataObject masterObject,
                        Map<String, Object> attributes, String[] logs) {

        // Read values from child objects.
        List<zqu.DataObject> plans = masterObject.getChildren('zqu__QuoteRatePlan__c');
        //Validate quantities match for same UOM on each Rate Plan
		logs.add('Hello');
        for (zqu.DataObject plan : plans) {
            List<zqu.DataObject> charges = plan.getChildren('zqu__QuoteRatePlanCharge__c');

			Decimal quantity = null;
            for (zqu.DataObject charge : charges) {
                Decimal chargeQuantity = (Decimal) charge.get('zqu__Quantity__c');
				if( quantity == null ) {
					quantity = chargeQuantity;
				} else if( chargeQuantity != quantity ) {
					throw new zqu.CustomValidationException('All charges must have the same quantity');
				}				
            }			
        }
    }
    
    global Boolean isUpdateAction() { return true; }
    global Boolean isAddRemoveAction() { return false; }
    global Boolean isValidateAction() { return true; }
}

With the rule set to always run if the username contains Nigel (i.e. when I run it) with just the above action then it doesn't. If I add an additional action of an Info message then it DOES run.

The rule is:

Condition Json	
{"criteriaType":"CONJUNCTION_CRITERIA","operationType":"OR_TYPE","parameters":[{"operationType":"CONTAINS","dataType":"STRING_TYPE","criteriaType":"COMPARISON_CRITERIA","leftTerm":{"valueType":"GLOBALVAR_VAL","dataType":"STRING_TYPE","globalVar":"USER_GVAR","fieldName":"Username"},"rightTerm":{"valueType":"CONSTANT_VAL","dataType":"STRING_TYPE","value":"nigel"}}]}
Action Json	
[{"actionType":"CUSTOM_ACTION","className":"NigelCustomActionPlugin","attributes":{"fff":"bbb"}}]

However, I've now found that if I change 

    global Boolean isAddRemoveAction() { return false; }

into 

    global Boolean isAddRemoveAction() { return true; }

Then it does run again - so maybe I have a workaround 🙂

Highlighted
Zuora Alumni

Re: CustomActionPlugin not being run

Hi @Nigel I will test your CustomActionPlugin code on my end end and let you know how it goes. WIll check with internal teams on this behavior.

WIll update this thread 

 

Thank you
Doyeli






If you found my answer helpful, please give me a kudo ↑
Help others find answers faster by accepting my post as a solution √

Highlighted
Master

Re: CustomActionPlugin not being run

@doyeli Hi - we were just discussing this again today and I found this thread and realised it didn't get updated. As mentioned the workaround was working so it's low priority.