You need to sign in to do that
Don't have an account?
Mateo
Newbie: Error on APEX Trigger
Hi there,
I'm new to APEX coding and seem to be frustrated by the smallest infractions...
Receiving the error "Compile Error: line 2:0 no viable alternative at character " at line 2 column 0"
Exact code is as follows:
trigger InsertUpdateContactBefore on Contact (before insert, before
update)
{
for (Contact c : Trigger.new) {
//Don't let records be entered without Account
if (c.AccountId == null){
c.addError('All contacts must be related to an account. If you are
creating this Contact in the Lookup screen,
you\'ll need to create the
contact with complete information by selecting Contact from the
"Create New..."
drop-down in the left-hand sidebar.');
}
} }
I'm certain this is an easy answer, but I can't come up with it. I've attempted to "retype" the code after copying and pasting from a text editor as simple text. I've also looked for help in other forums and using the APEX manual available online - just not getting it.
Thanks in advance!
Ankit,
Thank you! I ended up having to type the whole code sequence back into the UI manually. Your copy/paste idea still didn't work - I received the same error - BUT your comment did allow me to see that something in the text was functioning incorrectly - so I certainly appreciate the help!
Thanks much,
Mateo
All Answers
Hi Mateo,
The problem is very strange as everything looks fine. But what we see is not real sometimes.
Yes, I copy your code and pasted in notepad I got
The dot in red is invisible on UI. Copy this code as your first line it will surely resolve your problem
Thanks
Ankit Arora
Blog | Facebook | Blog Page
Ankit,
Thank you! I ended up having to type the whole code sequence back into the UI manually. Your copy/paste idea still didn't work - I received the same error - BUT your comment did allow me to see that something in the text was functioning incorrectly - so I certainly appreciate the help!
Thanks much,
Mateo