You need to sign in to do that
Don't have an account?
steve456
Basic Trigger---LEFT Function
How do i write the LEFT functionality in a trigger
Trigger on Order Entry
ON CREATE ONLY
IF(RecordType.Name == "PG" && Product__r.Group__c == 'Data Plan) THEN
IF(LEFT(Order_Number__r.Inventory__r.Product__r.Name__c, 8) == "V-Portal" && Order_Number__r.Date__c >= 2013-02-11) THEN
Additional_Revenue__c = 15
ELSE
Additional_Revenue__c = 0
ENDIF
ENDIF
Thanks in advance
You can use String method i.e. subString to get the specific characters string.
IF((Order_Number__r.Inventory__r.Product__r.Name__c != null && Order_Number__r.Inventory__r.Product__r.Name__c.subString(0, 8) == "V-Portal") && Order_Number__r.Date__c >= 2013-02-11) {
.
.
.
Cheers!
Means Before performing subString, Check if that String size is greater than 8
You are probably looking for the startsWith or startsWithIgnoreCase String instance methods.
http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_methods_system_string.htm