• Muhammad Saad Javed
  • NEWBIE
  • 30 Points
  • Member since 2018
  • Salesforce Developer
  • Matech Consulting and Outsourcing


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 8
    Replies
I am not being able to configure the trigger whose fetching childs records . This is the Screen shot , Please help me in it as your earliest possible 

User-added image

This is the Code 

trigger insert12Records on University__c (after insert) {
List<Class__c> classList = new List<Class__c>();
Set<Id> idSet = new Set<Id>();
Map<id,Integer> mapIDcount = new Map<id,Integer>();
for(University__c uni:Trigger.new)
{
idSet.add(uni.Name);
for(University__c u:[Select Id,(Select id from Class__c ) from University__c where Id =:idSet ])
{


for(Integer i = 0; i< 12; i++){
Class__c cls = new Class__c();
cls.Name= 'Test Class'+i;
cls.University__c = uni.Id;
classList.add(cls); 


}
}
insert classList;

}

}
 
I have struck in the Security Specialist Super badge's first Challenge. Here is the Challenge Statement 
Sales Executive User Requirements
Sales Executive users should be able to view all opportunities and accounts (regardless of other sharing settings), but not be able to create, edit, or delete any opportunities or accounts. They should be able to create reports and dashboards, but not create or manage report and dashboard folders. Sales Executive users should be able to create their own list views, but not create or manage list views for others. They should have mobile access, granted by the admin on demand, and are not restricted in terms of their hours of access to Salesforce.
i have configured rest of process correctly , i am not being able to get this bold statement, Regardless of Sharing setting, 
Please help me in it,
Here is the Problem 
User-added image
I am not being able to configure the trigger whose fetching childs records . This is the Screen shot , Please help me in it as your earliest possible 

User-added image

This is the Code 

trigger insert12Records on University__c (after insert) {
List<Class__c> classList = new List<Class__c>();
Set<Id> idSet = new Set<Id>();
Map<id,Integer> mapIDcount = new Map<id,Integer>();
for(University__c uni:Trigger.new)
{
idSet.add(uni.Name);
for(University__c u:[Select Id,(Select id from Class__c ) from University__c where Id =:idSet ])
{


for(Integer i = 0; i< 12; i++){
Class__c cls = new Class__c();
cls.Name= 'Test Class'+i;
cls.University__c = uni.Id;
classList.add(cls); 


}
}
insert classList;

}

}
 
I have struck in the Security Specialist Super badge's first Challenge. Here is the Challenge Statement 
Sales Executive User Requirements
Sales Executive users should be able to view all opportunities and accounts (regardless of other sharing settings), but not be able to create, edit, or delete any opportunities or accounts. They should be able to create reports and dashboards, but not create or manage report and dashboard folders. Sales Executive users should be able to create their own list views, but not create or manage list views for others. They should have mobile access, granted by the admin on demand, and are not restricted in terms of their hours of access to Salesforce.
i have configured rest of process correctly , i am not being able to get this bold statement, Regardless of Sharing setting, 
Please help me in it,
Here is the Problem 
User-added image
Here is the code that i have written:

public class AccountHandler {
    public Static Account insertNewAccount(String AccountName)
    {
        Account acc=new Account(name=AccountName)
        Database.SaveResult[] saveResultList = Database.insert(acc,false);
    }

}

Is it the right solution?, If yes please suggest me what is the execution code for this solution.
Hi all,

I have a problem with this challenge : 

Write an Apex trigger that fires before records are inserted and ensures that the ShippingState field has the same value as the BillingState field.
Create an Apex class named AccountTriggerHandler that contains a public static method called CreateAccounts to accept the List of Account objects.
For each Account record, before saving, ensure that the ShippingState field has the same value as the BillingState field.
Write an Apex trigger named AccountTrigger that fires before records are inserted.
The Apex trigger must call the AccountTriggerHandler.CreateAccounts() method with the collection of new records.
Create a test class named AccountTriggerTest that inserts 200 Account records with a BillingState of CA. After the insert, test to ensure that all 200 records have a ShippingState of CA.
Before verifying this challenge, run your test class at least once using the Developer Console Run All feature.

and this is my classes :
 
public class AccountTriggerHandler {
    
    public static void CreateAccounts(List<Account> acclist){
        
        
        for(Account a:acclist){
            
            if(a.ShippingState!=a.BillingState){
                a.BillingState=a.ShippingState;
              
            }
        }
    }

}
 
trigger AccountTrigger on Account (before insert) 
{
    if (Trigger.isBefore && Trigger.isInsert) {
			AccountTriggerHandler.CreateAccounts(Trigger.new);
		}	
	}
 
@isTest
public class AccountTriggerTest {
    
    @isTest static void TestCreate200Records(){
        
        // Test Setup data
        // Create 200 new Accounts
        List<Account> accts = new List<Account>();
        for(Integer i=0; i < 200; i++) {
            Account acct = new Account(Name='Test Account ' + i, BillingState = 'CA');
            accts.add(acct);
        
            Test.startTest();
            //insert acct;
        	Test.stopTest();
            
            for (Account a:accts){
                
                System.assertEquals('CA', a.ShippingState, 'ERROR');
            }
            
    }

        
}
}
And this error :
Challenge Not yet complete... here's what's wrong: 
The 'AccountTrigger' Trigger does not appear to be working correctly. Inserted records did not have matching BillingState and ShippingState values.

Anyone can help me please??
Thanks!
 
how to insert multiple records using dynamic apex in salesforce