You need to sign in to do that
Don't have an account?
David Okner 17
trigger to input text in custom field when case is created
Hi all,
writing my first trigger and can't seem to get it to work, can you take a look and see what I am doing wrong? Should it be after insert, before update?
It's just not putting the test text in the custom field...
What i am trying to do is eventually put a template in the description field for my users to fill out.
Thanks!
trigger insertText on Case (before insert, before update) {
for (case c : trigger.new) {
If (c.triggertest__c == null)
c.triggertest__c = 'Text here';
else {
System.debug ('field is already filled in');
}
}
}
writing my first trigger and can't seem to get it to work, can you take a look and see what I am doing wrong? Should it be after insert, before update?
It's just not putting the test text in the custom field...
What i am trying to do is eventually put a template in the description field for my users to fill out.
Thanks!
trigger insertText on Case (before insert, before update) {
for (case c : trigger.new) {
If (c.triggertest__c == null)
c.triggertest__c = 'Text here';
else {
System.debug ('field is already filled in');
}
}
}
Dear David,
You have to trigger the trigger before insert and before update if you want to assign a value to same record or you wanna put some custom validations.
The code you have mentioned should work. Try to add OR condition in if block like following
Hope it helps you. Let me know if need help.
thanks,
Anjith kumar.