• prasanth kumar 21
  • NEWBIE
  • 0 Points
  • Member since 2018

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

-> We have developed 3 lightning components and added that to lightning Record pages.
Even though the form factor is desktop and phone for all these components and pages, it doesn't show up on the iPad.
 
-> Similarly In the apps section, these components don't come up as tabs/apps.
 
-> Is there any Specific reason, for these components to not show up on the iPad?
Note: This is visible on iPhone
 
-> Apparently we have created  App pages that show up on iPad but not the record details page.
 
-> Is there any workaround for this issue? , else I am missing any configuration stuff that needs to be done to make components visible in IPad.
/**************************
* File Name     : CreateOpportunityService 
* Description   : Webservice class for creating opportunity. 
* =========================================================================== 
* Ver Date        Author                                     Modification 
* --- ---- ------ ---------------- --------------------------------------- 
* 1.0 27-Feb-2020  Kumar                              Created
*************************/ 

@RestResource(urlMapping='/opportunities')
global class CreateOpportunityService {
    public static string jsonString = '';
    @HttpPost
    global  static void Assignment(){
        RestRequest request = RestContext.request;  
        RestResponse response = RestContext.response;
        if( jsonString == '') 
        {
            Blob body = request.requestBody;
            jsonstring = body.toString();
            system.debug('.....jsonstring ...'+jsonstring);
        }
        List<JSON2Apex> recordList= (List<JSON2Apex>) System.JSON.deserialize(jsonstring, List<JSON2Apex>.class);
        system.debug('<<<apexRecords'+recordList); 
        
        
        Set<string> emailSet=new Set<String>();
        Set<String> phoneSet=new Set<String>();
        Set<String> accountIds=new Set<String>();
        Set<Integer> pids=new Set<Integer>();   
        Map<string,contact> conEmailMap=new Map<String,Contact>();
        Map<String,JSON2Apex> conJSON2ApexMap=new Map<String,JSON2Apex>();
        Map<String,list<contact>> AccountToContactMap = new Map<String,list<contact>>();
        Map<String,opportunity> OpportunityMap = new Map<String,opportunity>();
        
        Map<String,Opportunity> accOppMap=new Map<String,Opportunity>();
        List<contact> contacts=new List<contact>();
        List<Opportunity> opportunities=new List<Opportunity>();
        List<account> accounts=new List<account>();
        String result = 'Success';
        Date CloseDt = Date.today()+7;
        String Stage_Name ='Open';
        
        for(JSON2Apex js:recordList){
            if(js.email!=null){
                emailSet.add(js.email);
            }
            else if(js.phone!=null){
                phoneSet.add(js.phone);
            }
        }
        
        system.debug('<<<emailSet'+emailSet);
        system.debug('<<<phoneSet'+phoneSet);

        List<Contact> conList=[SELECT Id,firstName,lastName,Email,Phone,accountId from Contact where email IN :emailSet OR phone IN :phoneSet];
        System.debug('<<<conList'+conList);
        
        if(conList.size()>0){
            for(Contact con:conList){
                conEmailMap.put(con.email,con);
                if(con.email==null){
                    conEmailMap.put(con.phone,con);
                }
                accountIds.add(con.accountId);
            }
            List<Account> accList=[SELECT Id,name,(SELECT id,pid__c,accountId FROM opportunities) from account where id in :accountIds];
            for(account acc:accList){
                for(opportunity opp:acc.opportunities){
                    OpportunityMap.put(opp.accountId,opp);
                }
            }
        }
        
        for(JSON2Apex jsn : recordList){
            String accountId='';
            if(conEmailMap.get(jsn.email)!=null || conEmailMap.get(jsn.phone)!=null){
                if(conEmailMap.get(jsn.email)!=null){
                    accountId= conEmailMap.get(jsn.email).accountId;
                }else{
                    accountId= conEmailMap.get(jsn.phone).accountId;
                }
                if(accountId!=null){
                    if(OpportunityMap.get(accountId)!=null){
                        if(jsn.pid==OpportunityMap.get(accountId).pid__c){
                            //Update opportunity - Not Clear what to Update
                        }
                        else{
                            Opportunity opp=new opportunity();
                            opp.pid__c=jsn.pid;
                            opp.name=jsn.fname+jsn.lname+jsn.pid;
                            opp.accountId=conEmailMap.get(jsn.email).accountid;
                            opp.CloseDate = CloseDt;
                            opp.StageName =Stage_Name;
                            opportunities.add(opp);
                        }
                        
                    }
                }
                
            }
            else{
                Account acc=new Account();
                acc.name= jsn.fname+jsn.lname;
                accounts.add(acc);  
                
                Contact con=new Contact();
                con.Email = jsn.email;
                con.Phone = jsn.Phone;
                con.FirstName = jsn.fname;
                con.LastName = jsn.lname;
                contacts.add(con);
                
                opportunity opp= new opportunity();
                opp.Name = jsn.fname+jsn.lname + jsn.pid ;
                opp.pid__c=jsn.pid;
                opp.CloseDate = CloseDt;
                opp.StageName =Stage_Name;
                opportunities.add(opp);
            }
        }
        if(!accounts.isEmpty()){
            try{
                insert accounts;
            }catch(Exception e){
                result = e.getMessage();
            }
        }
        
        for(Account accTemp : accounts){
            for(contact con :contacts){
                con.accountid = accTemp.id;
            }
        }
        
        for(Account accTemp : accounts){
            for(opportunity opp :opportunities){
                opp.accountid = accTemp.id;
            }
        }
        if(!contacts.isEmpty()){
            try{
                insert contacts;
            }catch(exception e){
                result = e.getMessage();
            }
        }
        
        if(!opportunities.isEmpty()){
            try{
                insert opportunities;
            }catch(exception e){
                result = e.getMessage();
            }
        }
        
    }
    public class JSON2Apex{
        public String pid;
        public String email;
        public String phone;
        public String fname;
        public String lname;
    }
}

 
Hi,

-> We have developed 3 lightning components and added that to lightning Record pages.
Even though the form factor is desktop and phone for all these components and pages, it doesn't show up on the iPad.
 
-> Similarly In the apps section, these components don't come up as tabs/apps.
 
-> Is there any Specific reason, for these components to not show up on the iPad?
Note: This is visible on iPhone
 
-> Apparently we have created  App pages that show up on iPad but not the record details page.
 
-> Is there any workaround for this issue? , else I am missing any configuration stuff that needs to be done to make components visible in IPad.
/**************************
* File Name     : CreateOpportunityService 
* Description   : Webservice class for creating opportunity. 
* =========================================================================== 
* Ver Date        Author                                     Modification 
* --- ---- ------ ---------------- --------------------------------------- 
* 1.0 27-Feb-2020  Kumar                              Created
*************************/ 

@RestResource(urlMapping='/opportunities')
global class CreateOpportunityService {
    public static string jsonString = '';
    @HttpPost
    global  static void Assignment(){
        RestRequest request = RestContext.request;  
        RestResponse response = RestContext.response;
        if( jsonString == '') 
        {
            Blob body = request.requestBody;
            jsonstring = body.toString();
            system.debug('.....jsonstring ...'+jsonstring);
        }
        List<JSON2Apex> recordList= (List<JSON2Apex>) System.JSON.deserialize(jsonstring, List<JSON2Apex>.class);
        system.debug('<<<apexRecords'+recordList); 
        
        
        Set<string> emailSet=new Set<String>();
        Set<String> phoneSet=new Set<String>();
        Set<String> accountIds=new Set<String>();
        Set<Integer> pids=new Set<Integer>();   
        Map<string,contact> conEmailMap=new Map<String,Contact>();
        Map<String,JSON2Apex> conJSON2ApexMap=new Map<String,JSON2Apex>();
        Map<String,list<contact>> AccountToContactMap = new Map<String,list<contact>>();
        Map<String,opportunity> OpportunityMap = new Map<String,opportunity>();
        
        Map<String,Opportunity> accOppMap=new Map<String,Opportunity>();
        List<contact> contacts=new List<contact>();
        List<Opportunity> opportunities=new List<Opportunity>();
        List<account> accounts=new List<account>();
        String result = 'Success';
        Date CloseDt = Date.today()+7;
        String Stage_Name ='Open';
        
        for(JSON2Apex js:recordList){
            if(js.email!=null){
                emailSet.add(js.email);
            }
            else if(js.phone!=null){
                phoneSet.add(js.phone);
            }
        }
        
        system.debug('<<<emailSet'+emailSet);
        system.debug('<<<phoneSet'+phoneSet);

        List<Contact> conList=[SELECT Id,firstName,lastName,Email,Phone,accountId from Contact where email IN :emailSet OR phone IN :phoneSet];
        System.debug('<<<conList'+conList);
        
        if(conList.size()>0){
            for(Contact con:conList){
                conEmailMap.put(con.email,con);
                if(con.email==null){
                    conEmailMap.put(con.phone,con);
                }
                accountIds.add(con.accountId);
            }
            List<Account> accList=[SELECT Id,name,(SELECT id,pid__c,accountId FROM opportunities) from account where id in :accountIds];
            for(account acc:accList){
                for(opportunity opp:acc.opportunities){
                    OpportunityMap.put(opp.accountId,opp);
                }
            }
        }
        
        for(JSON2Apex jsn : recordList){
            String accountId='';
            if(conEmailMap.get(jsn.email)!=null || conEmailMap.get(jsn.phone)!=null){
                if(conEmailMap.get(jsn.email)!=null){
                    accountId= conEmailMap.get(jsn.email).accountId;
                }else{
                    accountId= conEmailMap.get(jsn.phone).accountId;
                }
                if(accountId!=null){
                    if(OpportunityMap.get(accountId)!=null){
                        if(jsn.pid==OpportunityMap.get(accountId).pid__c){
                            //Update opportunity - Not Clear what to Update
                        }
                        else{
                            Opportunity opp=new opportunity();
                            opp.pid__c=jsn.pid;
                            opp.name=jsn.fname+jsn.lname+jsn.pid;
                            opp.accountId=conEmailMap.get(jsn.email).accountid;
                            opp.CloseDate = CloseDt;
                            opp.StageName =Stage_Name;
                            opportunities.add(opp);
                        }
                        
                    }
                }
                
            }
            else{
                Account acc=new Account();
                acc.name= jsn.fname+jsn.lname;
                accounts.add(acc);  
                
                Contact con=new Contact();
                con.Email = jsn.email;
                con.Phone = jsn.Phone;
                con.FirstName = jsn.fname;
                con.LastName = jsn.lname;
                contacts.add(con);
                
                opportunity opp= new opportunity();
                opp.Name = jsn.fname+jsn.lname + jsn.pid ;
                opp.pid__c=jsn.pid;
                opp.CloseDate = CloseDt;
                opp.StageName =Stage_Name;
                opportunities.add(opp);
            }
        }
        if(!accounts.isEmpty()){
            try{
                insert accounts;
            }catch(Exception e){
                result = e.getMessage();
            }
        }
        
        for(Account accTemp : accounts){
            for(contact con :contacts){
                con.accountid = accTemp.id;
            }
        }
        
        for(Account accTemp : accounts){
            for(opportunity opp :opportunities){
                opp.accountid = accTemp.id;
            }
        }
        if(!contacts.isEmpty()){
            try{
                insert contacts;
            }catch(exception e){
                result = e.getMessage();
            }
        }
        
        if(!opportunities.isEmpty()){
            try{
                insert opportunities;
            }catch(exception e){
                result = e.getMessage();
            }
        }
        
    }
    public class JSON2Apex{
        public String pid;
        public String email;
        public String phone;
        public String fname;
        public String lname;
    }
}

 
Hi there, 

I'm quite stuck here. 
I've written a test class for my batch but it doesn't appears to be running. It stays at 0% :( 

I'm missing something but don't know what. 

Can someone help me figure it out? 

Here is my batch class : 
global class BatchUpdateAllLeads implements Database.Batchable <SObject> {
//START METHOD
    global Database.QueryLocator start(Database.BatchableContext bc){
        String Query='Select id,TECH_Update__c from Lead where TECH_Update__c=false AND Converted=false ' ;
        return Database.getQueryLocator(Query);
            }
//EXECUTE METHOD
    global void execute(Database.BatchableContext bc, List<Lead> scope){
        for(Lead l: scope){
            l.TECH_Update__c = true;
        }
        update scope;
    }
//FINISH METHOD
    global void finish(Database.BatchableContext bc){
        Id job= bc.getJobId();
        System.debug(job);
    }
}

And this is my attemp of writting a proper test class :( 
@istest
private class BatchUpdateAllLeads_TEST {
    @istest
    static void testAcc(){
        List<Lead> l = new List<Lead>();
        Lead l1 = new Lead(Company	='BTP',LastName = 'Test',SIRET__c='12659991955626',Numero_d_ordre__c='9999-99-99',Region_GRDF__c='Ile de France',Tech_Update__c=false,IsConverted=false);
        l.add(l1);

        Lead l2= new Lead(Company	='Comp',LastName = 'Test2',SIRET__c='12659991955687',Numero_d_ordre__c='1111-99-99',Region_GRDF__c='Ile de France',Tech_Update__c=false, IsConverted=true);
        l.add(l2);

        Lead l3= new Lead(Company	='Agny', LastName = 'Test3', SIRET__c='19959991988687', Numero_d_ordre__c='1111-99-11', Region_GRDF__c='Ile de France', Tech_Update__c=true,IsConverted=true);
        l.add(l3);
        insert l;
   
    Test.startTest();
    BatchUpdateAllLeads ap= new BatchUpdateAllLeads();
    Id jobid= Database.executeBatch(ap);
    Test.stopTest();
    }
}

Ty very much for your help