• Chaudhary Aditya
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 5
    Replies
Hi all, 
I am trying to complete below challenge and getting an error. I have copied all details(Challange Link, Code and Error).  

Appreciate your help!


CHALLENGE NAME

https://trailhead.salesforce.com/content/learn/modules/apex_metadata_api/apex_metadata_api_tools?trailmix_creator_id=strailhead&trailmix_slug=prepare-for-your-salesforce-platform-developer-ii-credential

CODE
public class MetadataExample {
    
    public  Metadata.CustomMetadata customMetadata{get;set;}
    public void updateMetadata(){
        
        customMetadata  = new Metadata.CustomMetadata();
        customMetadata.fullName  = 
            'MyNamespace__MyMetadataTypeName.MyMetadataRecordName';
        
        Metadata.CustomMetadataValue customField = new Metadata.CustomMetadataValue();
        customField.field = 'customField__c ';
        customField.value = 'New Value';
        
        customMetaData.values.add(customField);
        
        Metadata.DeployContainer deployContainer = new Metadata.DeployContainer();
        deployContainer.addMetadata(customMetaData);
        Id asyncResultId  = Metadata.Operations.enqueueDeployment(deployContainer, null);
    }
}

ERROR





 
I am baffled my the ability of Happysoup.io to access my salesforce org. I did not create a connected app or did anything else to connect my Salesforce org. A simple login. 

The documentaion on it's website mentions creating a connected application if we want to host the application on premise.  

I looked into 'Connected App Usage' - there is an entry for 'Heroku Connect' - I did not create this app - Neither do I see this app under Connected Apps list!

Has Salesforce 'behind the scenes' made it possible for Heroku apps to integrate with Salesforce - by embedding a Connected app in all Salesforce orgs by default? 

Could someone please help me explain how is HappySoup able to connect to my Org?  



 
I am required to add a logic around a custom object(On create). There are multiple process-builder processes, trigger, flow, workflow operating on this object.  

I need to document all the references to come up with an ideal component(existing/new) to add my logic. 

Is there a way in the User Interface,SOQL/API or something else - to figure out all the components - this custom object may be refernced in(Process, Flow, Workflow, Trigger, Apex classes)? 

Is this something very basic?  What am I missing?
Description:  A 'before update' trigger on Opportunity. Trigger logic has some validations/consitions.

Completed Tasks: 
1.Trigger has been written.
2. All Errored Out Opportunity Id are stored in a map called: erorredOutOpportunityMap
3. Error on screen is displayed using: 
    webpageOpp.addError('Error Message');     

Help on
Best way to handle: 
(a) Show error to user (in browser) if record cannot be updated for some reason. e.g. A validation in trigger fails. 
(b) For bulk updates -  Skip over the ones that failed and update the rest. [Notify/Add to Queue for the missed Opportunities]. 



I would like to believe this is a relatively common use case in Salesforce applications. 

Is it a good industry practice to add errored out Opportunities to a queue and have a human look at it? 

I would really appreciate a pointer/steps/improvement & errors in above.



        
 





 
Greetings! 
I am evaluating illuminated cloud on PyCharm community edition.  It looks good so far. I wrote apex code, test class and can execute the same & see the results.

I am unable to figure out  how to:  See Test Coverage (Percentage/Lines covered) for an apex class  - within the IDE. 

I would appreciate the steps or pointers in this direction. 
 

Hi There,

We have an integration that listens to anything changed on a user record and push the change to the down steam systems.
Now, the sytem that listens to it cant anchor on a specific field for e.g. LastModifiedDate and hence if the LastReferencedDate and LastViewedDate is updated it also counts that as an update and push a bulk load of data without need.

Has anyone come across this ?

How can we avoid it?

Please advise.

 

 

Hi all, 
I am trying to complete below challenge and getting an error. I have copied all details(Challange Link, Code and Error).  

Appreciate your help!


CHALLENGE NAME

https://trailhead.salesforce.com/content/learn/modules/apex_metadata_api/apex_metadata_api_tools?trailmix_creator_id=strailhead&trailmix_slug=prepare-for-your-salesforce-platform-developer-ii-credential

CODE
public class MetadataExample {
    
    public  Metadata.CustomMetadata customMetadata{get;set;}
    public void updateMetadata(){
        
        customMetadata  = new Metadata.CustomMetadata();
        customMetadata.fullName  = 
            'MyNamespace__MyMetadataTypeName.MyMetadataRecordName';
        
        Metadata.CustomMetadataValue customField = new Metadata.CustomMetadataValue();
        customField.field = 'customField__c ';
        customField.value = 'New Value';
        
        customMetaData.values.add(customField);
        
        Metadata.DeployContainer deployContainer = new Metadata.DeployContainer();
        deployContainer.addMetadata(customMetaData);
        Id asyncResultId  = Metadata.Operations.enqueueDeployment(deployContainer, null);
    }
}

ERROR





 
I am baffled my the ability of Happysoup.io to access my salesforce org. I did not create a connected app or did anything else to connect my Salesforce org. A simple login. 

The documentaion on it's website mentions creating a connected application if we want to host the application on premise.  

I looked into 'Connected App Usage' - there is an entry for 'Heroku Connect' - I did not create this app - Neither do I see this app under Connected Apps list!

Has Salesforce 'behind the scenes' made it possible for Heroku apps to integrate with Salesforce - by embedding a Connected app in all Salesforce orgs by default? 

Could someone please help me explain how is HappySoup able to connect to my Org?  



 
Hey Devs,

For the following my test class  code coverage doesnt seem to go up above 75%, This is my first test class.
Any thoughts on how to improve the code coverage are much appreciated.

Actual Class

public class EngagementSharepointFolderCreation {
    @InvocableMethod(label='Setup Engagements Folder structure in Sharepoint' description='Creates accounts with children of Opportunities and Deliverables')
    public static void CreateEngagementsFolder (List<String> engagementId){
        CreateEngagementsFolderHierarchy(engagementId);
    }
    @future(callout=true)
    public static void CreateEngagementsFolderHierarchy(List<String> lstOfEngagementIds){
        try{
            // get the Engagement
            
            List<pse__Proj__c> lstOfEngagementRecs = [Select Id, Engagement_SharePoint_Folder_Name__c, AccountEngagementSharePointFolderIdOnEng__c,pse__Account__c, pse__Account__r.Name, pse__Account__r.Account_Engagement_SharePoint_Folder_Id__c, pse__Opportunity__r.Name,pse__Account__r.Opportunity_Sharepoint_Folder_Id__c, pse__Proj__c.Engagement_Sharepoint_Folder_Id__c from pse__Proj__c where Id = :lstOfEngagementIds];
            
            List<Account> lstOfAccountsToPSEFolderIds = new List<Account>();
            
            List<Opportunity> lstOfOppPSEFolderIds = new List<Opportunity>();
            
            
            //get auth info from the Settings MDT
            fileforcem1__Sharepoint_Settings__mdt orgSettings = [SELECT fileforcem1__Named_Credential__c,fileforcem1__Document_Library_Id__c,fileforcem1__Site_Id__c FROM fileforcem1__Sharepoint_Settings__mdt WHERE Developername = 'Default' limit 1];
            
            //Initialize the client object
            fileforcem1.ClientApi apiClient = new fileforcem1.ClientApi();
            apiClient.namedCredentialName = orgSettings.fileforcem1__Named_Credential__c;
            
            
            //get the root folder id for the Engagement -- Need to check whats this?
            fileforcem1__SharePoint_Object_Settings__mdt objectSettings = [SELECT fileforcem1__Root_Folder_Id__c,fileforcem1__Site_Id__c,fileforcem1__Document_Library_Id__c,fileforcem1__Initial_Folder_Structure__c FROM fileforcem1__Sharepoint_Object_Settings__mdt WHERE MasterLabel ='pse__Proj__c' LIMIT 1 ];
            
            apiClient.sharepointSiteId = objectSettings.fileforcem1__Site_Id__c;
            apiClient.documentLibraryId = objectSettings.fileforcem1__Document_Library_Id__c;
            for(pse__Proj__c  engagement : lstOfEngagementRecs){
                String accFolderId;
                fileforcem1.SharepointFileInfo accFolder;
                if (String.isBlank(engagement.pse__Account__r.Account_Engagement_SharePoint_Folder_Id__c))
                {
                    //Create the Customer Account folder and record the ID
                    
                    if (!Test.isRunningTest()) {
                        accFolder = apiClient.createFolder(Label.PSA_CCX_Account, engagement.pse__Account__r.Name);
                        accFolderId = accFolder.Id;
                        lstOfAccountsToPSEFolderIds.add(new Account(Id = engagement.pse__Account__c, Account_Engagement_SharePoint_Folder_Id__c = accFolder.Id));
                    } else {accFolder=new fileforcem1.SharepointFileInfo();}
                    
                }else{
                    accFolderId = engagement.pse__Account__r.Account_Engagement_SharePoint_Folder_Id__c;
                }
                
                //Create the opportunity folder and record the ID
                fileforcem1.SharepointFileInfo oppFolder;
                if (!Test.isRunningTest()) {
                    oppFolder = apiClient.createFolder(accFolderId, engagement.pse__Opportunity__r.Name);
                    lstOfOppPSEFolderIds.add(new Opportunity(Id = engagement.pse__Opportunity__c, Opportunity_PSA_Sharepoint_Folder_Id__c = oppFolder.Id));
                } else{ oppFolder = new fileforcem1.SharepointFileInfo();}
                System.debug('Opp Folder created successfully'+oppFolder.Id);
                
                //Create PSE folder
                
                fileforcem1.SharepointFileInfo pseFolder;
                if (!Test.isRunningTest()){
                pseFolder = apiClient.createFolder(oppFolder.Id, engagement.Engagement_SharePoint_Folder_Name__c);
                engagement.sharepoint_folder_id__c = pseFolder.Id;
                }
                //Create Deliverables Folder under opportunity
                fileforcem1.SharepointFileInfo Deliverable1Folder;
                if (!Test.isRunningTest()) {
                    Deliverable1Folder  = apiClient.createFolder(pseFolder.Id, 'Deliverables');
               
                }
                else {Deliverable1Folder = new fileforcem1.SharepointFileInfo(); }
                engagement.Deliverable_Folder_Id__c= Deliverable1Folder.Id;
                System.debug('Deliverable Folder created successfully'+Deliverable1Folder.Id);
            }
            
            // update Account Engagement Folder Id 
            if(!lstOfAccountsToPSEFolderIds.isEmpty()){
                update lstOfAccountsToPSEFolderIds;
            }
            // update Opportunity Engagement Folder Id
            if(!lstOfOppPSEFolderIds.isEmpty()){
                update lstOfOppPSEFolderIds;
            }
            
            //update the opportunity to save the IDs
            update lstOfEngagementRecs;
        }
        
        catch(DmlException e) {
            System.debug('The following exception has occurred: ' + e.getMessage());
        }
    }
}

The Test Class for the same

 // Engagement(Deliverable) folder test class creation
    
  static testMethod void folderCreationTestEngagement()
  {
      
  Test.StartTest();         
  
  //Create Accounts To be related to Engagement
 
  Account customerAccTobeRelatedToEngagement = new Account();
  customerAccTobeRelatedToEngagement.Name ='TestCustomerAccountTobeRelatedToEngagement';
  customerAccTobeRelatedToEngagement.Type ='Customer';
  customerAccTobeRelatedToEngagement.D_Invoice_Delivery_Method__c= 'Email';
  customerAccTobeRelatedToEngagement.D_Historic_Customer_Folder_Locations__c= 'HistoricCustomerFolderLocation';  
  insert customerAccTobeRelatedToEngagement;
  System.debug('The new inserted account' + customerAccTobeRelatedToEngagement);    
      
  Account prospectAccTobeRelatedToEngagement = new Account();    
  prospectAccTobeRelatedToEngagement.Name='TestProspectAccountTobeRelatedToEngagement';
  prospectAccTobeRelatedToEngagement.Type='Prospect';
  prospectAccTobeRelatedToEngagement.D_Invoice_Delivery_Method__c='Email';
  prospectAccTobeRelatedToEngagement.D_Historic_Customer_Folder_Locations__c='HistoricCustomerFolderLocation';    
  prospectAccTobeRelatedToEngagement.D_External_ID_From_Legacy_Systems__c='ExternalId';    
  insert prospectAccTobeRelatedToEngagement;
  System.debug('The new inserted prospect account' + prospectAccTobeRelatedToEngagement); 

   //add account ids to be related to the Engagement to the list
  List<String> accIDsTobeRelatedToEngagement = new List<String>();
  accIDsTobeRelatedToEngagement.add(customerAccTobeRelatedToEngagement.Id); 
  accIDsTobeRelatedToEngagement.add(prospectAccTobeRelatedToEngagement.Id);     
       
  //Create Account Folders in SharePoint    
  AccountSharepointFolderCreation.CreateAccountFolder(accIDsTobeRelatedToEngagement);
    
    If (customerAccTobeRelatedToEngagement.SharePoint_Folder_Id__c<>'')  {
      System.debug('Account SharePoint FolderID: ' + customerAccTobeRelatedToEngagement.SharePoint_Folder_Id__c);}
    else if (customerAccTobeRelatedToEngagement.Opportunity_Sharepoint_Folder_Id__c<>'')  {
        System.debug('Account Opp SharePoint FolderID: ' + customerAccTobeRelatedToEngagement.Opportunity_Sharepoint_Folder_Id__c);}
    else if (customerAccTobeRelatedToEngagement.Contracts_Sharepoint_Folder_Id__c<>'')  {
        System.debug('Account Contract SharePoint FolderID: ' + customerAccTobeRelatedToEngagement.Contracts_Sharepoint_Folder_Id__c);}
    else if (customerAccTobeRelatedToEngagement.Contracts_Sharepoint_Folder_Id__c<>'')  {
        System.debug('Account Contract SharePoint FolderID: ' + customerAccTobeRelatedToEngagement.Contracts_Sharepoint_Folder_Id__c); }
    else if (customerAccTobeRelatedToEngagement.Finance_Sharepoint_Folder_Id__c<>'')  {
        System.debug('Account Finance SharePoint FolderID: ' + customerAccTobeRelatedToEngagement.Finance_Sharepoint_Folder_Id__c); }
    else if (customerAccTobeRelatedToEngagement.Archive_Sharepoint_Folder_Id__c<>'') {
        System.debug('Account Archive SharePoint FolderID: ' + customerAccTobeRelatedToEngagement.Archive_Sharepoint_Folder_Id__c);}
  
  //Create Opportunity to be related to Engagement
  Opportunity newCustomerOppTestCustomerOppTobeRelatedtoEngagement = new Opportunity();  
  newCustomerOppTestCustomerOppTobeRelatedtoEngagement.Name='TestCustomerOppTobeRelatedOpportunity';
  newCustomerOppTestCustomerOppTobeRelatedtoEngagement.Type='New Sale';    
  newCustomerOppTestCustomerOppTobeRelatedtoEngagement.CloseDate=System.today();
  newCustomerOppTestCustomerOppTobeRelatedtoEngagement.StageName='Discovery & Qualification';
  newCustomerOppTestCustomerOppTobeRelatedtoEngagement.AccountId=customerAccTobeRelatedToEngagement.Id;
  insert newCustomerOppTestCustomerOppTobeRelatedtoEngagement;

    
  Opportunity newProspectOppTobeRelatedtoEngagement = new Opportunity();     
  newProspectOppTobeRelatedtoEngagement.Name='TestCustomerOpp';
  newProspectOppTobeRelatedtoEngagement.Type='New Sale';
  newProspectOppTobeRelatedtoEngagement.CloseDate=System.today();
  newProspectOppTobeRelatedtoEngagement.StageName='Discovery & Qualification';
  newProspectOppTobeRelatedtoEngagement.AccountId=prospectAccTobeRelatedToEngagement.Id;
  insert newProspectOppTobeRelatedtoEngagement;
     
    
  List<String> oppIDsToBeRelatedToEngagement = new List<String>();
  oppIDsToBeRelatedToEngagement.add(newCustomerOppTestCustomerOppTobeRelatedtoEngagement.Id); 
  oppIDsToBeRelatedToEngagement.add(newProspectOppTobeRelatedtoEngagement.Id);     
 

  //Create Opportunity Folders in SharePoint
  OpportunitySharepointFolderCreation.CreateOpportunityFolder(oppIDsToBeRelatedToEngagement);

    If (newCustomerOppTestCustomerOppTobeRelatedtoEngagement.fileforcem1__Sharepoint_Folder_Id__c <>'')  {
      System.debug('Opp SharePoint FolderID: ' + newCustomerOppTestCustomerOppTobeRelatedtoEngagement.fileforcem1__Sharepoint_Folder_Id__c);}
    else if (newCustomerOppTestCustomerOppTobeRelatedtoEngagement.Quotes_Sharepoint_Folder_Id__c<>'')  {
        System.debug('Opp Quotes SharePoint FolderID: ' + newCustomerOppTestCustomerOppTobeRelatedtoEngagement.Quotes_Sharepoint_Folder_Id__c);}
    else if (newCustomerOppTestCustomerOppTobeRelatedtoEngagement.Proposal_Sharepoint_Folder_Id__c<>'')  {
        System.debug('Opp Proposals SharePoint FolderID: ' + newCustomerOppTestCustomerOppTobeRelatedtoEngagement.Proposal_Sharepoint_Folder_Id__c);}
    else if (newCustomerOppTestCustomerOppTobeRelatedtoEngagement.Signed_Contracts_Sharepoint_Folder_ID__c<>'')  {
        System.debug('Opp Signed Contracts SharePoint FolderID: ' + newCustomerOppTestCustomerOppTobeRelatedtoEngagement.Signed_Contracts_Sharepoint_Folder_ID__c); }
    else if (newCustomerOppTestCustomerOppTobeRelatedtoEngagement.Customer_Invoices_Folder_Id__c<>'')  {
        System.debug('Opp Customer Invoices SharePoint FolderID: ' + newCustomerOppTestCustomerOppTobeRelatedtoEngagement.Customer_Invoices_Folder_Id__c); }
    else if (newCustomerOppTestCustomerOppTobeRelatedtoEngagement.Vendor_Sharepoint_Folder_Id__c<>'') {
        System.debug('Opp Vendor SharePoint FolderID: ' + newCustomerOppTestCustomerOppTobeRelatedtoEngagement.Vendor_Sharepoint_Folder_Id__c);}
  
            
  //Create Engagement 
  pse__Proj__c NewEngagement1 = new pse__Proj__c();
  NewEngagement1.RecordTypeId = '0124Y000000502fQAA'; //Client
  NewEngagement1.Name='TestEngagementCreatedForMilestone';
  NewEngagement1.Account__c = customerAccTobeRelatedToEngagement.Id;
  NewEngagement1.Opportunity__c = newCustomerOppTestCustomerOppTobeRelatedtoEngagement.Id;
 // Query the regions to be used and assigned
   List<pse__Region__c> regionresultsforvic  = [SELECT Name FROM pse__Region__c WHERE Name = 'Victoria' Limit 1]; 
  if (regionresultsforvic.size()>0)
{
   NewEngagement1.pse__Region__c = regionresultsforvic[11].Name;

}
  NewEngagement1.pse__Start_Date__c = System.today();
  NewEngagement1.pse__End_Date__c = System.today();  
  NewEngagement1.pse__Practice__c = 'aDt4Y000000000aSAA';
    
  System.debug('practice name inserted' + NewEngagement1.pse__Practice__c);
  insert NewEngagement1;
 
  //Create Engagement2 
  pse__Proj__c NewEngagement2 = new pse__Proj__c();
  NewEngagement2.RecordTypeId = '0124Y000000502BQAQ'; // Global // Internal 0124Y000000502aQAA // 0124Y000000502kQAA
  NewEngagement2.Name='TestEngagementCreatedForMilestone2';
  NewEngagement2.Account__c = customerAccTobeRelatedToEngagement.Id;
  NewEngagement2.Opportunity__c = newCustomerOppTestCustomerOppTobeRelatedtoEngagement.Id;
 // Query the regions to be used and assigned
   List<pse__Region__c> regionresultsforqld  = [SELECT Name FROM pse__Region__c WHERE Name = 'Queensland' Limit 1]; 
  if (regionresultsforqld.size()>0)
{
   NewEngagement1.pse__Region__c = regionresultsforqld[6].Name;

}
  NewEngagement1.pse__Start_Date__c = System.today();
  NewEngagement1.pse__End_Date__c = System.today();  
  NewEngagement1.pse__Practice__c = 'aDt4Y000000000aSAA';
    
  System.debug('practice name inserted' + NewEngagement2.pse__Practice__c);
  insert NewEngagement2;
 
      
  List<String> milestoneIDs = new List<String>();
  milestoneIDs.add(NewEngagement1.Id); 
  milestoneIDs.add(NewEngagement2.Id); 
 /* milestoneIDs.add(NewEngagement3.Id); 
  milestoneIDs.add(NewEngagement4.Id); */
     
  //Create Milestone Folders in SharePoint
  AutomaticmilestonesharepointFolder.CreateMilestoneFolder(milestoneIDs);    

 If (NewEngagement1.sharepoint_folder_id__c <>'')  {
      System.debug('Milestone SharePoint FolderID: ' + NewEngagement1.sharepoint_folder_id__c);}
 If (NewEngagement2.sharepoint_folder_id__c <>'')  {
      System.debug('Milestone SharePoint FolderID: ' + NewEngagement2.sharepoint_folder_id__c);}
 /* If (NewEngagement3.sharepoint_folder_id__c <>'')  {
      System.debug('Milestone SharePoint FolderID: ' + NewEngagement3.sharepoint_folder_id__c);}
  If (NewEngagement4.sharepoint_folder_id__c <>'')  {
      System.debug('Milestone SharePoint FolderID: ' + NewEngagement4.sharepoint_folder_id__c);} */
 
  Test.stopTest();
  }