• 0 Points
  • Member since 2017

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
  • 0
Below are the code of both queueable apex and batch class.
public class sendEmailsExtended implements Queueable{
    private static List<Email_Log__c> emailDebugLogs = new List<Email_Log__c>();
    map<String,TimeEmailRules__c> allRules;
    private Boolean sendEmails = true;
    public sendEmailsExtended(map<String,TimeEmailRules__c> query){
    public void execute(QueueableContext qc){
        Messaging.SingleEmailMessage mail1 = new Messaging.SingleEmailMessage();
        mail1.toAddresses=new List<String>{'abhishek.singh@yopmail.com','bkevat@yopmail.com','varun.singh@yopmail.com'};
        mail1.subject='Subject Test Message';
        mail1.plainTextBody='This is the message body.';
        //Messaging.SingleEmailMessage mail2 = new Messaging.SingleEmailMessage(toAddresses='abc1@gmail.com',optOutPolicy='FILTER',subject='Subject Test Message',plainTextBody='This is the message body.');
        //Messaging.SingleEmailMessage mail3 = new Messaging.SingleEmailMessage(toAddresses='abc1@gmail.com',optOutPolicy='FILTER',subject='Subject Test Message',plainTextBody='This is the message body.');
        sendEmailsBatchExtended batch = new sendEmailsBatchExtended(new List<Messaging.SingleEmailMessage>{mail1});
        Id batchjobId =Database.executebatch(batch,1);

Batch class Code
global class sendEmailsBatchExtended implements Database.Batchable<sObject>,Database.Stateful{
    List<Messaging.SingleEmailMessage> mailtosend;
    String query;
    public sendEmailsBatchExtended(List<Messaging.SingleEmailMessage> maillist){
    mailtosend = maillist;   
    global Iterable<sObject> start(Database.BatchableContext bc){
        return Database.getQueryLocator(query);
    global void execute(Database.BatchableContext bc,List<sObject> scope){
    System.debug('value in mailtosend'+mailtosend);
    global void finish(Database.BatchableContext bc){
Hello Community,
I am using Customer Community License but this license doesn't allow to create account record only read and edit permission is available but want to create the account using this license is there any workaround for this besides changing the license.

Please share your thoughts need to get a solution on an urgent basis.
Hello Team,
 I have a Vf page for User Registration purpose Consisting of three fields First Name,Last Name,Email on clicking of proceed button i am performing below operations:-
1) if user exist by the entered email and is active have to peroform something.(Done)
2) if user don't exist by the entered email than have to create new user .(Done)
3) if by entered email any contact exist in than that contact has to be enabled as a user.(Not Working)
I am pasting both my vf page and apex controller.

<VisualForce Page>
<apex:page docType="html-5.0"
    <apex:composition template="CPBase__template">
        <apex:define name="pageTitle">
            User Registration
        <apex:define name="pageStyles">
                float: right;
                margin-right: 96px;
                margin-top: 21px;
                width: 93% !important;
                .section-heading {    
                padding-left: 0 !important;
                .row_cstm {
                margin-top: 12px;
        <apex:define name="supernavRight">
        <apex:define name="pageMain">
            <div class="container noprint">
                <div class="well">
                    <apex:outputPanel id="msg">
                        <div class="well text-center">
                            <p class="errorMessage"></p>
                            <Framework:messages />
                    <apex:form html-novalidate="true" id="searchForm">
                        <apex:outputPanel id="thePanel">  
                            <script> var sbutton = document.getElementById("{!$Component.processBtn}"); </script>
                                function does_Userexist(){
                                console.log('user == ' + {!isUserExist});
                                    alert('User Exists! Please login to continue');
                                    location.href ="CPBase__custom_login";
                                    alert('Thank You. Please check your email to verify your account.')
                            function noenter(ev){ 
                                var key = ev.charCode ? ev.charCode : ev.keyCode ? ev.keyCode : 0;
                                if (window.event && window.event.keyCode == 13 || ev.which == 13) {
                                    return false;
                                } else {
                                    return true;
                        <div class="form-horizontal" role="form">
                            <div class="container m-t-30">
                                <!-- <h3 class="section-heading"> Section heading</h3> -->
                                <!-- Page begins -->
                                <div class="row row_cstm">
                                    <div class="col-sm-12">
                                        <apex:outputLabel value="{!$Label.Sample}" />
                                <div class="row row_cstm">
                                    <div class="col-sm-12">
                                        <apex:commandLink action="{!redirect}" value="Sign in here"/> to access the DBA Community.
                                <apex:repeat value="{!Fields}" var="f"> 
                                    <div class="row row_cstm">
                                        <div class="col-sm-12">
                                            <apex:inputField value="{!usernew[f.fieldPath]}" styleClass="form-control" required="{!OR(f.required, f.dbrequired)}" onkeypress="return noenter(event);"/>
                                <div class="row btn_algn_rt row_cstm">
                                    <div class="col-sm-6">
                                        <apex:commandButton value="Cancel" action="{!cancelaction}" styleclass="btn btn-info fonteva-slds-button slds-button slds-button--neutral FrameworkButton"/> 
                                    <div class="col-sm-6">
                                        <apex:commandButton value="Proceed" id="searchButton" action="{!Proceedaction}" oncomplete="does_Userexist();" styleclass="btn btn-info btn-wide" reRender="thePanel,msg" />  
                                <!-- Page Ends -->
        <apex:define name="pageScripts">
            <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
            <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
            <script type="text/javascript">
            var js$ = jQuery.noConflict();   

<-----apex controller---------->

global class DBA_RegistrationClass {
    public Boolean isUserExist{get;set;}
    global User usernew{get;set;}
    public DBA_RegistrationClass(){
        usernew = new User();
    // fieldset for user
    public List<Schema.FieldSetMember> getFields() {
        return SObjectType.User.FieldSets.Registration_Page_Field_Set.getFields();
    public PageReference redirect(){
        PageReference pageRef = new PageReference('/apex/DBA_Login');
        return pageRef;
    public PageReference proceedaction(){
            Framework.Message.addMessage('Please Enter Email', Framework.Message.Severity.Warning);
            //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please select atleast one contact'));
            return null;
        Profile  p = [select id,Name from Profile where name ='Customer Community Login User' LIMIT 1];
        UserRole ur =[Select id,name from UserRole where Name='CEO'];
        List<Contact> contactList =[SELECT ID,name,Email FROM Contact WHERE Email=:usernew.Email];
        List<User> userListToInsert = new List<User>();
                User newUserTOInsert = new User();
                newUserTOInsert.Username = contactList.get(0).Email;
                newUserTOInsert.CommunityNickname = contactList.get(0).Email;
                newUserTOInsert.ContactId = contactList.get(0).Id;     
                newUserTOInsert.Email = contactList.get(0).Email;
                newUserTOInsert.EmailEncodingKey = 'ISO-8859-1';
                newUserTOInsert.FirstName = contactList.get(0).FirstName;
                newUserTOInsert.LastName = contactList.get(0).LastName;
                newUserTOInsert.IsActive = true;
                newUserTOInsert.ProfileId = p.Id;
                newUserTOInsert.UserRoleId = ur.Id;
        insert userListToInsert;
        List<user> activecommunityuser=[SELECT ID,name,Email FROM User WHERE IsActive=True AND Email=:usernew.Email and ContactId!=null];
            isUserExist= TRUE;
            Profile  p1 = [SELECT id,Name FROM Profile WHERE name ='Customer Community Login User' LIMIT 1];
            UserRole urerObj =[SELECT id,name FROM UserRole WHERE Name='CEO'];
                Account acc = [Select Id From Account where Name='Design Students' LIMIT 1];
                Site.createExternalUser(usernew, String.valueOf(acc.Id)); 
            catch(exception ex){
                Framework.Message.addMessage(ex.getmessage(), Framework.Message.Severity.Warning);
                //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please select atleast one contact'));
          PageReference page = new PageReference('https://www.dba.org.uk');
          return page;
    public PageReference cancelaction(){
        PageReference pageRef = new PageReference('https://www.dba.org.uk');
        return pageRef;

Please provide your valuable inputs.
Many thanks in advance.