You need to sign in to do that
Don't have an account?

Error Message on Apex Trigger
Still pretty new to Apex Triggers, but here is what I am trying to do. I need the custom field Related_User__C on the custom object Activity__C to autopopulate with the current user's username. Here is what I've written: trigger SetRelatedUser on Activity__c (before insert) { List <user> userid = UserInfo.getUserId(); if (Activity__c. Related_User__c == null) { Activity__c. Related_User__c = userid; } } I keep getting this error though... Error: Compile Error: Illegal assignment from String to LIST<User> at line 2 column 5 Any help would be greatly appreciated. Thanks.
|
That's because userid is a string, so you can't set that equal to a list. Try this:
Thanks for your reply!
Now I'm getting this error:
Compile Error: Expression cannot be assigned at line -1 column -1
Not sure about that, but I just realized you had spaces before the field names ... I edited my previous post above, so try it without those extra spaces.
Tried it without spaces, still no dice. Thank you anyway!
Well, sorry about that, my mind was temporarliy turned off. You need to assign the Activity__c to an actual variable instead of just using the object name.
Here ya go: