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
steve456steve456 

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 

Prafull G.Prafull G.

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!

Rahul SharmaRahul Sharma
Don't forgot to add a check before slicing the string.
Means Before performing subString, Check if that String size is greater than 8
davidjgriffdavidjgriff

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