• Rajesh Singh 88
  • NEWBIE
  • 60 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 9
    Replies
I am working on a requirement where I have to create a button and from the modal/screen, search the territory and assign/relate to Account on submit/assign using lightning component.
I am new to lightning development , can anyone please help me on this.

Thanks!
Hi 

I am new to writting apex for integration. I have written the logic and it's working fine. Can someone please help me to write test class the below class as I am unable to do so. I have tried multiple times but the class is not getting covered.

@RestResource(urlMapping='/AccountBiilingDate/*')
global class AccountBiilingDateUpdateClass{
    @HttpPost 
    global static List<ResponseWrapper> updateAccBillDate(){
        RestRequest accBillDateRequest = RestContext.request;
        String jsonResponse = '';
        RestResponse res = RestContext.response;
        
        String requestBody = accBillDateRequest.requestBody.toString();
        
        List<AccountBiilingDate> accRecsReceived = (List<AccountBiilingDate>) JSON.deserialize(requestBody, List<AccountBiilingDate>.class);
        List<ResponseWrapper> wrperlist = new List<ResponseWrapper>();
        List<Account> accListToUpdt = new List<Account>();
        Set<Account> accSetToUpdate = new Set<Account>();
        
        for(AccountBiilingDate accBillDate : accRecsReceived){
            Account acc = new Account();
            acc.Id = Id.valueOf(accBillDate.ACC_ID);
            If(accBillDate.BILLDATE != ''){
                acc.Billing_Date__c = Date.valueOf(accBillDate.BILLDATE);
            }else{
                acc.Billing_Date__c = NULL;
            } 
            accSetToUpdate.add(acc);
        }
        accListToUpdt .addALL(accSetToUpdate);
    
        
        Database.SaveResult[] srList = database.update(accListToUpdt,false);
        
        for (Database.SaveResult sr : srList){
            if (sr.isSuccess()){
                jsonResponse = 'Successfully updated';
                res.responseBody = blob.valueOf(jsonResponse);
                wrperlist.add(new ResponseWrapper(sr.getId(),jsonResponse,200));
            }else {
                for(Database.Error err : sr.getErrors()) {
                    res.responseBody = Blob.valueOf(err.getMessage());
                    wrperlist.add(new ResponseWrapper(sr.getId(),err.getMessage(),400));
                }
            }
        }
        return wrperlist;
    }
    global class AccountBiilingDate{
        public String ACC_ID;  //Account Id
        public String BILLDATE;  //yyyy-mm-dd format
    }
}

----------------------------------------------------------------------------------

global class ResponseWrapper{
    public String Id ;
    public string Status;
    public Integer Statuscode;
    public ResponseWrapper(String Id, String statusMsg,Integer statusCode){
        this.Id  = Id;
        this.Status = statusMsg;
        this.Statuscode = statusCode;
    }
    
}
I am new to integration so need some help on my work.

I have a requirement to get the request from an external system and update the data in salesforce. I am able to successfully update the data and send the success response but I am unable to send the failed record Ids and the failed status message.

Below is the code which I have written:

@RestResource(urlMapping='/AccSlaExpireDate/*')
global class AccountSLAExpirationDateUpdate {
    @HttpPost 
    global static void updateAccSLAExpDate(){
        RestRequest accSlaDateRequest = RestContext.request;
        String jsonResponse = '';
        RestResponse res = RestContext.response;
        
        String requestBody = accSlaDateRequest.requestBody.toString();
        system.debug('requestBodyVal'+requestBody);
        List<accountSLAExpDate> accDateReceived = (List<accountSLAExpDate>) JSON.deserialize(requestBody, List<accountSLAExpDate>.class);
        System.debug('listSizeVal'+accDateReceived.size());
        List<Account> accListToUpdate = new List<Account>();
        
        for(accountSLAExpDate accDate : accDateReceived){
            Account acc = new Account();
            acc.Id = Id.valueOf(accDate.ACCOUNT_SOURCE_REF);
            If(accDate.SLAEXPDATE != ''){
                acc.SLAExpirationDate__c = Date.valueOf(accDate.SLAEXPDATE);
            }else{
                acc.SLAExpirationDate__c = NULL;
            } 
            accListToUpdate.add(acc);
        }
        
        Database.SaveResult[] srList = database.update(accListToUpdate,false);
        
        for (Database.SaveResult sr : srList){
            if (sr.isSuccess()){
                jsonResponse = '{"response": {"status": "Successfully updated"}}';
                res.responseBody = blob.valueOf(jsonResponse);
                return;
            }else {
                // Operation failed, so get all errors                
                for(Database.Error err : sr.getErrors()) {
                    System.debug('The following error has occurred.'+sr.getId());                    
                    System.debug(err.getStatusCode() + ': ' + err.getMessage());
                    System.debug('Account fields that affected this error: ' + err.getFields());
                }
            }
        }
    }
    global class accountSLAExpDate{
        public String ACCOUNT_SOURCE_REF;  //Account Id
        public String SLAEXPDATE;  //yyyy-mm-dd format
    }
}

I have tested with the below REST API service URI :

/services/apexrest/AccSlaExpireDate/

Payload: 
[
    {
      "ACCOUNT_SOURCE_REF": "0012x0000059fPD",
      "SLAEXPDATE": "2021-02-08"
    }
]

Can someone please help on how to send the failed record Ids and failed records status message as response back to the external system.
In my company the Financial Year starts from April - March. My requirement is When the Period__c ( picklist ) is updated to Quarter 1 then the Financial_Period__c is updated to FY21 - Q1.

The Financial_Period__c needs to be incremented based up on the Financial Year.

I am new to Apex , can someone please help me in this.

Period__c picklist values : 
Quarter 1
Quarter 2
Quarter 3
Quarter 4

Example  for FY21:

If the Period__c is updated to Quarter 2 the Financial_Period__c is updated to FY21 - Q2

If the Period__c is updated to Quarter 4 the Financial_Period__c is updated to FY21 - Q4

Similarly for FY22 :

If the Period__c is updated to Quarter 2 the Financial_Period__c is updated to FY22 - Q2

Similarly for FY24 :

If the Period__c is updated to Quarter 2 the Financial_Period__c is updated to FY24 - Q2

Thanks!
 
I have a requirement to update the child record fields when the lookup field(Segment_Id__c) is updated. The child record fields will be updated from the lookup obj's fields(parent's fields.)

Parent Object : Segment__c
Child Object : Case (Segment_Id__c lookup field on case obj)

Case.Comments__c = Segment__c.Comments__c
Case.Recognition_Date__c = Segment__c.Recognition_Date__c

I tried with record triggered flow(After save) but I am facing issues. Can anyone please help me on this as I am new to Salesforce and flows.
Chatter notification to Opportunity Team Members when Opportunity StageName = Commit 

Chatter message :
Hi Team Member 1, Team Member 2

This is to notify that the Opportunity Name(Hyperlink) is commited.

Thank You
OrderItem is the parent to Object A and Object B.

I want to update Type__c  on Object A (existing records) from Object B when the  Object B records get inserted with the Type__c.

I think I can leverage the OrderItem lookup on both the child objects to have a condition something like 
Trigger :- afterUpdate on Object B

If(objectA.OrderItem == objectB.OrderItem){
objectA.Type__c = objectB.Type__c
list.add(objectA); 
}
update list;

As I am bit new to apex not sure how to go ahead. Need some help on this.
Anytime the owner of the  Parent account is updated/changed, the userId of Child Account's :  Account Team Member should be updated.

Along with the update functionlity , I want when a new child account is created for the parent account automatically AccountTeamMember is inserted with the parent account's owner and TeamMemberRole = Account Manager.

Thanks,
Rajesh Singh
I have a requirement to show the 1st word in BOLD letter of sentences/line having multiple words which are the values of each radio button using Lightning Component.
Example: In the below example the first word is in BOLD
  • This is line 1
  • This is line 2
  • This is line 3  
I am new to Flows and having a hard time to implement the logic I am working on. I have a requirement to update the child records(object : Group Segment) picklist field to Status : 'Completed' when the parent record(object : Case) Status is 'Closed' using Flows.
Can someone please guide/help me on this.
I have the below 2 fields :
Weekdays__c (Multiselect picklist) which contains the values as below :
Monday
Tuesday
Wednesday
Thursday
Friday
ExpirationDate__c (Date) 
My requirement is whenever the picklist values are selected as Monday;Tuesday OR Tuesday;Wednesday;Friday with multiple combinations the date should fall within any of the selected weekdays from the multi-picklist else throw validation.

Example : User selected the Weekday valules as Monday;Tuesday and the selected date is not falling Monday or Tuesday then throw validation. As in the current month Monday is falling on 7, 14, 21 , 28 dates or same in the case of Tuesday so if the user selects date falling on Monday or Tuesday then allow to save the record.

I am a newbie to the sfdc world and I have tried in multiple ways to achieve but couldn't able to. 

For single value I was able to as below but with multiple combinations I wasn't able to do.
AND(INCLUDES(Weekdays__c, "Monday"),
MOD( ExpirationDate__c - DATE(1900, 1, 6), 7) <> 2)
I think this can be resolved using roll-up summary fields but my organization wants to go with Apex. I am a newbie to Apex. Can anyone please help me on this. I tried in Apex but i was able to update the Total Amount field with the sum amount value of quotelineitem related to a single quote , which will be completely wrong as quote is having masterdetail relationship with opportunity 

Objects/fields involved :
Opportunity (Total_Amount__c)
Quote : Masterdetail relationship with Opportunity
QuoteLineItem (Amount__c) : Masterdetail with Quote

What I excatly want to achieve is for example Opportunity is having 2 quotes and these quotes are having 3 quoteline items each , I want the sum of all the quotelineitems to be updated in the Total Amount field on Opportunity.


 
I am new to integration so need some help on my work.

I have a requirement to get the request from an external system and update the data in salesforce. I am able to successfully update the data and send the success response but I am unable to send the failed record Ids and the failed status message.

Below is the code which I have written:

@RestResource(urlMapping='/AccSlaExpireDate/*')
global class AccountSLAExpirationDateUpdate {
    @HttpPost 
    global static void updateAccSLAExpDate(){
        RestRequest accSlaDateRequest = RestContext.request;
        String jsonResponse = '';
        RestResponse res = RestContext.response;
        
        String requestBody = accSlaDateRequest.requestBody.toString();
        system.debug('requestBodyVal'+requestBody);
        List<accountSLAExpDate> accDateReceived = (List<accountSLAExpDate>) JSON.deserialize(requestBody, List<accountSLAExpDate>.class);
        System.debug('listSizeVal'+accDateReceived.size());
        List<Account> accListToUpdate = new List<Account>();
        
        for(accountSLAExpDate accDate : accDateReceived){
            Account acc = new Account();
            acc.Id = Id.valueOf(accDate.ACCOUNT_SOURCE_REF);
            If(accDate.SLAEXPDATE != ''){
                acc.SLAExpirationDate__c = Date.valueOf(accDate.SLAEXPDATE);
            }else{
                acc.SLAExpirationDate__c = NULL;
            } 
            accListToUpdate.add(acc);
        }
        
        Database.SaveResult[] srList = database.update(accListToUpdate,false);
        
        for (Database.SaveResult sr : srList){
            if (sr.isSuccess()){
                jsonResponse = '{"response": {"status": "Successfully updated"}}';
                res.responseBody = blob.valueOf(jsonResponse);
                return;
            }else {
                // Operation failed, so get all errors                
                for(Database.Error err : sr.getErrors()) {
                    System.debug('The following error has occurred.'+sr.getId());                    
                    System.debug(err.getStatusCode() + ': ' + err.getMessage());
                    System.debug('Account fields that affected this error: ' + err.getFields());
                }
            }
        }
    }
    global class accountSLAExpDate{
        public String ACCOUNT_SOURCE_REF;  //Account Id
        public String SLAEXPDATE;  //yyyy-mm-dd format
    }
}

I have tested with the below REST API service URI :

/services/apexrest/AccSlaExpireDate/

Payload: 
[
    {
      "ACCOUNT_SOURCE_REF": "0012x0000059fPD",
      "SLAEXPDATE": "2021-02-08"
    }
]

Can someone please help on how to send the failed record Ids and failed records status message as response back to the external system.
OrderItem is the parent to Object A and Object B.

I want to update Type__c  on Object A (existing records) from Object B when the  Object B records get inserted with the Type__c.

I think I can leverage the OrderItem lookup on both the child objects to have a condition something like 
Trigger :- afterUpdate on Object B

If(objectA.OrderItem == objectB.OrderItem){
objectA.Type__c = objectB.Type__c
list.add(objectA); 
}
update list;

As I am bit new to apex not sure how to go ahead. Need some help on this.
I have a requirement to show the 1st word in BOLD letter of sentences/line having multiple words which are the values of each radio button using Lightning Component.
Example: In the below example the first word is in BOLD
  • This is line 1
  • This is line 2
  • This is line 3  
I am new to Flows and having a hard time to implement the logic I am working on. I have a requirement to update the child records(object : Group Segment) picklist field to Status : 'Completed' when the parent record(object : Case) Status is 'Closed' using Flows.
Can someone please guide/help me on this.
I have the below 2 fields :
Weekdays__c (Multiselect picklist) which contains the values as below :
Monday
Tuesday
Wednesday
Thursday
Friday
ExpirationDate__c (Date) 
My requirement is whenever the picklist values are selected as Monday;Tuesday OR Tuesday;Wednesday;Friday with multiple combinations the date should fall within any of the selected weekdays from the multi-picklist else throw validation.

Example : User selected the Weekday valules as Monday;Tuesday and the selected date is not falling Monday or Tuesday then throw validation. As in the current month Monday is falling on 7, 14, 21 , 28 dates or same in the case of Tuesday so if the user selects date falling on Monday or Tuesday then allow to save the record.

I am a newbie to the sfdc world and I have tried in multiple ways to achieve but couldn't able to. 

For single value I was able to as below but with multiple combinations I wasn't able to do.
AND(INCLUDES(Weekdays__c, "Monday"),
MOD( ExpirationDate__c - DATE(1900, 1, 6), 7) <> 2)
I think this can be resolved using roll-up summary fields but my organization wants to go with Apex. I am a newbie to Apex. Can anyone please help me on this. I tried in Apex but i was able to update the Total Amount field with the sum amount value of quotelineitem related to a single quote , which will be completely wrong as quote is having masterdetail relationship with opportunity 

Objects/fields involved :
Opportunity (Total_Amount__c)
Quote : Masterdetail relationship with Opportunity
QuoteLineItem (Amount__c) : Masterdetail with Quote

What I excatly want to achieve is for example Opportunity is having 2 quotes and these quotes are having 3 quoteline items each , I want the sum of all the quotelineitems to be updated in the Total Amount field on Opportunity.