• Colbridge
  • NEWBIE
  • 60 Points
  • Member since 2017
  • SFDC Training and Development
  • colbridge.com


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 10
    Questions
  • 25
    Replies
Looking to get coverage for the else part:
 
message.subject = messageSub;
        message.plainTextBody = messageBody;
        Messaging.SingleEmailMessage[] messages = 
            new List<Messaging.SingleEmailMessage> {message};
                Messaging.SendEmailResult[] results = Messaging.sendEmail(messages);
        if (results[0].success) {
            System.debug('The email was sent successfully.');
        } else {
            System.debug('The email failed to send: '
                + results[0].errors[0].message);
        }

 
How to get the coverage for the // dml operation failed part?
 
// records to be updated received from json
jsonBody = '[{"count__c":"445", "downloads__c":"340"}, {"count__c":"440", "downloads__c":"240"}]';

List<Data__c> dList = (List<Data__c>) System.JSON.deserialize(jsonBody, List<Data__c>.class);

countList has unique count__c values, say: 445,440 // to use in the IN clause.

// Querry parent for those plan ids in daily data json
List<Parent__c> parentList = [SELECT Id, Name FROM Parent__c 
    WHERE count__c IN :countList];

List<Data__c> dataToInsert = new List<Data__c>();

// Loop through dList - inner loop
for(Data__c dRecords : dList) {
     for(Parent__c parentRecords : parentList) {         
          if(dRecords.count__c  == parentRecords.count__c) {
                dRecords.downloads__c  = parentRecords.downloads__c ;
                dataToInsert.add(dRecords );
           }
      } 
} 

List srList = Database.insert(dataToInsert, false);
for(Integer i=0;i<srList.size();i++){
    if (srList.get(i).isSuccess()){
        srList.get(i).getId();

    }else if (!srList.get(i).isSuccess()){
        // DML operation failed
        Database.Error error = srList.get(i).getErrors().get(0);
        String failedDML = error.getMessage();
        recsToInsert.get(i);//failed record from the list
        system.debug('Failed Id: '+recsToInsert.get(i).Your_field__c);
    }
}



// Test class:
 
@isTest
private class Connect_Test {
    @isTest static void testCall() {
        Profile p = [SELECT Id FROM Profile WHERE Name='System Administrator' LIMIT 1]; 
        user intUser = new User(Alias = 'standt', Email='standarduser@testorg.com', 
            EmailEncodingKey='UTF-8', LastName='Integration User', LanguageLocaleKey='en_US', 
            LocaleSidKey='en_US', ProfileId = p.Id, 
            TimeZoneSidKey='America/Los_Angeles', UserName='intuser@co.com');
        insert intUser;

        System.runAs(intUser) {
            List<Parent__c> ms = new List<Parent__c>();
            Parent__c msRec1 = new Parent__c(count__c = '445');
            Parent__c msRec2 = new Parent__c(count__c = '440');
            ms.add(msRec1);
            ms.add(msRec2);
            insert ms;

            String strIds = '445, 440';
            list<String> countList = strIds.split(',');

            List<Parent__c> parentList = [SELECT Id, Name FROM Parent__c 
                WHERE count__c IN :countList];

            List<Data__c> recsToInsert = new List<Data__c>();
            Data__c ddRecs1 = new Data__c(downloads__c = 'a1IO001110AakH2MAJ');
            Data__c ddRecs2 = new Data__c(downloads__c = null);
            recsToInsert.add(ddRecs1);
            recsToInsert.add(ddRecs2);
            try {
                List<Database.SaveResult> srList = Database.insert(recsToInsert, false);
            } catch(DMLException e) {
                throw new DMLException('Unable to Perform the DML Operation: ' +e.getMessage());
            }
            Test.startTest();
            Test.setMock(HttpCalloutMock.class, new MockHttpResponse());
            Connect.call();
            Test.stopTest();
        }
    }
}

 
I have created an integration user account with name Integration User. How can I update the created by (ownerid) and last updated by fields with the details of this integration user while doing a bulk dml insert in apex? Right now its showing the logged in users name when the apex class is run.
 
// records to be updated received from json
jsonBody = '[{"count__c":"445", "downloads__c":"340"}, {"count__c":"440", "downloads__c":"240"}]';

List<Data__c> dList = (List<Data__c>) System.JSON.deserialize(jsonBody, List<Data__c>.class);

countList has unique count__c values, say: 445,440 // to use in the IN clause.

// Querry parent for those plan ids in daily data json
List<Parent__c> parentList = [SELECT Id, Name FROM Parent__c 
    WHERE count__c IN :countList];

List<Data__c> dataToInsert = new List<Data__c>();

// Loop through dList - inner loop
for(Data__c dRecords : dList) {
     for(Parent__c parentRecords : parentList) {         
          if(dRecords.count__c  == parentRecords.count__c) {
                dRecords.downloads__c  = parentRecords.downloads__c ;
                dataToInsert.add(dRecords );
           }
      } 
} 
insert dataToInsert;

 
How to generate a string with a list of skipped record ids.
Here I am skipping the records for which there is no matching count__c. 
I need to concatinate a string (skippedRecords) with ids of those skipped records. How would I achive this?
 
List<Parent__c> parentList = [SELECT Id, Name,downloads__c  FROM Parent__c 
    WHERE count__c IN :countList];

List<Data__c > datatoupdate = new List<Data__c >();

String skippedRecords = '';

    for(Data__c dRecords : dList) { 
        for(Parent__c parentRecords : parentList) {
            if(dRecords.count__c  == parentRecords.count__c) {
		        dRecords.downloads__c  = parentRecords.downloads__c ;
		        datatoupdate.add(dRecords );
            }
    } 
} 
update  datatoupdate;

 
P.S. No need to send entire record, just a few specific field on each failed records. Code so far is below:
 
Database.SaveResult[] srList = Database.insert(recsToInsert, false);

Integer successCtr = 0;
Integer failedCtr = 0;

for (Database.SaveResult sr : srList) {
    if (sr.isSuccess()) {
        successCtr ++;
    } else {
        // Operation failed, get all errors
        failedCtr ++;
        for(Database.Error err : sr.getErrors()) {
            System.debug('The following error has occurred.');
            System.debug(err.getStatusCode() + ': ' + err.getMessage());
            System.debug('Fields that affected this error: ' + err.getFields());
        }
    }
}
System.debug('Total successful record inserts: ' + successCtr);
System.debug('Total failed record inserts: ' + failedCtr);

 
What I am trying to do is to update a child object field (downloads__c) in each of the child records in the child object (Data__c) record collection, with the value of a field (downloads__c) from its parent object (Parent__c). The parent object also has the field count__c.
 
Once all the records are updated in the child collection, do a dml insert after the loop. Can't seem to get this to work. Hope I have explained correctly.
 
jsonBody = '[{"count__c":"45","downloads__c":"30"},{"count__c":"40","downloads__c":"20"}]'; // child records to be updated

List<Data__c> dList = (List<Data__c>) System.JSON.deserialize(jsonBody, List<Data__c>.class);

countList has unique count__c values, say 45,40 // to use in the IN clause.

// Querry parent for those plan ids in daily data json
List<Parent__c> parentList = [SELECT Id, Name FROM Parent__c 
    WHERE count__c IN :countList];

// Loop through the list of returned parent records - outer loop
for(Parent__c parentRecords : parentList) {
    // Loop through dList - inner loop
    for(Data__c dRecords : dList) {
        // look for matching count__c in parent 
        // update corresponding downloads__c in the child record with its parents downloads__c value
    } 
} 

Should I use maps, if so how?

// dml insert of child collection

 
With the validation rule active, getting validation error saying cannot update closed opportunity, while trying to insert the opportunity record. Any pointers to solve this?
I am getting the following error in http response in salesforce apex, when I do an http post:
oauth_problem=timestamp_refused&message=Timestamp has been refused
Any pointers on how to fix it will be appreciated.
Thanks.
Hi, 

How would you deploy/migrate custom settings from one org to another?

Thanks. 
Hi,

I am getting the error "The Lightning Bundle expensesApp is not a legal name" when trying to create this new app.

Trailhead unit: https://trailhead.salesforce.com/en/content/learn/modules/lex_dev_lc_basics/lex_dev_lc_basics_forms

Note sure why. Can someone give me a pointer?

Thanks,
Colbridge. 
How to get the coverage for the // dml operation failed part?
 
// records to be updated received from json
jsonBody = '[{"count__c":"445", "downloads__c":"340"}, {"count__c":"440", "downloads__c":"240"}]';

List<Data__c> dList = (List<Data__c>) System.JSON.deserialize(jsonBody, List<Data__c>.class);

countList has unique count__c values, say: 445,440 // to use in the IN clause.

// Querry parent for those plan ids in daily data json
List<Parent__c> parentList = [SELECT Id, Name FROM Parent__c 
    WHERE count__c IN :countList];

List<Data__c> dataToInsert = new List<Data__c>();

// Loop through dList - inner loop
for(Data__c dRecords : dList) {
     for(Parent__c parentRecords : parentList) {         
          if(dRecords.count__c  == parentRecords.count__c) {
                dRecords.downloads__c  = parentRecords.downloads__c ;
                dataToInsert.add(dRecords );
           }
      } 
} 

List srList = Database.insert(dataToInsert, false);
for(Integer i=0;i<srList.size();i++){
    if (srList.get(i).isSuccess()){
        srList.get(i).getId();

    }else if (!srList.get(i).isSuccess()){
        // DML operation failed
        Database.Error error = srList.get(i).getErrors().get(0);
        String failedDML = error.getMessage();
        recsToInsert.get(i);//failed record from the list
        system.debug('Failed Id: '+recsToInsert.get(i).Your_field__c);
    }
}



// Test class:
 
@isTest
private class Connect_Test {
    @isTest static void testCall() {
        Profile p = [SELECT Id FROM Profile WHERE Name='System Administrator' LIMIT 1]; 
        user intUser = new User(Alias = 'standt', Email='standarduser@testorg.com', 
            EmailEncodingKey='UTF-8', LastName='Integration User', LanguageLocaleKey='en_US', 
            LocaleSidKey='en_US', ProfileId = p.Id, 
            TimeZoneSidKey='America/Los_Angeles', UserName='intuser@co.com');
        insert intUser;

        System.runAs(intUser) {
            List<Parent__c> ms = new List<Parent__c>();
            Parent__c msRec1 = new Parent__c(count__c = '445');
            Parent__c msRec2 = new Parent__c(count__c = '440');
            ms.add(msRec1);
            ms.add(msRec2);
            insert ms;

            String strIds = '445, 440';
            list<String> countList = strIds.split(',');

            List<Parent__c> parentList = [SELECT Id, Name FROM Parent__c 
                WHERE count__c IN :countList];

            List<Data__c> recsToInsert = new List<Data__c>();
            Data__c ddRecs1 = new Data__c(downloads__c = 'a1IO001110AakH2MAJ');
            Data__c ddRecs2 = new Data__c(downloads__c = null);
            recsToInsert.add(ddRecs1);
            recsToInsert.add(ddRecs2);
            try {
                List<Database.SaveResult> srList = Database.insert(recsToInsert, false);
            } catch(DMLException e) {
                throw new DMLException('Unable to Perform the DML Operation: ' +e.getMessage());
            }
            Test.startTest();
            Test.setMock(HttpCalloutMock.class, new MockHttpResponse());
            Connect.call();
            Test.stopTest();
        }
    }
}

 
How to generate a string with a list of skipped record ids.
Here I am skipping the records for which there is no matching count__c. 
I need to concatinate a string (skippedRecords) with ids of those skipped records. How would I achive this?
 
List<Parent__c> parentList = [SELECT Id, Name,downloads__c  FROM Parent__c 
    WHERE count__c IN :countList];

List<Data__c > datatoupdate = new List<Data__c >();

String skippedRecords = '';

    for(Data__c dRecords : dList) { 
        for(Parent__c parentRecords : parentList) {
            if(dRecords.count__c  == parentRecords.count__c) {
		        dRecords.downloads__c  = parentRecords.downloads__c ;
		        datatoupdate.add(dRecords );
            }
    } 
} 
update  datatoupdate;

 
What I am trying to do is to update a child object field (downloads__c) in each of the child records in the child object (Data__c) record collection, with the value of a field (downloads__c) from its parent object (Parent__c). The parent object also has the field count__c.
 
Once all the records are updated in the child collection, do a dml insert after the loop. Can't seem to get this to work. Hope I have explained correctly.
 
jsonBody = '[{"count__c":"45","downloads__c":"30"},{"count__c":"40","downloads__c":"20"}]'; // child records to be updated

List<Data__c> dList = (List<Data__c>) System.JSON.deserialize(jsonBody, List<Data__c>.class);

countList has unique count__c values, say 45,40 // to use in the IN clause.

// Querry parent for those plan ids in daily data json
List<Parent__c> parentList = [SELECT Id, Name FROM Parent__c 
    WHERE count__c IN :countList];

// Loop through the list of returned parent records - outer loop
for(Parent__c parentRecords : parentList) {
    // Loop through dList - inner loop
    for(Data__c dRecords : dList) {
        // look for matching count__c in parent 
        // update corresponding downloads__c in the child record with its parents downloads__c value
    } 
} 

Should I use maps, if so how?

// dml insert of child collection

 
With the validation rule active, getting validation error saying cannot update closed opportunity, while trying to insert the opportunity record. Any pointers to solve this?
I am getting the following error in http response in salesforce apex, when I do an http post:
oauth_problem=timestamp_refused&message=Timestamp has been refused
Any pointers on how to fix it will be appreciated.
Thanks.
Hi, 

How would you deploy/migrate custom settings from one org to another?

Thanks. 
Hi,

I am getting the error "The Lightning Bundle expensesApp is not a legal name" when trying to create this new app.

Trailhead unit: https://trailhead.salesforce.com/en/content/learn/modules/lex_dev_lc_basics/lex_dev_lc_basics_forms

Note sure why. Can someone give me a pointer?

Thanks,
Colbridge. 
(New org, Superbadge: App Customization Specialist, Step 4)
Cant figure out why Volunteer Jobs isnt showing up. Double checked the relationships and all and couldnt find anything wrong. Would appreciate any help on the matter.
User-added imageUser-added image
  • February 28, 2019
  • Like
  • 1
I may be overthinking this, but want to make sure they aren't twisting the terminology on us like they tend to do with Superbadges.

For the final part of Challenge 2, under the "Support Is a Team Sport" portion of the requirements, it talks about creating Customer Contact and Support Lead roles. Are those actual Salesforce Roles or more akin to Case teams?

The main reason I ask this is because the Error Message I get mentions something not spelled out in the requirements that I could see:

"Challenge Not yet complete... here's what's wrong:
We can't find the 'Customer Case Team' role. Ensure the Customer Contact can be tracked on Cases."

However, the requirements don't specifically mention creating a 'Customer Case Team' role.
Hi All, 

Im trying to do the second challenge in App Customization  but am getting some Super badge am getting the error "Challenge Not yet complete... here's what's wrong:  Couldn’t find the 'Volunteer Shift' relationship field or it is not configured correctly."
Please, anyone, can anyone tell me which relationships should be created between these objects? I have created a master-detail relationship between them. 
User-added image

Also, am not clear with this "Shifts with cascading delete and the option of roll-up summary fields." 

Thank you and any help is appreciated.
Thank you in advance. 
Hello,

I'm facing an issue with the SuperBadge "App Customization Specialist"

I'm trying to check my Report challenge but I get this error message : User-added image

And this is how i've created it : 

User-added image

Do you have any idea ? 

Thanks,
Guillaume
I keep getting the following error message, even after trying in 3 new playgrounds: 
Challenge Not yet complete... here's what's wrong: 
Some billing state names do not meet data quality standards, or the data import was unsuccessful.

I followed all of the instructions:
1. Installed unmanaged package in the new playground
2. Added Residential picklist type to Accounts
3. Cleaned up Account list:
a. Removed "Household" from Account name (this wasn't specified, but it didn't seem necessary)
b. Removed duplicate records
c. Changed accounts in ALL CAPS to only cap first letter of first and last name
d. Changed state name to 3 letter State code
e. Saved as .CSV file
4. Imported list using Import Wizard

I received an email confirming the import was successful with 11 rows processed and I see the accounts when I search up accounts in the playground. 

Thanks in advance for any help!

Hi,

I have followed several different solutions to this step, but still, I am recieving this error: 

"Challenge Not yet complete... here's what's wrong: 
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, error: [Name]"

Has anyone got any ideas on how to solve this? 

Please let me know what you need of information from this. I have the following validation rules on opportunity object :
"Approved field validation": 
AND( 
ISCHANGED(Approved__c), 
OR( 
$Profile.Name <> 'System Administrator', 
$Profile.Name <> 'Custom: Sales Profile' 

)

High Value Opportunity Validation:

AND( 
IsClosed = TRUE, 
Amount > 100000, 
Approved__c <> TRUE 
)

I'm unable to check step 2: Automate Accounts because I'm receiving this error: Challenge Not yet complete... here's what's wrong: 
There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: ZKCVFIZH
 

We have recently contracted several Salesforce customization  projects and need some extra help (paid by the hour).  Please send your credentials, describe your past involvement with Salesforce, and references if possible to Taylor at timesmith@solvate.com.

hi ,i am trying the Lightning Experience Specialist

while i installed the  unmanaged LEX Superbadge package.
here comes the issue

"Install the unmanaged package from the pre-work if you haven’t already. Rename all of the standard objects in the schema as specified, and set the default page layouts for Adventure, Adventure Package, and Opportunity to the Relaxation Gauntlet custom layouts. Update the Opportunity stage values, create a sales path for sales reps (highlighting key fields and giving specific coaching guidance), and create an approval process as specified in the business requirements."

i am confused what i should do next .as i am unable to understand ....

help me