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
vijayakumar Bvijayakumar B 

URL Comparision

hi friends,
 this trigget is not working.
my aim is to print an error message  if the selected url is shine.com

 could you help me..?

trigger ppp on Job_Posting__c (before insert,before update) {

//Employment_Website__c web=new Employment_Website__c();
for (Job_Posting__c jobInLoop : Trigger.new) {
        if(String.valueOf(jobInLoop.Employment_Website__c)=='http://Shine.com'){
       
        jobInLoop.addError('WE cannot post your Job to shine.com');
        }
    }
//Web_Address__c   Price_Per_Post__c

}
Vamsi KrishnaVamsi Krishna
Hi,

you can convert the input string to all lower case and use contains function to check if the value has shine.com ...

jobInLoop.Employment_Website__c.toLowerCase().contains('shine.com')

Vinit_KumarVinit_Kumar
How you are executing this Trigger ??

Also,what is the Datattype of field Employment_Website__c
vijayakumar Bvijayakumar B
*Data type of the field "Employment_Website__c" is URL and in fact i'm tying compare it with the given string. then1 thing i want to tell is here look up relation is there..*
Vinit_KumarVinit_Kumar
The way @Vamsi has suggested looks good to me,just to add one thign to it ,try below code in your if condition :-
jobInLoop.Employment_Website__c.toString().toLowerCase().contains('shine.com')
and I didn't understand what you meant by lookup relation here ...