You need to sign in to do that
Don't have an account?
DannyTK
Receiving an error: no viable alternative at character ' '
Good afternoon,
as a non-developer, i'm trying to write a trigger that will update the owner of a custom object record "Sales Order" back to the creator of the record when the status is "Sales Order Completion",
(pretty basic, which is the only reason I would attempt it myself), code is:
trigger UpdateOwner on Sales_Order__c (after Update)
{
if((trigger.new[0].Status__c == 'Sales Order Completion') && (trigger.old[0].Status__c != 'Sales Order Completion'))
{ trigger.new[0].OwnerId = trigger.new[0].CreatedById ;
}
}
it's throwing a Compile Error: line 5:10 no viable alternative at character '' at line 5 column 10
the only thing on line 5 is the }, so i'm assuming i have a missing reference somewhere.
Any help is appreciated on why i'm getting the error message
as a non-developer, i'm trying to write a trigger that will update the owner of a custom object record "Sales Order" back to the creator of the record when the status is "Sales Order Completion",
(pretty basic, which is the only reason I would attempt it myself), code is:
trigger UpdateOwner on Sales_Order__c (after Update)
{
if((trigger.new[0].Status__c == 'Sales Order Completion') && (trigger.old[0].Status__c != 'Sales Order Completion'))
{ trigger.new[0].OwnerId = trigger.new[0].CreatedById ;
}
}
it's throwing a Compile Error: line 5:10 no viable alternative at character '' at line 5 column 10
the only thing on line 5 is the }, so i'm assuming i have a missing reference somewhere.
Any help is appreciated on why i'm getting the error message
I found some issues in your code and modified it.Try the below code this should work :-
<pre>
trigger UpdateOwner on Sales_Order__c (before Update)
{
for(Sales_Order__c sc : trigger.new)
{
Sales_Order__c oldrecord = trigger.oldMap.get(sc.id);
if(sc.Status__c == 'Sales Order Completion' && oldrecord.Status__c=='Sales Order Completion')
{
sc.OwnerId = sc.CreatedById ;
}
}
</pre>
All Answers
http://stackoverflow.com/questions/11001916/no-viable-alternative-at-character
Hope this helps !!
I found some issues in your code and modified it.Try the below code this should work :-
<pre>
trigger UpdateOwner on Sales_Order__c (before Update)
{
for(Sales_Order__c sc : trigger.new)
{
Sales_Order__c oldrecord = trigger.oldMap.get(sc.id);
if(sc.Status__c == 'Sales Order Completion' && oldrecord.Status__c=='Sales Order Completion')
{
sc.OwnerId = sc.CreatedById ;
}
}
</pre>
I replaced my trigger with yours, i trust that it's better than what i can write. Looks like it's still throwing out the "no viable alternative at character '' at line 9 column 9" error message....i also deleted the single quotes and re-typed them. (and added a closed "}", looks like it's missing one)
I copied it from a different format and it worked, thanks for both of your help