function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
edel32edel32 

contains function

Im using the quotes app to add products to an opportunity.
I want to check the product name to see if it contains setup. if it does the contract term must be = 1. iv tried using the contains function but it doesnt work.this is the code im using:  if(term!=12 && !CONTAINS(Product2__c, "Annual")) when this is true it pops up with an error saying quote lines cannot be created because of an object error.
any ideas on how to do this


Message Edited by edel32 on 07-16-2008 04:22 AM
werewolfwerewolf
That's not going to work because product is a child of opportunity (not even that actually, it's a child of opportunity line item).  CONTAINS is a string contains function -- it just looks in a string to see if it contains some value.  It won't look across multiple child objects.

In order to do what you want to do here you'll have to write an Apex trigger.
edel32edel32
any ideas on how i might do this. im pretty new to using apex and triggers
werewolfwerewolf
I don't have any specific sample code for you, but you may find something of use in the Force.com Cookbook, which is a pretty good repository of samples.