+ Start a Discussion
saariko.ax241saariko.ax241 

Creating a new contact and enable Self Service for it

We are currently using our application to create new contacts in SF. What I need now, is to be able to enable SSP for these users.

 

In all the posts so far, I saw it's impossible, and I need to use a trigger. I am not familiar with triggers, and I think that the samples in the lab day are not sufficient, but that's another post :-P

 

I would truly appreciate a sample code or an alternate method to enable SSP to a newly created contact.

 

The sample code I got from one of the posts is:

 

 

trigger EndSSUAccessWhenContactIsSetToFormerUser on Contact bulk (after update) { Set<Id> lConIds = new Set<Id>(); for (Contact c : Trigger.new) { lConIds.add(c.Id); } List<SelfServiceUser> lSSUs = new List<SelfServiceUser>([select Id, IsActive, ContactId from SelfServiceUser where ContactId in :lConIds]); Map<Id,SelfServiceUser> lSelfServiceUsers = new Map<Id,SelfServiceUser>(); for(SelfServiceUser s: lSSUs) { lSelfServiceUsers.put(s.ContactId,s); } List<SelfServiceUser> lSelfServiceUserUpdates = new List<SelfServiceUser>(); for (Contact c : Trigger.new) { SelfServiceUser s = lSelfServiceUsers.get(c.Id); if(c.OMG_ContactType__c == 'Former User' && s != null && s.IsActive) { s.IsActive = false; lSelfServiceUserUpdates.add(s); if(lSelfServiceUserUpdates.size() == 200) { //update lSelfServiceUsersUpdates; lSelfServiceUserUpdates.clear(); } } } if(lSelfServiceUserUpdates.size() > 0) { //update lSelfServiceUsersUpdates; } }

 

This is a pure copy&paste but I am doing it since I can not grasp the idea of the triggers yet.

 

I will rally appreciate any help that will help me to solve this.