• SUMIT BANERJEE
  • NEWBIE
  • 60 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 15
    Questions
  • 11
    Replies
2017-02-02T15:35:00.000+0000

I want to change into Tuesday, February 2nd at 10:30am

Please help on this
 
Hi, I generate class as per JSON response, now I am facing issue Like unexpected token: '-' at line 18 and 30, How to resolve this issue and the  API name is access-token, I can't change that


public class TokenResponse {
    public static void consumeObject(JSONParser parser) {
        Integer depth = 0;
        do {
            JSONToken curr = parser.getCurrentToken();
            if (curr == JSONToken.START_OBJECT || 
                curr == JSONToken.START_ARRAY) {
                depth++;
            } else if (curr == JSONToken.END_OBJECT ||
                curr == JSONToken.END_ARRAY) {
                depth--;
            }
        } while (depth > 0 && parser.nextToken() != null);
    }

    public String type_Z {get;set;} 
    public Integer state {get;set;} 
    public String access-token {get;set;} 

    public TokenResponse(JSONParser parser) {
        while (parser.nextToken() != JSONToken.END_OBJECT) {
            if (parser.getCurrentToken() == JSONToken.FIELD_NAME) {
                String text = parser.getText();
                if (parser.nextToken() != JSONToken.VALUE_NULL) {
                    if (text == 'type') {
                        type_Z = parser.getText();
                    } else if (text == 'state') {
                        state = parser.getIntegerValue();
                    } else if (text == 'accesstoken') {
                        access-token = parser.getText();
                    } else {
                        System.debug(LoggingLevel.WARN, 'Root consuming unrecognized property: '+text);
                        consumeObject(parser);
                    }
                }
            }
        }
    }
    
    
    public static TokenResponse parse(String json) {
        return new TokenResponse(System.JSON.createParser(json));
    }
}
Hi, I have Create REST API class by hitting rest API class using an anonymous window, I am getting response JSON result.
Currently, I am using anonymous window for sending the Input Question, Now I want to map Case object field for Sending Question.

Could anyone guide on this?
This is the class which I have Written, I want to Send data Input data using Case object to this class.
public class SendQuestion{
   public SendQuestion(){}
    
    public void SendQuestionMethod(String inputQue,String dialogId,String accessToken ) {
        HttpResponse res=new HttpResponse();
        HttpRequest req = new HttpRequest(); 

        String jsonsString = '{'+
        '    \"input\" :' +'\"'+inputQue+'\",'+
        '    \"conversation-id\" : null, '+
        '    \"dialog-id\":' +'\"'+dialogId+'\",'+
        '    \"channel\": \"web\",'+
        '    \"access-token\":'+ '\"'+accessToken+'\"'+
        '}';
        System.debug('jsonsString'+jsonsString);
         
        req.setBody(jsonsString);
        req.setMethod('POST');
        req.setEndpoint('https://dialog-----------------');
        req.setHeader('Content-Type', 'application/json');
        req.setTimeout(120000);     
          
        try {
        Http h = new Http();  
        res= h.send(req);
        System.debug('res::>'+res.getBody());      
        } catch(System.CalloutException e) {
            if (res.getStatus()=='OK') {
            system.debug(res.toString());
            } else {
            System.debug('ERROR: '+ e);
            system.debug(res.toString());
            }     
        }
    }
}

Thanks, Sumit
Hi I have written batch class to update stage field of opportunity as per close date but when I run my batch class it will be updating close date also.
How to prevent that can you guide where I did mistake in my code :

global class batchOpportunityUpdate implements Database.Batchable <sObject>{
    
    date dt1 = system.today().addDays(+30);
    date dt2 = system.today().addDays(+120);
    date dt3 = system.today().addDays(+182);
    Id oppRecordTypeId = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('New Rec3 Type').getRecordTypeId(); 
    
    
    global Database.QueryLocator start(Database.BatchableContext BC){
        
        string query = 'SELECT Id,CloseDate,StageName,RecordTypeId FROM Opportunity Where RecordTypeId =:oppRecordTypeId ';
        return Database.getQueryLocator(query);
    }
    global void execute(Database.BatchableContext BC, List<Opportunity> scope){
            for(Opportunity opp : scope){
                if(opp.CloseDate <= dt1 && oppRecordTypeId == opp.RecordTypeId){
                System.debug('Record'+oppRecordTypeId +'dt1'+dt1);
                opp.StageName ='Qualification';
                }else if(opp.CloseDate <= dt2 && oppRecordTypeId == opp.RecordTypeId){
                    opp.StageName ='Needs Analysis';
                }else if(opp.CloseDate <= dt3 && oppRecordTypeId == opp.RecordTypeId){
                opp.StageName ='Closed Won';
                }
            }
            update scope;
            
    }
    global void finish(Database.BatchableContext BC){
            
    }
}


Thanks,
sumit
How to create automation rule that automatically changes Opportunity stages: 
Base On : 

If Opportunity CloseDate < month then Stage = 6 Month
If Opportunity CloseDate < month then Stage = 3 Month
If Opportunity CloseDate < month then Stage = 1 Month
 
Please check my trigger where I need to change for pass bulkifying issue.


trigger Noofcontacts on Contact (after insert,after delete) {
    
    Set<id>accid    =   new Set<id>();
    List<contact>contactlist =  new List<contact>();
    List<contact>listcon    =   new List<contact>();
    List<account>acclist    =   new List<account>();
    List<account>listacc    =   new List<account>();
    Map<id,integer>mapCount =   new Map<id,integer>();

    if(trigger.isinsert){
        for(contact con:trigger.new){
            accid.add(con.accountid);
        }
    }

    if (trigger.isdelete){
        for(contact con:trigger.old){
            accid.add(con.accountid);
        }
    }

    acclist=[SELECT id,name FROM account WHERE id in:accid];
    contactlist=[SELECT id,name,accountid FROM contact WHERE accountid in:accid];

    for(account acc:acclist){
        listcon.clear();
        for(contact c:contactlist){
            if(c.accountid==acc.id){
                listcon.add(c);
                mapCount.put(c.accountid,listcon.size());
            }
        }
    }

    if(acclist.size()>0){
        for(Account a:acclist){
            if(mapCount.get(a.id)==null)
                a.No_of_Contacts__c=0;
            else
                a.No_of_Contacts__c=mapCount.get(a.id);
                listacc.add(a);
        }
    }

    if(listacc.size()>0)
    update listacc;
}
global class LightningForgotPasswordController {

    public LightningForgotPasswordController() {

    }

    @AuraEnabled
    public static String forgotPassowrd(String username, String checkEmailUrl) {
        try {
            Site.forgotPassword(username);
            ApexPages.PageReference checkEmailRef = new PageReference(checkEmailUrl);
            if(!Site.isValidUsername(username)) {
                return Label.Site.invalid_email;
            }
            aura.redirect(checkEmailRef);
            return null;
        }
        catch (Exception ex) {
            return ex.getMessage();
        }
    }

}
public class AccContExt {

    private final Account account{get; set;}
    public AccContExt(ApexPages.StandardController controller) {
          
           this.account= (Account)controller.getRecord();

    }

}
Hi, 

I want to call lighting component page whenever a new account button will be press.

Thanks,
Sumit
Hi,
I have created a Component page on that page, I have create a next button, now I want when I press next button it will we call another component page .

Thanks, 
Sumit
I would like to pre-populate the account name for this record type with something so the user doesn’t have to be bothered with entering something there because it’s a required field. 
Hi, I have Create REST API class by hitting rest API class using an anonymous window, I am getting response JSON result.
Currently, I am using anonymous window for sending the Input Question, Now I want to map Case object field for Sending Question.

Could anyone guide on this?
This is the class which I have Written, I want to Send data Input data using Case object to this class.
public class SendQuestion{
   public SendQuestion(){}
    
    public void SendQuestionMethod(String inputQue,String dialogId,String accessToken ) {
        HttpResponse res=new HttpResponse();
        HttpRequest req = new HttpRequest(); 

        String jsonsString = '{'+
        '    \"input\" :' +'\"'+inputQue+'\",'+
        '    \"conversation-id\" : null, '+
        '    \"dialog-id\":' +'\"'+dialogId+'\",'+
        '    \"channel\": \"web\",'+
        '    \"access-token\":'+ '\"'+accessToken+'\"'+
        '}';
        System.debug('jsonsString'+jsonsString);
         
        req.setBody(jsonsString);
        req.setMethod('POST');
        req.setEndpoint('https://dialog-----------------');
        req.setHeader('Content-Type', 'application/json');
        req.setTimeout(120000);     
          
        try {
        Http h = new Http();  
        res= h.send(req);
        System.debug('res::>'+res.getBody());      
        } catch(System.CalloutException e) {
            if (res.getStatus()=='OK') {
            system.debug(res.toString());
            } else {
            System.debug('ERROR: '+ e);
            system.debug(res.toString());
            }     
        }
    }
}

Thanks, Sumit
Hi,
I have created a Component page on that page, I have create a next button, now I want when I press next button it will we call another component page .

Thanks, 
Sumit
Hi I have written batch class to update stage field of opportunity as per close date but when I run my batch class it will be updating close date also.
How to prevent that can you guide where I did mistake in my code :

global class batchOpportunityUpdate implements Database.Batchable <sObject>{
    
    date dt1 = system.today().addDays(+30);
    date dt2 = system.today().addDays(+120);
    date dt3 = system.today().addDays(+182);
    Id oppRecordTypeId = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('New Rec3 Type').getRecordTypeId(); 
    
    
    global Database.QueryLocator start(Database.BatchableContext BC){
        
        string query = 'SELECT Id,CloseDate,StageName,RecordTypeId FROM Opportunity Where RecordTypeId =:oppRecordTypeId ';
        return Database.getQueryLocator(query);
    }
    global void execute(Database.BatchableContext BC, List<Opportunity> scope){
            for(Opportunity opp : scope){
                if(opp.CloseDate <= dt1 && oppRecordTypeId == opp.RecordTypeId){
                System.debug('Record'+oppRecordTypeId +'dt1'+dt1);
                opp.StageName ='Qualification';
                }else if(opp.CloseDate <= dt2 && oppRecordTypeId == opp.RecordTypeId){
                    opp.StageName ='Needs Analysis';
                }else if(opp.CloseDate <= dt3 && oppRecordTypeId == opp.RecordTypeId){
                opp.StageName ='Closed Won';
                }
            }
            update scope;
            
    }
    global void finish(Database.BatchableContext BC){
            
    }
}


Thanks,
sumit
public class AccContExt {

    private final Account account{get; set;}
    public AccContExt(ApexPages.StandardController controller) {
          
           this.account= (Account)controller.getRecord();

    }

}
Hi, 

I want to call lighting component page whenever a new account button will be press.

Thanks,
Sumit
Hi,
I have created a Component page on that page, I have create a next button, now I want when I press next button it will we call another component page .

Thanks, 
Sumit
I would like to pre-populate the account name for this record type with something so the user doesn’t have to be bothered with entering something there because it’s a required field.