• Sunil Kumar 545
  • NEWBIE
  • 20 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 24
    Questions
  • 24
    Replies
http://dummy.restapiexample.com/

using this link (employee detail)have to write in batch class (api callouts)
can anyone able  to help for this requirement ?
how to create apex trigger using email message in email to case (automatically task sholud created notification have to come using salesforce lightind)uisng apex trigger ,can anyone tell me this requiremnt as soon as possible?
@RestResource(urlMapping='/PortalUser/*')
Global Class rolesException extends Exception {
    @HttpPost   
    global static String CreateNewUser()  
        {             
     
         RestRequest req = RestContext.request;    
         System.debug('RestRequest___: '+ req);     
         RestResponse res = RestContext.response;   
         System.debug('RestResponse___: '+ res);    
         Blob b = req.Requestbody;                 
         Wrapperclss reg = rolesException.parse(b.tostring());
            Savepoint sp = Database.setSavepoint();

         Try{    
               if(reg.firstname==null || reg.firstname=='')
                {
                    throw new rolesException ('enter firstname');
                }
                if(reg.lastname==null || reg.lastname=='')
                {
                    throw new rolesException ('enter lastname');        
                }
                //if(Pattern.matches('[a-zA-Z0-9._-]+@[a-zA-Z]+.[a-zA-Z]{2,4}',reg.Email))
                //{                        
                  //     throw new rolesException ('Please enter valid emailid');
                //} 
                
                 if(reg.role==null || reg.role=='')
                 {
                    throw new rolesException('role is required');  
                 }        
                 /*list<contact> sr =[SELECT  lastName, Role__c from Contact where  Role__c=:reg.Role];
                 system.debug('enter@@@'+sr);
                 if(sr.size()<=0)
                 {
                    throw new rolespostportalException('role is requiredee');        
                 }*/
                 
                 list<Role__c>role=[select Name,Type__c from Role__c where type__c =:reg.Role];
                 system.debug('Enter__'+role);
                 if(role[0].type__c == 'Manager')
               {
                   List<Contact> con = [SELECT Id, Name FROM Contact WHERE accountId=:reg.AccountID AND Role__c=:role[0].Id];
                   if(con.size()>0)

                   {
                       throw new rolesException('Manager already exist');
                   }
               }
               if(reg.username!=null || reg.username!='')

                   {

                    List<User> u = [SELECT username FROM User WHERE username =:reg.username];

                    if(u.size()>0)

                   {

                       throw new rolesException('User already exist');
     }

                    }
            
            Contact C1 = new Contact( AccountID =reg.AccountID, firstName = reg.Firstname, lastName =reg.lastname ,email =reg.Email, role__c = role[0].id);
            insert C1;
                User newUser = new User();           
                newUser.Username =reg.username;     
                newUser.LastName = reg.lastname;
                newUser.Firstname = reg.Firstname;
                newUser.Email = reg.Email;      
                newUser.ContactId =C1.id ;
                newUser.Alias =reg.Alias;
                newUser.TimeZoneSidKey = reg.TimeZoneSidKey;
                newUser.LocaleSidKey = reg.LocaleSidKey;
                newUser.EmailEncodingKey = reg.EmailEncodingKey;
                newUser.LanguageLocaleKey = reg.LanguageLocaleKey;
                newUser.CommunityNickname= reg.CommunityNickname;
                newUser.ProfileId= reg.ProfileId;         
                insert newUser;        
                return 'User Created! Id Is: ' + newUser.Id; 
            }
               catch(Exception e)
               {
                    Database.rollback( sp );
                    system.debug('error____:enter valid ID'+e);
                    return e.getMessage();
               }
        }
               global static Wrapperclss parse(string reg) 
               {       
                   return(Wrapperclss)System.json.deserialize(reg,Wrapperclss.class);  
               }   
               global class Wrapperclss  
                {      
                    global String username{get;set;} 
                    global String Firstname{get;set;} 
                    global String LastName{get;set;}     
                    global String Email{get;set;}    
                    global String ContactId{get;set;}   
                    global String Role{get;set;}
                    global String Alias{get;set;}   
                    global String TimeZoneSidKey{get;set;}   
                    global String EmailEncodingKey{get;set;} 
                    global String LanguageLocaleKey{get;set;}
                    global String LocaleSidKey{get;set;}
                    global String CommunityNickname{get;set;}
                    global String ProfileId{get;set;}   
                    global String AccountID{get;set;}   

                }    
          
    }
have to create site,then have to register,and using user without session id .?
step by step how to implement ?

create external user(portal user should create)pass parameter firstname,lastname,email,role)...if firstname,lastname not given means (not required field thorw),if email not given means exception sholud throw it sholud check emailformat ,and then role have check is there are not,



 
* have to create one role object in that name,type ..type should be picklist value manager,staff(this one completed )

* create external user(portal user should create)pass parameter firstname,lastname,email,role)...if firstname,lastname not given means (not required field thorw),if email not given means exception sholud throw it sholud check emailformat ,and then role have check is there are not,

* if i create manger record already means ..again i create na it should throw error
check whether email is there or not in lead object ...if lead exist means convert to contact and account 
if it does not exist means it sholud be contact using apex class ...send code in only apex class..
passing parameter method (first name,lastname,eamil)
check query with lead .eamil is there or not,
if lead exit means it converted to (con/acc),
if does not exit means(contact or account)
using apex class..
passing parameter method in(firstname,lastname,email)and query with in contact object email is there means it will show its generate or not create any email it create automatically new contact will create .lead exit covert to contact/account,does not exit means convert contact .successfully...using apex class
how to create apex trigger using email message in email to case (automatically task sholud created notification have to come using salesforce lightind)uisng apex trigger ,can anyone tell me this requiremnt as soon as possible?
@RestResource(urlMapping='/PortalUser/*')
Global Class rolesException extends Exception {
    @HttpPost   
    global static String CreateNewUser()  
        {             
     
         RestRequest req = RestContext.request;    
         System.debug('RestRequest___: '+ req);     
         RestResponse res = RestContext.response;   
         System.debug('RestResponse___: '+ res);    
         Blob b = req.Requestbody;                 
         Wrapperclss reg = rolesException.parse(b.tostring());
            Savepoint sp = Database.setSavepoint();

         Try{    
               if(reg.firstname==null || reg.firstname=='')
                {
                    throw new rolesException ('enter firstname');
                }
                if(reg.lastname==null || reg.lastname=='')
                {
                    throw new rolesException ('enter lastname');        
                }
                //if(Pattern.matches('[a-zA-Z0-9._-]+@[a-zA-Z]+.[a-zA-Z]{2,4}',reg.Email))
                //{                        
                  //     throw new rolesException ('Please enter valid emailid');
                //} 
                
                 if(reg.role==null || reg.role=='')
                 {
                    throw new rolesException('role is required');  
                 }        
                 /*list<contact> sr =[SELECT  lastName, Role__c from Contact where  Role__c=:reg.Role];
                 system.debug('enter@@@'+sr);
                 if(sr.size()<=0)
                 {
                    throw new rolespostportalException('role is requiredee');        
                 }*/
                 
                 list<Role__c>role=[select Name,Type__c from Role__c where type__c =:reg.Role];
                 system.debug('Enter__'+role);
                 if(role[0].type__c == 'Manager')
               {
                   List<Contact> con = [SELECT Id, Name FROM Contact WHERE accountId=:reg.AccountID AND Role__c=:role[0].Id];
                   if(con.size()>0)

                   {
                       throw new rolesException('Manager already exist');
                   }
               }
               if(reg.username!=null || reg.username!='')

                   {

                    List<User> u = [SELECT username FROM User WHERE username =:reg.username];

                    if(u.size()>0)

                   {

                       throw new rolesException('User already exist');
     }

                    }
            
            Contact C1 = new Contact( AccountID =reg.AccountID, firstName = reg.Firstname, lastName =reg.lastname ,email =reg.Email, role__c = role[0].id);
            insert C1;
                User newUser = new User();           
                newUser.Username =reg.username;     
                newUser.LastName = reg.lastname;
                newUser.Firstname = reg.Firstname;
                newUser.Email = reg.Email;      
                newUser.ContactId =C1.id ;
                newUser.Alias =reg.Alias;
                newUser.TimeZoneSidKey = reg.TimeZoneSidKey;
                newUser.LocaleSidKey = reg.LocaleSidKey;
                newUser.EmailEncodingKey = reg.EmailEncodingKey;
                newUser.LanguageLocaleKey = reg.LanguageLocaleKey;
                newUser.CommunityNickname= reg.CommunityNickname;
                newUser.ProfileId= reg.ProfileId;         
                insert newUser;        
                return 'User Created! Id Is: ' + newUser.Id; 
            }
               catch(Exception e)
               {
                    Database.rollback( sp );
                    system.debug('error____:enter valid ID'+e);
                    return e.getMessage();
               }
        }
               global static Wrapperclss parse(string reg) 
               {       
                   return(Wrapperclss)System.json.deserialize(reg,Wrapperclss.class);  
               }   
               global class Wrapperclss  
                {      
                    global String username{get;set;} 
                    global String Firstname{get;set;} 
                    global String LastName{get;set;}     
                    global String Email{get;set;}    
                    global String ContactId{get;set;}   
                    global String Role{get;set;}
                    global String Alias{get;set;}   
                    global String TimeZoneSidKey{get;set;}   
                    global String EmailEncodingKey{get;set;} 
                    global String LanguageLocaleKey{get;set;}
                    global String LocaleSidKey{get;set;}
                    global String CommunityNickname{get;set;}
                    global String ProfileId{get;set;}   
                    global String AccountID{get;set;}   

                }    
          
    }
check whether email is there or not in lead object ...if lead exist means convert to contact and account 
if it does not exist means it sholud be contact using apex class ...send code in only apex class..
passing parameter method (first name,lastname,eamil)
check query with lead .eamil is there or not,
if lead exit means it converted to (con/acc),
if does not exit means(contact or account)
using apex class..