• AmitSoni
  • NEWBIE
  • 230 Points
  • Member since 2016

  • Chatter
    Feed
  • 8
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 28
    Replies
Hello this is my first time parsing a JSON respnse, so this may be a basic question. In my code, I am making a callout and am receiving a 200 response, and receiving the response JSON. However, at this point I am getting stuck with how to actually parse the JSON. I am familiar with the concepts of wrapper classes and the JSONParse class, but what I am requesting here, if possible, is if someone can actually show me how to parse the response AND save the data into my object's fields.  This would be a tremendous help for me. 

Here is a snippet of the response (if you can show me how to do it with this, I will learn how to do it myself for the rest of it.) I need to map the fields to corresponding fields on my custom object called Eligibility__c. Please note also that in the JSON, there a some repeats (i.e. "service_name" appears multiple times in the "third_party" section. )

Again, the end result needs to be that I create a new eligibility record with each value in the json populating a field on the eligibility object. 


{
"request_id": "1a87457e-f11c-11ea-863c-d20ff8abdbc2",
"request_status": "results_ready",
"result_path": "emed.json.output/PF03367D-2495_2020-09-07_15-09-21_271.json",
"result": {
"first_name": "JOHN",
"last_name": "SMITH",
"id_type": "MI",
"subscriber_id": "123456",
"gender": "M",
"birthdate": "19551220",
"address": {
"info": "123 CENTRAL AVE",
"city": "New York",
"state": "NY",
"zip_code": "10301"
},

"third_party": [
          {
            "service_name": "Health Benefit Plan Coverage",
            "service_type": "30",
            "coverage_level": "IND",
            "info_code_name": "Other or Additional Payor",
            "entity": {
              "name": "BC/BS EMPIRE",
              "id_code": "P4",
              "benefit_id_name": "Payor Identification",
              "benefit_id_qual": "PI",
              "benefit_id": "12",
              "address": {
                "info": "PO BOX 1407 CHURCH ST STATION",
                "info_2": "ATTN  CLAIMS DEPT",
                "city": "NEW YORK",
                "state": "NY",
                "zip_code": "100081407"
              }
],
     {
            "service_name": "Health Benefit Plan Coverage",
            "service_type": "30",
            "coverage_level": "IND",
            "info_code_name": "Other or Additional Payor",
            "entity": {
              "name": "BC/BS EMPIRE - DENTAL",
              "id_code": "P4",
              "benefit_id_name": "Payor Identification",
              "benefit_id_qual": "PI",
              "benefit_id": "12DNT",
              "address": {
                "info": "PO BOX 1407",
                "city": "NEW YORK",
                "state": "NY",
                "zip_code": "100081407"
              }
            }}

 
We have this code in our org for a trigger. I am trying to understand the code. Can anyone please explain what's being done in the bolded lines?
 
public with sharing class ObjAction {
    private Obj__c[] newObj;  
    private Obj__c[] oldObj; 
    ObjHandler triggerHandler = new ObjHandler();
    public ObjAction(Obj__c[] oldObj, Obj__c[] newObj){    
        this.newObj = newObj;    
        this.oldObj = oldObj;   
    } 
}

Thanks.
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)
public class QuoteQuickActionController {

    @auraEnabled
    public static opportunity getopportunity(string oppId){
        Opportunity opp=[Select id,accountId,pricebook2Id from opportunity where id =: oppId];
                         return opp;
    }
}
  • August 26, 2020
  • Like
  • 0
The requirement now is to add gray indicator if the ROI months are greater than 36.
Red for greater than 24 but less than or = 36 months.
Yellow for greater than or = to 13 but less than 24 and green for less than 13.

Gray >36
red 25-36 months
yellow 13-24 months
green 1-12 months


IF( 
ROI_No_of_Months__c  < 13,
IMAGE("//c.na139.content.force.com/servlet/servlet.FileDownload?file=0154W00000BiFeo", "green", 30, 30),
IF(
AND(
ROI_No_of_Months__c  >= 13,
ROI_No_of_Months__c  <= 24
),
IMAGE("//c.na139.content.force.com/servlet/servlet.FileDownload?file=0154W00000BiFee", "yellow", 30, 30),
IF(
AND(
ROI_No_of_Months__c  >= 25,
ROI_No_of_Months__c  <= 36
),
IMAGE("//c.na139.content.force.com/servlet/servlet.FileDownload?file=0154W00000BiFej", "red", 30, 30)
IF(
ROI_No_of_Months__c > 36, 
IMAGE("//c.na139.content.force.com/servlet/servlet.FileDownload?file=0154W00000BiFlp", "gray", 20, 20), 
),
)
)
)
)
Hello,

I have a code coverage of 100% for my trigger but uploading my packages to production I have an error 
Code Coverage Failure
Your code coverage is 74%. You need at least 75% coverage to complete this deployment.

I really don't understand why when my code is covered 100%

User-added image

my Trigger:
 
trigger CaseConcernAircallDateTrigger on Task (after insert) {
   
    List<Case>  cList = new List<Case>();
    for(Task t: Trigger.New) {
        if(t.WhatId!=Null && t.whatId.getsObjectType() == Case.sObjectType){
            Case c = new Case();
            c.Id = t.whatId;
            c.Last_Aircall_Logged__c = t.CreatedDate;
            cList.add(c);
        }
    }
   
    if(cList.size() > 0) update cList;
}

my Test class:
 
@isTest
public class CaseConcernAircallDateTriggerTest {
    @isTest static void testAircallDateUpdate() {
        
        
        Contact con = new Contact (FirstName = 'First Name',LastName = 'Test');
        insert con;
        
        Case c = new Case(Status = 'New',ContactId = con.Id,Phone_Number__c = '123456789');
        insert c;
        
        Task t = new Task(Subject = 'Test', WhatId = c.Id);
        insert t;
       
        c.Id = t.WhatId;
        c.Last_Aircall_Logged__c = t.CreatedDate;
        update c;
       
    }
}

Thank you
 
Hello, I am trying to write a formula that evaluates to true when the following conditions are met.
Enrolled_Date__c != null
AND Payment_Status__c IN ("Paid in Full", "No Charges", "Balance Pending", "Refund Pending")
OR Enrolled_Date__c != null AND Payment_Status__c = "Balance Due" AND Financial_Aid_Amount__c >= Account_Balance__c

Any help is greatly apprecaited. This will be used inside process builder to trigger an action. 
I am trying to implement a case comment component for communities that was posted in this blog. when I deploy without any text class I get 71% code coverage. what would a test class for this apex class look like? I am just getting into the dev side and I am looking for some help. thank you in advance. 
https://medium.com/@kamatvs/test-66e060ccb91f
/*
* @Description: APEX Server Side Controller.
* Provides methods to fetch case and work with case from Community
*/
public class CommunityCaseDisplayController { 
    
    @AuraEnabled
    public static List<CaseComment> getCaseComments(String caseId) {
        List<CaseComment> caseComments = 
                [SELECT Id, ParentId, IsPublished, CommentBody,    CreatedDate, CreatedBy.Name, LastModifiedDate, LastModifiedById FROM CaseComment where parentId=:caseId order by CreatedDate desc];
return caseComments;        
    }
    
    @AuraEnabled
    public static CaseComment addCaseComment(String caseId, String commentBody) {
        CaseComment caseComment = new CaseComment(ParentId=caseId, CommentBody=commentBody);
        insert caseComment;
return caseComment;        
    }    
}

 
Hello this is my first time parsing a JSON respnse, so this may be a basic question. In my code, I am making a callout and am receiving a 200 response, and receiving the response JSON. However, at this point I am getting stuck with how to actually parse the JSON. I am familiar with the concepts of wrapper classes and the JSONParse class, but what I am requesting here, if possible, is if someone can actually show me how to parse the response AND save the data into my object's fields.  This would be a tremendous help for me. 

Here is a snippet of the response (if you can show me how to do it with this, I will learn how to do it myself for the rest of it.) I need to map the fields to corresponding fields on my custom object called Eligibility__c. Please note also that in the JSON, there a some repeats (i.e. "service_name" appears multiple times in the "third_party" section. )

Again, the end result needs to be that I create a new eligibility record with each value in the json populating a field on the eligibility object. 


{
"request_id": "1a87457e-f11c-11ea-863c-d20ff8abdbc2",
"request_status": "results_ready",
"result_path": "emed.json.output/PF03367D-2495_2020-09-07_15-09-21_271.json",
"result": {
"first_name": "JOHN",
"last_name": "SMITH",
"id_type": "MI",
"subscriber_id": "123456",
"gender": "M",
"birthdate": "19551220",
"address": {
"info": "123 CENTRAL AVE",
"city": "New York",
"state": "NY",
"zip_code": "10301"
},

"third_party": [
          {
            "service_name": "Health Benefit Plan Coverage",
            "service_type": "30",
            "coverage_level": "IND",
            "info_code_name": "Other or Additional Payor",
            "entity": {
              "name": "BC/BS EMPIRE",
              "id_code": "P4",
              "benefit_id_name": "Payor Identification",
              "benefit_id_qual": "PI",
              "benefit_id": "12",
              "address": {
                "info": "PO BOX 1407 CHURCH ST STATION",
                "info_2": "ATTN  CLAIMS DEPT",
                "city": "NEW YORK",
                "state": "NY",
                "zip_code": "100081407"
              }
],
     {
            "service_name": "Health Benefit Plan Coverage",
            "service_type": "30",
            "coverage_level": "IND",
            "info_code_name": "Other or Additional Payor",
            "entity": {
              "name": "BC/BS EMPIRE - DENTAL",
              "id_code": "P4",
              "benefit_id_name": "Payor Identification",
              "benefit_id_qual": "PI",
              "benefit_id": "12DNT",
              "address": {
                "info": "PO BOX 1407",
                "city": "NEW YORK",
                "state": "NY",
                "zip_code": "100081407"
              }
            }}

 
Simple SOQL Query fails to yield results in live Apex code, but succeeds in Developer Console Execute Anonymous Window and in Query Editor Tab.

public void importProgramCollaborationGroupTable(){
   List<CollaborationGroup> allCollabGroups = [SELECT Id, Name FROM CollaborationGroup];
}
I utilized below mentioned code in a class and used that class in a trigger to update a field at Account Level but it's giving me Trigger Recursion Error.( I know this can be done via simple workflow but want to understand how this can be achieved via apex)

(This code is from Apex Developers Guide. Here is the link:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_dml_examples_insert_update.htm)


Account[] accts = new List<Account>();
for(Integer i=0;i<3;i++) {
Account a = new Account(Name='Acme' + i,
BillingCity='San Francisco');
accts.add(a);
}
Account accountToUpdate;
try {
insert accts;
// Update account Acme2.
accountToUpdate =
[SELECT BillingCity FROM Account
WHERE Name='Acme2' AND BillingCity='San Francisco'
LIMIT 1];
// Update the billing city.
accountToUpdate.BillingCity = 'New York';
// Make the update call.
update accountToUpdate;
} catch(DmlException e) {
System.debug('An unexpected error has occurred: ' + e.getMessage());
}
 
// Verify that the billing city was updated to New York.
Account afterUpdate =
[SELECT BillingCity FROM Account WHERE Id=:accountToUpdate.Id];
System.assertEquals('New York', afterUpdate.BillingCity);
We have this code in our org for a trigger. I am trying to understand the code. Can anyone please explain what's being done in the bolded lines?
 
public with sharing class ObjAction {
    private Obj__c[] newObj;  
    private Obj__c[] oldObj; 
    ObjHandler triggerHandler = new ObjHandler();
    public ObjAction(Obj__c[] oldObj, Obj__c[] newObj){    
        this.newObj = newObj;    
        this.oldObj = oldObj;   
    } 
}

Thanks.
Hi All,
Can I please ask couple of things and request for prompt response.

1) I have enrolled for ADM201 exam online through webassessor. Can I check to ensure if the software use for exam is working fine a week before exam?

2) Does external webcam still a requirement to give an exam? I dont have a webcam and we are in Stage 4 lockdown due to COVID. I have seen an article which details that due to COVID, we can give exam using built in webcam in laptop. Is this true? 
https://trailhead.salesforce.com/help?article=Testing-Center-Closures-Due-to-Coronavirus-COVID-19
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)
Hello, I am not sure if this is the correct topic to list this under, but I am certain what I am looking for will ulimately need some custom coding.  

What I am being asked to find a potential solution for is for example: An existing quote already has quote lines present.  A User wishes to update said quote by "Importing Quote lines" using an import format.  When the import is used, they wish to have all existing quote lines be deleted and only the new lines from the import remaining.  

Any thoughts on how to possibly achieve this?

Any help would be very much appreciated!

Shawn
public class QuoteQuickActionController {

    @auraEnabled
    public static opportunity getopportunity(string oppId){
        Opportunity opp=[Select id,accountId,pricebook2Id from opportunity where id =: oppId];
                         return opp;
    }
}
  • August 26, 2020
  • Like
  • 0
The requirement now is to add gray indicator if the ROI months are greater than 36.
Red for greater than 24 but less than or = 36 months.
Yellow for greater than or = to 13 but less than 24 and green for less than 13.

Gray >36
red 25-36 months
yellow 13-24 months
green 1-12 months


IF( 
ROI_No_of_Months__c  < 13,
IMAGE("//c.na139.content.force.com/servlet/servlet.FileDownload?file=0154W00000BiFeo", "green", 30, 30),
IF(
AND(
ROI_No_of_Months__c  >= 13,
ROI_No_of_Months__c  <= 24
),
IMAGE("//c.na139.content.force.com/servlet/servlet.FileDownload?file=0154W00000BiFee", "yellow", 30, 30),
IF(
AND(
ROI_No_of_Months__c  >= 25,
ROI_No_of_Months__c  <= 36
),
IMAGE("//c.na139.content.force.com/servlet/servlet.FileDownload?file=0154W00000BiFej", "red", 30, 30)
IF(
ROI_No_of_Months__c > 36, 
IMAGE("//c.na139.content.force.com/servlet/servlet.FileDownload?file=0154W00000BiFlp", "gray", 20, 20), 
),
)
)
)
)
Hello,

I have a code coverage of 100% for my trigger but uploading my packages to production I have an error 
Code Coverage Failure
Your code coverage is 74%. You need at least 75% coverage to complete this deployment.

I really don't understand why when my code is covered 100%

User-added image

my Trigger:
 
trigger CaseConcernAircallDateTrigger on Task (after insert) {
   
    List<Case>  cList = new List<Case>();
    for(Task t: Trigger.New) {
        if(t.WhatId!=Null && t.whatId.getsObjectType() == Case.sObjectType){
            Case c = new Case();
            c.Id = t.whatId;
            c.Last_Aircall_Logged__c = t.CreatedDate;
            cList.add(c);
        }
    }
   
    if(cList.size() > 0) update cList;
}

my Test class:
 
@isTest
public class CaseConcernAircallDateTriggerTest {
    @isTest static void testAircallDateUpdate() {
        
        
        Contact con = new Contact (FirstName = 'First Name',LastName = 'Test');
        insert con;
        
        Case c = new Case(Status = 'New',ContactId = con.Id,Phone_Number__c = '123456789');
        insert c;
        
        Task t = new Task(Subject = 'Test', WhatId = c.Id);
        insert t;
       
        c.Id = t.WhatId;
        c.Last_Aircall_Logged__c = t.CreatedDate;
        update c;
       
    }
}

Thank you
 
Hello

I have added apex class and VF Page to override standard convert button to Accept Button. The mentioned below code is working fine. But it is getting converted in Classic Version. But need the lead Conversion Page in Lightning Version. Anyone Please suggest.

public class AutoConvertLeads {
    
    private final Lead lead; //variable for the standard Lead object
    
    public AutoConvertLeads(ApexPages.StandardController standardPageController) {
        this.lead = (Lead)standardPageController.getRecord(); //initialize the standard controller
    }
    
    public PageReference redirectToConvertionPage() {
        PageReference nextPage = new PageReference('/lead/leadconvert.jsp'); //set the starting point for the page reference to which the User will be sent
        nextPage = encodeAndSetParam(nextPage, 'retURL', lead.Id); //set the retURL parameter in order to allow for returning to Lead if User cancels from page
        nextPage = encodeAndSetParam(nextPage, 'id', lead.Id); //set the id parameter so that the conversion page knows the proper record
        nextPage = encodeAndSetParam(nextPage, 'nooppti', '1'); //set the nooppti parameter to pre-populate the "Do not create a new opportunity upon conversion." checkbox
        nextPage = encodeAndSetParam(nextPage, 'nooverride', '1'); //set the nooverride parameter in order to prevent looping in the user interface
        nextPage.setRedirect(true); //indicate that the redirect should be performed on the client side
        return nextPage; //send the User to the Lead conversion page
    }
    
    public PageReference encodeAndSetParam(PageReference passedPageReference, String passedParameterId, String passedParameterValue){
        if (passedParameterValue != null) { //if the passedParameterValue is not null
            String encodedParameterValue = EncodingUtil.urlEncode(passedParameterValue, 'UTF-8'); //encode the value that was passed to eliminate conflicts with unsafe characters
            passedPageReference.getParameters().put(passedParameterId, EncodingUtil.urlDecode(encodedParameterValue, 'UTF-8')); //add the parameter to the page reference
        }
        return passedPageReference;
    }

}

Visual Force Page:

<apex:page action="{!redirectToConvertionPage}" extensions="AutoConvertLeads" standardController="Lead">
    <apex:sectionHeader title="Accept" subtitle="{!Lead.Name}" help="/htviewhelpdoc?id=leads_convert.htm&siteLang=en_US"></apex:sectionHeader>
    <apex:pageMessages ></apex:pageMessages>
</apex:page>


Thanks
TS

 
Hi ,
I have the below code snippet on Lead trigger.
I want to add an extra condition if the Lead Owner is Not equal to the queue "Partner Marketing" , How to do that ? i tried as  below but shows errors,

!newLead.OwnerID.equals ('Partner Marketing') Or tried as well
newLead.OwnerID != 00yhggddy4th2we
 
if (!oldLead.status.equals(newLead.status) || 
                (newLead.Company_Type__c != null && 
                 !newLead.Company_Type__c.equals(oldLead.Company_Type__c) && 
                 (newLead.Company_Type__c.startsWith('Partner')) )
               ) {
          // Add to list to update
            leadsToUpdate.add(new Lead(id = newLead.id));                    
        }

 
We are integrating Salesforce and Service now in which middle will be Mulesfot. As of now we are using Oauth2.0 for integrating Salesforce with Mule. As of client requirement they need more secure authentication. Is Oauth2.0 the best compared to others as of now?

Are there any other authentication methods which are more secure for integrating salesforce and mule?

Thanks in Advance.
for(vlocity_cmt__OrchestrationItem__c items:Trigger.New)
         {            
            if(items.Name=='Generate Bill Manual Task')
                {
                allItemsGenBilling.add(items);
                }
         }
        
           if(allItemsGenBilling.size()>0)
                {
                Tet_GenerateBillManualTaskForGenBill.UpdateOrderStatus(allItemsGenBilling);  
                }
Hello, I am trying to write a formula that evaluates to true when the following conditions are met.
Enrolled_Date__c != null
AND Payment_Status__c IN ("Paid in Full", "No Charges", "Balance Pending", "Refund Pending")
OR Enrolled_Date__c != null AND Payment_Status__c = "Balance Due" AND Financial_Aid_Amount__c >= Account_Balance__c

Any help is greatly apprecaited. This will be used inside process builder to trigger an action. 
Hi, I wrote a trigger and a test class, but when testing I get below error: 

System.DmlException: Update failed. First exception on row 0 with id 003M000000Zc1NaIAJ; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, PopulateContactAreaCode: execution of BeforeUpdate
caused by: System.NullPointerException: Attempt to de-reference a null object
Trigger.PopulateContactAreaCode: line 5, column 1: []

Trigger:
trigger PopulateContactAreaCode on Contact (before insert, before update) {

    for(Contact contact : Trigger.new)
    {
        string AreaCode = CountryRegion__c.getInstance(contact.MailingCountry).Area_Code__c;
        contact.Area_Code__c = AreaCode;
    }
}

test class:
@isTest
public class PopulateContactAreaCodeTest
{
    static testMethod void attTriggerTest1()
    {
        test.startTest();
        Account acct = new Account(id = '001M000000iLhTL', Name = 'Test Account ', Mailing_Country__c = 'Afghanistan');
        update acct;      
        Contact con = new Contact(id = '003M000000Zc1Na', LastName = 'Test Contact', Account = acct, Email = 'test@test.com', Mailing_Country__c = 'Afghanistan', MailingCountry = 'Afghanistan');
        update con;
        delete con;
        test.stopTest();
    }
}

any idea what I added wrong?

thank you in advance
  • February 24, 2015
  • Like
  • 1