• Prav P
  • NEWBIE
  • 0 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies
Hi,

Is there any possibility to hide the "Embedded Chat" on the site, i have updated the javascript to showup the chat window for only few users, but looks like its not working. 
Nay help
  • August 12, 2021
  • Like
  • 0
Hi,

Im trying to create user from contact object by using trigger and method. However, Im getting the below error , could you please help

Variable does not exist: CreateNewUserHandler
Missing  at 'public'


trigger NewUser on Contact (after insert) {

    List<User> userList = new List<User>();
    Set<Id> contactIds = new Set<Id>();
    for(Contact c: Trigger.New){
       if(c.Agent_type__c == 'Member'){
            contactIds.add(c.id);
        }
    }

    if(contactIds.size() > 0){
        CreateNewUserHandler.createNewUserFromContact(contactIds);
    }
}
public with sharing class CreateNewUserHandler {


public static void CreateNewUserHandler(Set<Id> contactIds)
{
    List<User> userList = new List<User>();
    List<Profile> profileList = [Select Id from Profile where Name=: 'Customer Community User' limit 1];
    //List<UserRole> roleList = [Select Id from UserRole where Name=: 'CEO' limit 1];
    for(Contact contactObj : [Select Id, Name, Email,Username__c from Contact where Id IN: contactIds limit 50000]){
        User uObj = new User();
        uObj.Username = contactObj.Username__c;
        uObj.Email = contactObj.Email;
        uObj.Alias = contactObj.Name;
        uObj.UserRoleId = roleList[0].Id;
        uObj.ProfileId = profileList[0].Id;
        uObj.IsActive = true; 
        uObj.TimeZoneSidKey = 'GMT';
        uObj.LanguageLocaleKey = 'en_US';
        uObj.EmailEncodingKey = 'UTF-8';
        uObj.LocaleSidKey = 'en_US';
        uObj.ContactId = contactObj.Id;
        userList.add(uObj);
    }
    try{
           insert userList;  // insert the user record
    }catch(Exception e){
          // Catch Exception
     }
}
Hi ,

Im trying to authenticate Salesforce -Okta through Auth Provider and to support that I have created the Registration Handler which creates and updates the users from SF to okta. However, Im receiving the below error in line1, though i have implemented the both createUser and UpdateUser method. Any help please

"Class Oktahandler must implement the method: User Auth.RegistrationHandler.createUser(Id, Auth.UserData)"


global class Oktahandler implements Auth.RegistrationHandler {

    private static final String ORG_SUFFIX = '.test';
    private static final String DEFAULT_ACCOUNTNAME = 'Test';
    private static final String DEFAULT_EXTERNAL_USER_PROFILE = 'Customer Community User';
    private static final String DEFAULT_INTERNAL_USER_PROFILE = 'Standard User';
    private static final String EXTERNAL_APPS_LOGIN_LICENSE_NAME = 'Community User';
    private static final String SALESFORCE_LICENSE_NAME = 'Salesforce';
    private static final String TZSID = [SELECT timezonesidkey from User where profile.name = 'System administrator' LIMIT 1].timezonesidkey;

global Boolean canCreateUser(Auth.UserData data) {
      //Check whether we want to allow creation of a user?
      return true;
  }
 
  global User createUser(Id portalId, Auth.UserData data){
      if(!canCreateUser(data)) {
        return null;
      }
      system.debug(data);
      if(data.attributeMap.containsKey('sfdc_networkid')) {
list<user> ulist =[select id,email from user where email=:data.email];
          if(ulist.size()>0){
             return ulist[0];
          }
        
      Account a=[select id from account where id='0017c00000oh8M2AAI'];
      contact c=new contact();
      c.accountid=a.id;
      c.email=data.email;
      c.FirstName=data.attributeMap.get('FirstName');
      c.LastName=data.attributeMap.get('LastName');
      insert c;
         
      user u=new user();
     Profile p = [SELECT Id FROM profile WHERE name='Customer Community User'];
   u.email = data.email;
    u.lastName = data.attributeMap.get('LastName');
    u.firstName = data.attributeMap.get('FirstName');
      u.Username=data.attributeMap.get('UserName');
        String alias = data.username;
    //Alias must be 8 characters or less
    if (alias.length() > 8) {
        alias = alias.substring(0, 8);
    }
       u.alias = alias;
    u.languagelocalekey = 'en_US';
    u.localesidkey = 'en_US';
    u.emailEncodingKey = 'UTF-8';
    u.timeZoneSidKey = 'Australia/Brisbane';
    u.profileId = p.Id;
      u.ContactId=c.id;
    return u;
      }
      else{
          return null;
      }
   }
 
  global void updateUser(Id userId, Id portalId, Auth.UserData data){
      User u = new User(id=userId);
       u.lastName = data.attributeMap.get('LastName');
      //.. update fields if required.
     // update u;
  }
}
Hi,

Im trying to create user from contact object by using trigger and method. However, Im getting the below error , could you please help

Variable does not exist: CreateNewUserHandler
Missing  at 'public'


trigger NewUser on Contact (after insert) {

    List<User> userList = new List<User>();
    Set<Id> contactIds = new Set<Id>();
    for(Contact c: Trigger.New){
       if(c.Agent_type__c == 'Member'){
            contactIds.add(c.id);
        }
    }

    if(contactIds.size() > 0){
        CreateNewUserHandler.createNewUserFromContact(contactIds);
    }
}
public with sharing class CreateNewUserHandler {


public static void CreateNewUserHandler(Set<Id> contactIds)
{
    List<User> userList = new List<User>();
    List<Profile> profileList = [Select Id from Profile where Name=: 'Customer Community User' limit 1];
    //List<UserRole> roleList = [Select Id from UserRole where Name=: 'CEO' limit 1];
    for(Contact contactObj : [Select Id, Name, Email,Username__c from Contact where Id IN: contactIds limit 50000]){
        User uObj = new User();
        uObj.Username = contactObj.Username__c;
        uObj.Email = contactObj.Email;
        uObj.Alias = contactObj.Name;
        uObj.UserRoleId = roleList[0].Id;
        uObj.ProfileId = profileList[0].Id;
        uObj.IsActive = true; 
        uObj.TimeZoneSidKey = 'GMT';
        uObj.LanguageLocaleKey = 'en_US';
        uObj.EmailEncodingKey = 'UTF-8';
        uObj.LocaleSidKey = 'en_US';
        uObj.ContactId = contactObj.Id;
        userList.add(uObj);
    }
    try{
           insert userList;  // insert the user record
    }catch(Exception e){
          // Catch Exception
     }
}
Hi ,

Im trying to authenticate Salesforce -Okta through Auth Provider and to support that I have created the Registration Handler which creates and updates the users from SF to okta. However, Im receiving the below error in line1, though i have implemented the both createUser and UpdateUser method. Any help please

"Class Oktahandler must implement the method: User Auth.RegistrationHandler.createUser(Id, Auth.UserData)"


global class Oktahandler implements Auth.RegistrationHandler {

    private static final String ORG_SUFFIX = '.test';
    private static final String DEFAULT_ACCOUNTNAME = 'Test';
    private static final String DEFAULT_EXTERNAL_USER_PROFILE = 'Customer Community User';
    private static final String DEFAULT_INTERNAL_USER_PROFILE = 'Standard User';
    private static final String EXTERNAL_APPS_LOGIN_LICENSE_NAME = 'Community User';
    private static final String SALESFORCE_LICENSE_NAME = 'Salesforce';
    private static final String TZSID = [SELECT timezonesidkey from User where profile.name = 'System administrator' LIMIT 1].timezonesidkey;

global Boolean canCreateUser(Auth.UserData data) {
      //Check whether we want to allow creation of a user?
      return true;
  }
 
  global User createUser(Id portalId, Auth.UserData data){
      if(!canCreateUser(data)) {
        return null;
      }
      system.debug(data);
      if(data.attributeMap.containsKey('sfdc_networkid')) {
list<user> ulist =[select id,email from user where email=:data.email];
          if(ulist.size()>0){
             return ulist[0];
          }
        
      Account a=[select id from account where id='0017c00000oh8M2AAI'];
      contact c=new contact();
      c.accountid=a.id;
      c.email=data.email;
      c.FirstName=data.attributeMap.get('FirstName');
      c.LastName=data.attributeMap.get('LastName');
      insert c;
         
      user u=new user();
     Profile p = [SELECT Id FROM profile WHERE name='Customer Community User'];
   u.email = data.email;
    u.lastName = data.attributeMap.get('LastName');
    u.firstName = data.attributeMap.get('FirstName');
      u.Username=data.attributeMap.get('UserName');
        String alias = data.username;
    //Alias must be 8 characters or less
    if (alias.length() > 8) {
        alias = alias.substring(0, 8);
    }
       u.alias = alias;
    u.languagelocalekey = 'en_US';
    u.localesidkey = 'en_US';
    u.emailEncodingKey = 'UTF-8';
    u.timeZoneSidKey = 'Australia/Brisbane';
    u.profileId = p.Id;
      u.ContactId=c.id;
    return u;
      }
      else{
          return null;
      }
   }
 
  global void updateUser(Id userId, Id portalId, Auth.UserData data){
      User u = new User(id=userId);
       u.lastName = data.attributeMap.get('LastName');
      //.. update fields if required.
     // update u;
  }
}