You need to sign in to do that
Don't have an account?
Jay reddy
Need help on Custom Setting Logic
Hello,
I have a requirement where we have Subscription products and in that some should be sold for definite time period [3 months] and the rest of the products from the similar category can be sold for any time period. For this I have created a CUSTOM SETTING for the products which should be sold for definite time period [3 months] but seems my logic is incorrect and throwing the same second error [see below in the code] for the products which are in CUSTOM SETTING. They do have different error.
I have a requirement where we have Subscription products and in that some should be sold for definite time period [3 months] and the rest of the products from the similar category can be sold for any time period. For this I have created a CUSTOM SETTING for the products which should be sold for definite time period [3 months] but seems my logic is incorrect and throwing the same second error [see below in the code] for the products which are in CUSTOM SETTING. They do have different error.
Set<String> ExcludeSubProdIds = new Map<String, Product2> ([Select Name,ProductCode from Product2 WHERE ProductCode IN: SubscriptionProducts__c.getAll().keySet()]).keySet(); for(Quotelineitem qli:QLIList){ if(qli.Product_Code__c.contains('SUB')) { if(ExcludeSubProdIds.contains(qli.Product_Code__c) && (qli.Number_of_Terms__c !=3 || decimavalue!=0) ){ qli.adderror('Error. Please check dates'); } else if(!ExcludeSubProdIds.contains(qli.Product_Code__c) && (qli.Number_of_Terms__c== 0 ||decimavalue!=0)) { qli.adderror('Term Periods must be in whole months (for SUB products) and whole years products.'); } } }
Can you please share snap of your Custom Settings and also wondering, why not use Custom Metadata Types instead of Custom Settings ?
Hello Ashish,
Here it is...Setting Type is LIST
I did not look at the logic but what I am seeing you are adding "qli.adderror()" in both if and elseif condition. I would suggest to put System.debug and see the flow and test it out. thanks.