You need to sign in to do that
Don't have an account?
Devon Morancie
Assign user to ID issue
Hi all, I'm having trouble getting a user assigned to a specific ID.
Basically, when creating a new Task, if the Owner of the Event (custom object) is a certain Id (let's call it A) then the owner of the task must be set to Id C. If the owner is Id B, then it must also be set to Id C. The Id A condition works just fine, but the condition for B does not. I am pasing the Id as a string, to a lookup field (User, Calendar), in an if statement.
if(event.Owner == 'A'){
task.Owner = 'C';}
else if (event.Owner == 'B'){
task.Owner = 'C';}
Condition A works fine, but condition B does not. In the DML insert error, it sas that the task.Owner is null, but ONLY when attempting to set with condition B. The two blocks of code are the same, and I have put debug statements in there to check and make sure the if statements are firing correctly, and they are. Any ideas?
Basically, when creating a new Task, if the Owner of the Event (custom object) is a certain Id (let's call it A) then the owner of the task must be set to Id C. If the owner is Id B, then it must also be set to Id C. The Id A condition works just fine, but the condition for B does not. I am pasing the Id as a string, to a lookup field (User, Calendar), in an if statement.
if(event.Owner == 'A'){
task.Owner = 'C';}
else if (event.Owner == 'B'){
task.Owner = 'C';}
Condition A works fine, but condition B does not. In the DML insert error, it sas that the task.Owner is null, but ONLY when attempting to set with condition B. The two blocks of code are the same, and I have put debug statements in there to check and make sure the if statements are firing correctly, and they are. Any ideas?
Can you share your real code with declaring variable & insert part?
There might be a possibility that the event owner is neither A nor B. You might be testing the second scenario with the wrong event owner.
If you can provide the real code (if and else statement) with the record data then it will easy to find the issue.
I will suggest you check the event owner field value against the A and B.
Thanks