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

APEX: Check a contact also has an associated Customer Portal User
hi
I am writing a trigger that updates a customer portal user when the associated contact is updated. I have the class but only want to run the trigger when the contact has an associated cust portal user - I can't seem to find reference to this at all. y Trigger would be something like
trigger UpdateUserfromContact on Contact (after update) {
Contact c = Trigger.new[0];
//And only if the contact has a related Customer Portal User associated
UpdatePortalUserfromContact.updateUser(c.Id);
}
thanks
The contact appears as a lookup on the user record, thus you'd need to pull back the user detail based on the contact id:
I'm also duty bound to point out that your trigger isn't bulkified, so it won't handle changes to a number of users at once, via the data loader for instance.