• m 10
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 13
    Questions
  • 4
    Replies
Hi team,
how too write trigger for below scenario i am new to salesforce please help me
"A case can’t be closed if it is owned by the Integration User or a by a queue that is not the Closed Cases Email Received Queue."
  • December 30, 2021
  • Like
  • 0
Hi Team ,
Could you please help me below apex batch job need to run every minute
but no lock it's executng every 1hour please find below screenshot
User-added image
global class ServiceClaimBatchimplements Database.Batchable<SObject>, Database.AllowsCallouts, Database.Stateful{

    private  void rescheduleBurstSMSResponse(){
        try{
        Datetime dt = system.now().addMinutes(1);          
        String day = string.valueOf(system.now().day());
        String month = string.valueOf(system.now().month());
        String hour = string.valueOf(system.now().hour());
        String minute = string.valueOf(system.now().minute());
        String second = string.valueOf(system.now().second());
        String year = string.valueOf(system.now().year());
        
        String cronExpression = '' + dt.second() + ' ' + dt.minute() + ' ' + dt.hour() + ' ' + dt.day() + ' ' + dt.month() + ' ? ' + dt.year();
        String strSchedule = '0 ' + minute + ' ' + hour + ' ' + day + ' ' + month + ' ?' + ' ' + year;
 
            
            if(Test.isRunningTest()) {
            //This will throw Divide by 0 error and code will move to catch block
            Integer divideError = 123/0;
        }
                System.schedule(cronExpression, strSchedule, new ScheduleServiceClaim());
        }catch(Exception ex){
            System.debug(ex);
            System.debug(ex.getMessage());
            System.debug(ex.getLineNumber());
        }
    }


 ...........................................................
global class ScheduleServiceClaim implements Schedulable {
    global void execute(SchedulableContext sc){
        Database.executeBatch(new ServiceClaimBatch());
    }
}

Will appricate as best answer please help me it is killing my head 
  • November 03, 2020
  • Like
  • 0
Hi Team,
Pleasehelp me below class need to write apex class.
we will appricate baest answer
Apex class:
   global static String setExperienceId(String expId) {    
        // Return null if there is no error, else it will return the error message 
        system.debug('>>>expId>>>'+expId);
        try {
            if (expId != null) {
                Site.setExperienceId(expId);               
            }
            return null; 
        } catch (Exception ex) {
            return ex.getMessage();            
        }        
    } 
 
  • June 30, 2020
  • Like
  • 0
how ot write below component contoller and helpr for lighting button in component please help me

<button class="slds-button slds-button_neutral" >
                                    <lightning:icon class="slds-button__icon slds-button__icon_left" iconName="utility:refresh" size="x-small" alternativeText="Refresh" />
                                        Refresh
                                    </button>
  • February 28, 2020
  • Like
  • 0
when page is loading how to put image in place of spinner anybody worked could you please share lightnig component and how to use this component into another component

<aura:component implements="flexipage:availableForAllPageTypes" access="global">
    <aura:attribute type="Integer" name="Logos"/>
    <aura:attribute name="width" type="Integer" default="32" />
    <aura:attribute name="height" type="Integer" default="32" />
    <aura:attribute name="showimage" type="Boolean" default ="false"/>
    <aura:handler event="aura:waiting" action="{!c.showimages}"/>
    <aura:if isTrue="{v.showimage}"> 
    <div aura:id="showimageId" class="slds-spinner_container">
         <div class="slds-spinner--brand  slds-spinner slds-spinner--large slds-is-relative" role="alert">
         <span class="slds-assistive-text">Loading</span>
         <div class="slds-spinner__dot-a"></div>
         <div class="slds-spinner__dot-b"></div>
       </div>
       </div>
    </aura:if>
    <aura:handler name="init" align="center" value="{!this}" action="{!c.doInit}"/>
    <div class="logo cVGA_Loadingimage" data-aura-rendered-by="6:0" data-aura-class="cVGA_Loadingimage" style="
   height: 100vh;
   position: relative;
">
        <img src="/resource/1528440018000/vwlogo" data-aura-rendered-by="7:0" style="
   position: absolute;
   /* margin: auto; */
   left: 40%;
   right: -40%;
   top: 40%;
   bottom: -40%;
">
        </img>
    </div>
    </aura:component>
  • February 13, 2020
  • Like
  • 0
 <ui:InputTextArea value="{!mon.MonthDescription}" class="vw_Plan_blu_bodr" aura:id = "Testdes" disabled="{!v.isDisabled == false}" />
                            
                           
 <ui:InputText value="{!mon.MonthDescription}" class="vw_Plan_blu_bodr" aura:id = "Testdes1" disabled="{!v.isDisabled == True}" />
                            
  • February 07, 2020
  • Like
  • 0
i have create a survey  for external users with out login they are going to complete that survey ,now i am scenario is i need t o post that link in facebook unfortunately it is not working could you please help me on this scenario
  • August 07, 2019
  • Like
  • 0
Hi team ,
Could you please help me linkedin integration with examples and class ,

need to integrate linkedin and salesforce integration
  • July 26, 2019
  • Like
  • 0
need to write mulitple error messages below trigger for multiple fields
Note:suppose if enter name it is throwing error as duplicate for next i am entering email also error message need to display as duplicate same as like phone also

trigger AvoidDuplicate on Contact (before insert)
{    
    
    set<string> newNameSet = new set<string>();
    
    set<string> newEmailSet = new set<string>();
    set<string> newPhoneSet = new set<string>();
    set<string> dbNameSet = new set<string>();
    
    set<string> dbEmailSet = new set<string>();
    set<string> dbPhoneSet = new set<string>();
    
    for(Contact con : trigger.new){
        
        newNameSet.add(con.LastName);
        
        newEmailSet.add(con.Email);
        newPhoneSet.add(con.Phone);
        
    }
    
    List<contact> bcon = [select id, LastName,Phone, email from contact where email IN: newEmailSet OR LastName IN: newNameSet OR Phone IN: newPhoneSet];
   for(Contact dbcon:Trigger.new)
    {
        
        dbNameSet.add(dbcon.LastName);
        
        dbEmailSet.add(dbcon.Email);
        dbPhoneSet.add(dbcon.Phone);
    }
    
    for(contact con1 : trigger.new){        
        if(dbNameSet.contains(con1.LastName) && dbEmailSet.Contains(con1.Email) && dbPhoneSet.Contains(con1.Phone))
        {
            con1.addError('You are inserting Duplicate LastName');
            con2.addError('You are inserting Duplicate Email');
            con3.addError('You are inserting Duplicate Phone');
        }
        
        
    }
    
}
  • June 27, 2019
  • Like
  • 0
hi team ,
Below error message when i am deplpoyiong total copy from my system .
Error: Invalid Data.  Review all error messages below to correct your data. Apex trigger AvoidDuplicate caused an unexpected exception, contact your administrator: AvoidDuplicate: execution of BeforeInsert caused by: System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Contact.Phone: Trigger.AvoidDuplicate: line 27, column 1
  • June 26, 2019
  • Like
  • 0
when i am running below vf page code i am getting error message ,in apex class i am getting response but i am not able to insert values dynamically into the object in class line no 21 it's throing an error
note:Argument cannot be null.
An unexpected error has occurred. Your development organization has been notified.
class:
global class SampleReport {
    public String body{set;get;}
    public list<integer> mylist{set;get;}
    public List<ReportFields> consolewrapperlist{get;set;}
   
    public  SampleReport(){                        
             
        Httprequest req=new Httprequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
        string url='https://canvasjs.com/data/gallery/javascript/daily-sales-data.json';
        req.setEndpoint(url);      
        req.setHeader('Content-type','application/json');           
        req.setMethod('GET');
        res = http.send(req);
        system.debug('=========res>>>'+res);
        consolewrapperlist=new List<ReportFields>();
        if(res.getstatusCode() == 200 && res.getbody() != null){
            string body=res.getbody().replaceAll('\n','').replaceAll('\r','');
            system.debug('==========>>>body....>'+body);
            System.JSONParser jp=json.createParser(res.getbody());
            system.debug('==.>>>jp'+jp);
 
            while (jp.nextToken() != null) {
              
                // find the stock part of the response
                if (jp.getCurrentToken() == JSONToken.START_OBJECT) {
                    // parse the stock response and form the response for this controller
                    ReportFields responseObject = (ReportFields)jp.readValueAs(ReportFields.class);
                    Daily_sales_Data__c sd=new Daily_sales_Data__c();
                    sd.date__c=Date.valueOf(responseObject.dates);
                    sd.units__c=Integer.valueOf(responseObject.units);
                    insert sd;                   
                    system.debug('Hello There ' +sd);
                    // return the serialized response
                    //return JSON.serialize(new PackagedReturnItem(returnItems));
                      consolewrapperlist.add(responseObject);
                    system.debug('Hello There ' +consolewrapperlist);
                }
            }
            
               
           
        }else{
            ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Data not find');
           ApexPages.addMessage(myMsg);
        }
       
       
    }
    public class ReportFields
    {
        public String dates;
        public string units;
         public ReportFields(String dates, String units) {
            this.dates = dates;
            this.units = units;
        }
      
      
    }
}
Vf page:
<apex:page controller="SampleReport">
    <apex:form >
        <apex:pageBlock >
          
           
            <apex:pageBlockTable value="{!consolewrapperlist}" var="wrap" width="100%">
               
               
                <apex:column headerValue="date" value="{!wrap.rdate}"/>
                <apex:column headerValue="units" value="{!wrap.runits}"/>
               
               
               
            </apex:pageBlockTable>
           
        </apex:pageBlock>
    </apex:form>
   
</apex:page>
                
  • June 01, 2019
  • Like
  • 0
i have one object name is Reportconfig(this is my custom object name:Reportconfig) in that below  object field i am mentioned after hting that url json need to save
Report Name
Report Source Url
RID
public class reportcon{
    public String apiKey {set;get;}
    public String jsonResult{Set;get;}
    public void getReport(){
        Map<String,reportconfig__c> myMap=reportconfig.getAll();
        reportconfig__c ws=myMap.get('Report Name');
        String url='https://canvasjs.com/data/gallery/javascript/daily-sales-data.json';
        Http p=new Http();
        HttpRequest request =new HttpRequest();
        request.setEndPoint(url);
        request.setMethod('GET');
        HttpResponse response=p.send(request);
        System.debug('====>>'+response);
        jsonResult=response.getBody();
    }
}
 
  • May 23, 2019
  • Like
  • 0
Hi team,
how too write trigger for below scenario i am new to salesforce please help me
"A case can’t be closed if it is owned by the Integration User or a by a queue that is not the Closed Cases Email Received Queue."
  • December 30, 2021
  • Like
  • 0
@isTest
public class TestDataFactory {
   
    public static testMethod void testdata_for_manipulateDataForInviteBlast(){
        insert new Pardot_Settings__c(Name = 'Pardot User Key', User_Key__c ='xxxxxxxxxxxxxxxxxxx');
        
        Test.setMock(HttpCalloutMock.class, new MockHttpResponseGeneratorpost());
        Account a = new Account();
        
        a.Name = 'Test Account';
        Insert a;
       
        Contact con1 = new Contact();
        con1.FirstName='Seema';
        con1.LastName= 'singh';
        con1.AccountId = a.Id;        
        con1.Email='seemax1.singh@accelerize360.com';
        insert con1; 
        
        Analyst__c an= new Analyst__c();
        an.Name='asdf122345';
        an.Order_of_Precedence__c = '1';
        insert an;
        
        
        Custom_Event__c cEvent = new Custom_Event__c();
        cEvent.name = 'testingEvent';
        cEvent.CAT_external_event_name__c = 'testing External Event';
        cEvent.Type_of_Meeting__c = 'Analyst Marketing';
        cEvent.Start_Date__c = DateTime.Now().AddDays(10);
        cEvent.End_Date__c = DateTime.Now().AddDays(13);
        insert cEvent;
        
        Campaign com = new Campaign();
        com.Analyst__c=an.id;
        com.Related_Event__c = cEvent.Id;
        com.Name='test';
        insert com;
        
        CampaignMember cm = new CampaignMember();
        cm.ContactId=con1.id;
        cm.CampaignId=com.id;
        cm.CampaignId = com.id;
        insert cm;
        
         EmailMessage incomingMail = new EmailMessage();
         incomingMail.fromaddress='test@email.com';
         incomingMail.toAddress = 'test@test.com';
         incomingMail.subject = ' Test Message';
         incomingMail.TextBody= 'This is the message body ';
         incomingMail.RelatedToId = cEvent.id;
         insert incomingMail ;       
        
    }
}

here I'm not testing integration directly, but it was like whenever contact is created it happens, so its making callout indirectly that's why I have to use more class. 

here when I run the test I'm getting error:

System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out

and when I remove emailmessage record insertion part its working. but I need that
 <ui:InputTextArea value="{!mon.MonthDescription}" class="vw_Plan_blu_bodr" aura:id = "Testdes" disabled="{!v.isDisabled == false}" />
                            
                           
 <ui:InputText value="{!mon.MonthDescription}" class="vw_Plan_blu_bodr" aura:id = "Testdes1" disabled="{!v.isDisabled == True}" />
                            
  • February 07, 2020
  • Like
  • 0
need to write mulitple error messages below trigger for multiple fields
Note:suppose if enter name it is throwing error as duplicate for next i am entering email also error message need to display as duplicate same as like phone also

trigger AvoidDuplicate on Contact (before insert)
{    
    
    set<string> newNameSet = new set<string>();
    
    set<string> newEmailSet = new set<string>();
    set<string> newPhoneSet = new set<string>();
    set<string> dbNameSet = new set<string>();
    
    set<string> dbEmailSet = new set<string>();
    set<string> dbPhoneSet = new set<string>();
    
    for(Contact con : trigger.new){
        
        newNameSet.add(con.LastName);
        
        newEmailSet.add(con.Email);
        newPhoneSet.add(con.Phone);
        
    }
    
    List<contact> bcon = [select id, LastName,Phone, email from contact where email IN: newEmailSet OR LastName IN: newNameSet OR Phone IN: newPhoneSet];
   for(Contact dbcon:Trigger.new)
    {
        
        dbNameSet.add(dbcon.LastName);
        
        dbEmailSet.add(dbcon.Email);
        dbPhoneSet.add(dbcon.Phone);
    }
    
    for(contact con1 : trigger.new){        
        if(dbNameSet.contains(con1.LastName) && dbEmailSet.Contains(con1.Email) && dbPhoneSet.Contains(con1.Phone))
        {
            con1.addError('You are inserting Duplicate LastName');
            con2.addError('You are inserting Duplicate Email');
            con3.addError('You are inserting Duplicate Phone');
        }
        
        
    }
    
}
  • June 27, 2019
  • Like
  • 0
when i am running below vf page code i am getting error message ,in apex class i am getting response but i am not able to insert values dynamically into the object in class line no 21 it's throing an error
note:Argument cannot be null.
An unexpected error has occurred. Your development organization has been notified.
class:
global class SampleReport {
    public String body{set;get;}
    public list<integer> mylist{set;get;}
    public List<ReportFields> consolewrapperlist{get;set;}
   
    public  SampleReport(){                        
             
        Httprequest req=new Httprequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
        string url='https://canvasjs.com/data/gallery/javascript/daily-sales-data.json';
        req.setEndpoint(url);      
        req.setHeader('Content-type','application/json');           
        req.setMethod('GET');
        res = http.send(req);
        system.debug('=========res>>>'+res);
        consolewrapperlist=new List<ReportFields>();
        if(res.getstatusCode() == 200 && res.getbody() != null){
            string body=res.getbody().replaceAll('\n','').replaceAll('\r','');
            system.debug('==========>>>body....>'+body);
            System.JSONParser jp=json.createParser(res.getbody());
            system.debug('==.>>>jp'+jp);
 
            while (jp.nextToken() != null) {
              
                // find the stock part of the response
                if (jp.getCurrentToken() == JSONToken.START_OBJECT) {
                    // parse the stock response and form the response for this controller
                    ReportFields responseObject = (ReportFields)jp.readValueAs(ReportFields.class);
                    Daily_sales_Data__c sd=new Daily_sales_Data__c();
                    sd.date__c=Date.valueOf(responseObject.dates);
                    sd.units__c=Integer.valueOf(responseObject.units);
                    insert sd;                   
                    system.debug('Hello There ' +sd);
                    // return the serialized response
                    //return JSON.serialize(new PackagedReturnItem(returnItems));
                      consolewrapperlist.add(responseObject);
                    system.debug('Hello There ' +consolewrapperlist);
                }
            }
            
               
           
        }else{
            ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Data not find');
           ApexPages.addMessage(myMsg);
        }
       
       
    }
    public class ReportFields
    {
        public String dates;
        public string units;
         public ReportFields(String dates, String units) {
            this.dates = dates;
            this.units = units;
        }
      
      
    }
}
Vf page:
<apex:page controller="SampleReport">
    <apex:form >
        <apex:pageBlock >
          
           
            <apex:pageBlockTable value="{!consolewrapperlist}" var="wrap" width="100%">
               
               
                <apex:column headerValue="date" value="{!wrap.rdate}"/>
                <apex:column headerValue="units" value="{!wrap.runits}"/>
               
               
               
            </apex:pageBlockTable>
           
        </apex:pageBlock>
    </apex:form>
   
</apex:page>
                
  • June 01, 2019
  • Like
  • 0
i have one object name is Reportconfig(this is my custom object name:Reportconfig) in that below  object field i am mentioned after hting that url json need to save
Report Name
Report Source Url
RID
public class reportcon{
    public String apiKey {set;get;}
    public String jsonResult{Set;get;}
    public void getReport(){
        Map<String,reportconfig__c> myMap=reportconfig.getAll();
        reportconfig__c ws=myMap.get('Report Name');
        String url='https://canvasjs.com/data/gallery/javascript/daily-sales-data.json';
        Http p=new Http();
        HttpRequest request =new HttpRequest();
        request.setEndPoint(url);
        request.setMethod('GET');
        HttpResponse response=p.send(request);
        System.debug('====>>'+response);
        jsonResult=response.getBody();
    }
}
 
  • May 23, 2019
  • Like
  • 0