• Hunter Allspaugh
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 4
    Replies
I'm building a new class to act as an external connector to a project management service, AceProject.  The API is purely URL based, so I want to be able to make my http requests dynamically.  Trying to build a method to take the Map parameter and return it after it is converted into a string.

Currently, my solution is:
private static String buildHttpUrl(Map<String, String> params){
    String url = '';
			
    for (String key : params.keySet()){
        if (url.length() != 0){
            url += '&';
        }                
        url += key + '=' + params.get(key);
    } 
    return PRIVATE_STR_API + EncodingUtil.urlEncode(url, 'UTF-8');
}

Is there a way to do this without writing the math out?  I looked into String.join() but I don't know if I can make that work, since the format needs to be `&key=value`.
I'm trying to create a unit test class for a trigger that fires before insert on Leads so that Lead.Country will be used to lookup the Region (continent) from a custom Country__c table.

If I run a test insert, it will apply the correct Region value to the lead, but when I run unit tests to try to validate the behavior, it returns Null when the lookup to the country table happens.

My trigger code is:
 
trigger LeadsSetRegion on Lead (before insert) {    

    for (Lead l: Trigger.new){
        // Query for name of Region that contains Country
        try {
        	Country__c[] countries = [Select Region__c FROM Country__c WHERE Name=:l.Country];
        	System.debug(countries);
        	if (countries.size() > 0){

                l.Region__c = countries[0].Region__c;

            } 
        }catch (exception e){
            System.debug(e);
        }
    }
    
}
As stated before, this works perfectly fine when a lead is inserted. 

However, when building a unit test to attempt to get the Region, "Africa", the Country__c SOQL query in the trigger returns null:
 
@isTest
public class TestLeadsSetRegion {
    @isTest public static void TestLeadWithKnownCountry (){
        Lead l = new Lead(firstName='Test',lastName='Lead',company='Test Company',email='testlead123@test.com',Country='Nigeria',LeadSource='Contact Us');
        
        // Begin Testing
        Test.startTest();
        insert l;
        Test.stopTest();
        
        System.assertEquals('Africa', l.Region__c);
    }
}
Do I need to perform the lookup in a certain manner to retrieve these results?

 
While trying to implement a process with Process Builder to automatically fix mispellings or incorrect values of country names, I came across this behavior and I dont really understand it.

The field in question is BillingCountry.  To test this, I just wanted to work with one specific value, so I started with converting UNITED STATES to USA.  I created the process to make this change automatically when the record is edited, and immediately noticed that both BillingCountry and BillingCity get set to USA.  If I change the BillingCity back to the city it will stay correct, but if I set the BillingCountry back to UNITED STATES to trigger the process again, the BillingCity goes right back to USA.  The only action that is defined in the process is the update to "Map Country" which is the [Account].BillingCountry.

Is this a bug, or is there a better way to go about this?

Our schema when we migrated from the previous CRM to Salesforce was an absolute nightmare.  Once we moved to SF, I was granted the role as our SF admin.  After building our integration to our website, I thought I had grown to be very familiar with most of our data.  There is a specific permission that I need to grant on the website based on a pretty awful series of rollups that need to happen, but I'm struggling to get everything to work correctly.  I'll try to properly map out the chain of events that need to be followed.  I am using DLRS to do what I can.

The primary objects that need to be focused on are as follows (mostly custom objects): Account, License Servers, License Sites, License Products, License Content

License Product contains the determining value
License Content has a lookup to License Product and License Server
Account has a lookup to License Server but none of the others.
License Sites has a lookup to up to 2 different accounts ( main and secondary locations), but none of the others.

1) If License Content is associated with a License Product that contains a specific value, and the License Content expiration date is not past, then the value is equal to the amount of license seats exist in License Content.
2) If the License Content has this value > 0, then License Server sees this value as available seats for this desired License.
3) If License Server shows a positive number of active seats, then the Account will know that it has X amount of seats.

This is where it gets weird, because Account needs to reflect the total of available seats for both the License Site where it is the main location AND ALL of the License Sites where it is a secondary location.

So to add to the previous steps, Account needs to show a value equal to the number of seats from the site where it is the main location, PLUS all of the sites where it is the secondary location. 

Currently, what I have in place is as follows:

1) License_Content__c has a formula field to show active seats of the designated license if it has not expired.  (WORKS)
2) License_Server__c has a Number field where DLRS looks uses a lookup relationship From License_Server__c to License_Content__c where the lookup ID = the License_Server__c record. (WORKS)
3) Account needs to reflect the number of seats where it is a main location.  I have a DLRS rollup where the Parent is Account, the Child is License_Server__c and the relationship field is the ID of the Account.  The field to aggregate is the correctly populated field from step 2 (DOES NOT WORK - BLANK)
4) License_Sites__c needs to do its own separate rollup where each License_Site__c record reflects the number of active seats in its secondary location, so Accounts step 3 needs to function for this to work
5) Account now needs a rollup that contains the total number of license seats where it is a secondary location in License_Sites__c. 

This structure is horrible, but it has been in place for years and years, and I don't think there is any way we can consolidate and normalize.  I've been working on this problem for far too long, and I'm still running into issues with step 3, even though the correct values are in place and it just seems like the DLRS summary is not filling any values in.  This whole thing is super overwhelming because of how massively confusing it is, so there might be a really easy way to take care of this that I'm not seeing. 

Is there a simpler way to handle this?  Or do I need to change the way I am using these DLRS rollups?  Please let me know if any clarity is needed on the process that should be followed.

Our schema when we migrated from the previous CRM to Salesforce was an absolute nightmare.  Once we moved to SF, I was granted the role as our SF admin.  After building our integration to our website, I thought I had grown to be very familiar with most of our data.  There is a specific permission that I need to grant on the website based on a pretty awful series of rollups that need to happen, but I'm struggling to get everything to work correctly.  I'll try to properly map out the chain of events that need to be followed.  I am using DLRS to do what I can.

The primary objects that need to be focused on are as follows (mostly custom objects): Account, License Servers, License Sites, License Products, License Content

License Product contains the determining value
License Content has a lookup to License Product and License Server
Account has a lookup to License Server but none of the others.
License Sites has a lookup to up to 2 different accounts ( main and secondary locations), but none of the others.

1) If License Content is associated with a License Product that contains a specific value, and the License Content expiration date is not past, then the value is equal to the amount of license seats exist in License Content.
2) If the License Content has this value > 0, then License Server sees this value as available seats for this desired License.
3) If License Server shows a positive number of active seats, then the Account will know that it has X amount of seats.

This is where it gets weird, because Account needs to reflect the total of available seats for both the License Site where it is the main location AND ALL of the License Sites where it is a secondary location.

So to add to the previous steps, Account needs to show a value equal to the number of seats from the site where it is the main location, PLUS all of the sites where it is the secondary location. 

Currently, what I have in place is as follows:

1) License_Content__c has a formula field to show active seats of the designated license if it has not expired.  (WORKS)
2) License_Server__c has a Number field where DLRS looks uses a lookup relationship From License_Server__c to License_Content__c where the lookup ID = the License_Server__c record. (WORKS)
3) Account needs to reflect the number of seats where it is a main location.  I have a DLRS rollup where the Parent is Account, the Child is License_Server__c and the relationship field is the ID of the Account.  The field to aggregate is the correctly populated field from step 2 (DOES NOT WORK - BLANK)
4) License_Sites__c needs to do its own separate rollup where each License_Site__c record reflects the number of active seats in its secondary location, so Accounts step 3 needs to function for this to work
5) Account now needs a rollup that contains the total number of license seats where it is a secondary location in License_Sites__c. 

This structure is horrible, but it has been in place for years and years, and I don't think there is any way we can consolidate and normalize.  I've been working on this problem for far too long, and I'm still running into issues with step 3, even though the correct values are in place and it just seems like the DLRS summary is not filling any values in.  This whole thing is super overwhelming because of how massively confusing it is, so there might be a really easy way to take care of this that I'm not seeing. 

Is there a simpler way to handle this?  Or do I need to change the way I am using these DLRS rollups?  Please let me know if any clarity is needed on the process that should be followed.

I'm building a new class to act as an external connector to a project management service, AceProject.  The API is purely URL based, so I want to be able to make my http requests dynamically.  Trying to build a method to take the Map parameter and return it after it is converted into a string.

Currently, my solution is:
private static String buildHttpUrl(Map<String, String> params){
    String url = '';
			
    for (String key : params.keySet()){
        if (url.length() != 0){
            url += '&';
        }                
        url += key + '=' + params.get(key);
    } 
    return PRIVATE_STR_API + EncodingUtil.urlEncode(url, 'UTF-8');
}

Is there a way to do this without writing the math out?  I looked into String.join() but I don't know if I can make that work, since the format needs to be `&key=value`.
Setting up lightning for outlook, and can't sync the salesforce and outlook calendars (see screen shot)

Anyone face this issue before?? if so what was your solution??

User-added image
While trying to implement a process with Process Builder to automatically fix mispellings or incorrect values of country names, I came across this behavior and I dont really understand it.

The field in question is BillingCountry.  To test this, I just wanted to work with one specific value, so I started with converting UNITED STATES to USA.  I created the process to make this change automatically when the record is edited, and immediately noticed that both BillingCountry and BillingCity get set to USA.  If I change the BillingCity back to the city it will stay correct, but if I set the BillingCountry back to UNITED STATES to trigger the process again, the BillingCity goes right back to USA.  The only action that is defined in the process is the update to "Map Country" which is the [Account].BillingCountry.

Is this a bug, or is there a better way to go about this?

Our schema when we migrated from the previous CRM to Salesforce was an absolute nightmare.  Once we moved to SF, I was granted the role as our SF admin.  After building our integration to our website, I thought I had grown to be very familiar with most of our data.  There is a specific permission that I need to grant on the website based on a pretty awful series of rollups that need to happen, but I'm struggling to get everything to work correctly.  I'll try to properly map out the chain of events that need to be followed.  I am using DLRS to do what I can.

The primary objects that need to be focused on are as follows (mostly custom objects): Account, License Servers, License Sites, License Products, License Content

License Product contains the determining value
License Content has a lookup to License Product and License Server
Account has a lookup to License Server but none of the others.
License Sites has a lookup to up to 2 different accounts ( main and secondary locations), but none of the others.

1) If License Content is associated with a License Product that contains a specific value, and the License Content expiration date is not past, then the value is equal to the amount of license seats exist in License Content.
2) If the License Content has this value > 0, then License Server sees this value as available seats for this desired License.
3) If License Server shows a positive number of active seats, then the Account will know that it has X amount of seats.

This is where it gets weird, because Account needs to reflect the total of available seats for both the License Site where it is the main location AND ALL of the License Sites where it is a secondary location.

So to add to the previous steps, Account needs to show a value equal to the number of seats from the site where it is the main location, PLUS all of the sites where it is the secondary location. 

Currently, what I have in place is as follows:

1) License_Content__c has a formula field to show active seats of the designated license if it has not expired.  (WORKS)
2) License_Server__c has a Number field where DLRS looks uses a lookup relationship From License_Server__c to License_Content__c where the lookup ID = the License_Server__c record. (WORKS)
3) Account needs to reflect the number of seats where it is a main location.  I have a DLRS rollup where the Parent is Account, the Child is License_Server__c and the relationship field is the ID of the Account.  The field to aggregate is the correctly populated field from step 2 (DOES NOT WORK - BLANK)
4) License_Sites__c needs to do its own separate rollup where each License_Site__c record reflects the number of active seats in its secondary location, so Accounts step 3 needs to function for this to work
5) Account now needs a rollup that contains the total number of license seats where it is a secondary location in License_Sites__c. 

This structure is horrible, but it has been in place for years and years, and I don't think there is any way we can consolidate and normalize.  I've been working on this problem for far too long, and I'm still running into issues with step 3, even though the correct values are in place and it just seems like the DLRS summary is not filling any values in.  This whole thing is super overwhelming because of how massively confusing it is, so there might be a really easy way to take care of this that I'm not seeing. 

Is there a simpler way to handle this?  Or do I need to change the way I am using these DLRS rollups?  Please let me know if any clarity is needed on the process that should be followed.