• Muhariz Jabeer
  • NEWBIE
  • 0 Points
  • Member since 2018
  • Deloitte


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 2
    Replies
We recently added v2Campaign Influence to our solution and require the CRM User Permission Set License to be available in our target deployment environments. All our sandboxes have this Permission Set License which makes deployment to sandboxes and prod successful. However, deployment to Scratch Orgs fail because CRM User license is disabled and unavailable in Scratch Orgs. 

User-added image

Is there a way to enable CRM User in scratch orgs?
Hi

I am doing the 'Asynchronous Apex' module's 2nd part 'Use Future Methods' on Trailheads and had a question regarding SOQL best practice. The directs us to create a method that accepts a list of Account IDs, and update a custom field on the Account called 'number of contacts'. I passed the module but would like to engage in open discourse about SOQL best practices in regards to queries and iteration. The entire code block is as follows:
 
public without sharing class AccountProcessor {
    
    @future
    public static void countContacts(List<Id> accountList){        
        
        // Get all the Contact records with a Parent Account belonging to the above list 'accountList'
        List<Contact> contactsToCount = [ SELECT Id, LastName, AccountId 
                                          FROM CONTACT
                                          WHERE AccountId IN : accountList];
        
        // Create a hashmap of ID to Account so that we can efficiently access them to update their individual contact counts
        Map<Id, Account> accountsToUpdateMap = new Map<Id, Account>([SELECT Id, Name, Number_of_Contacts__c
                                                                    FROM Account
                                                                    WHERE Id IN : accountList]);
        
        // obtain the Accounts from the above into a list for both zeroing existing contact count AND DML update at the end
        List<Account> accountsToUpdateList = (List<Account>) accountsToUpdateMap.values();
        for(Account acc : accountsToUpdateList) {
            acc.Number_of_Contacts__c = 0;
        }
        
        // go through every contact which has a parent account from the list and sequentially increase the parent's contact count
        for(Contact con : contactsToCount) {
            // check to see whether there is a parent to begin with (orhphaned contacts)
            if(con.AccountId != null && accountsToUpdateMap.containsKey(con.AccountId)){ // the last check is not needed
                Account accountToUpdate = accountsToUpdateMap.get(con.AccountId);
                accountToUpdate.Number_of_Contacts__c += 1;
            }
        }
        
        for(Account acc : accountsToUpdateList) {
            System.debug('*** [Output] Account Name: ' + acc.Name + '   Num Contacts: ' + acc.Number_of_Contacts__c);
        }
        
        update accountsToUpdateList;
    }
}

I am looking for feedback on SOQL query usage and possibility of optimisation/scalability pitfalls in the above code block.

Thanks in advance
Muhariz.
Is it possible to pass tokens (i.e.: custom field values within a Work Order or Service Appointment) from the FSL Mobile App to the Salesforce App, without using a fully qualified url?

I have successfully created a custom App Extension (under Field Service Mobile Settings) to launch the main Salesforce App and bring up a Lightning Page Tab. I simply specified the name of the Lightning Page in the Launch Value of the App Extension.

However, this lightning page houses a VisualForce page that requires parameters to be sent to it from the FSL app. I have not been able to do this using the above method.

Thoug, I have managed to get it working by explicitly setting the Launch Value in the App Extension to the URL of the VisualForce page (with the parameter I want tacked to the end. (i.e.: https://XXX/apex/FSLExtensionA?myparameter=someValue). This method works fine on Android, as Android prompts whether to open this link via the Salesforce App (as opposed to a web browser). It does NOT work on iOS as it simply opens the link on safari.

In summary, is there a way to pass parameters to a VisualForce page without using a fully qualified url? The Doco claims it is possible, if you house a VisualForce page within a lightning tab in the Salesforce app --> https://help.salesforce.com/articleView?id=mfs_extension.htm&type=5  - unfortunately I haven't been able to figure out how.
Is it possible to pass tokens (i.e.: custom field values within a Work Order or Service Appointment) from the FSL Mobile App to the Salesforce App, without using a fully qualified url?

I have successfully created a custom App Extension (under Field Service Mobile Settings) to launch the main Salesforce App and bring up a Lightning Page Tab. I simply specified the name of the Lightning Page in the Launch Value of the App Extension.

However, this lightning page houses a VisualForce page that requires parameters to be sent to it from the FSL app. I have not been able to do this using the above method.

Thoug, I have managed to get it working by explicitly setting the Launch Value in the App Extension to the URL of the VisualForce page (with the parameter I want tacked to the end. (i.e.: https://XXX/apex/FSLExtensionA?myparameter=someValue). This method works fine on Android, as Android prompts whether to open this link via the Salesforce App (as opposed to a web browser). It does NOT work on iOS as it simply opens the link on safari.

In summary, is there a way to pass parameters to a VisualForce page without using a fully qualified url? The Doco claims it is possible, if you house a VisualForce page within a lightning tab in the Salesforce app --> https://help.salesforce.com/articleView?id=mfs_extension.htm&type=5  - unfortunately I haven't been able to figure out how.