• Paweł Woźniak
  • NEWBIE
  • 20 Points
  • Member since 2014
  • Developer
  • Fibratus

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 4
    Replies
In my org I have strange problem that users are unable to send emails with big attachemnts > 4MB by Lighning Action on Opportunity.
Salesforce in such case wanrn you that attachemtns will be converted to links and as soon as you agree it ends up with message Check the errors on this page: null.
User-added image
Admin users are abe to send. 
What I have done:
- Granted user all possible permisions with permission set including Modiy All data
- Changed profile to Administrator
- Compared profile settings between user who is able to send and this one
- Setup Libraries as is written in SF documentation
- Catch debug logs with all categories set to finest for this user - log has status success and no errors inside.
- Contacted SF support, but they don't know what is an issue

I ho no more ideas what to change. Have anyone seen such error and can advise what to do?

HTML for error:
<div class="pageLevelErrors" data-aura-rendered-by="4:1777;a">
	<div class="desktop forcePageError" aria-live="assertive" data-aura-rendered-by="3:5374;a" data-aura-class="forcePageError">
		<div class="genericNotification" data-aura-rendered-by="5:5374;a">
			<span class="genericError uiOutputText" data-aura-rendered-by="8:5374;a" data-aura-class="uiOutputText">Überprüfen Sie die Fehler auf dieser Seite.</span>
		</div>
		<ul class="errorsList" data-aura-rendered-by="9:5374;a">
			<li data-aura-rendered-by="11:5374;a">null</li>
		</ul><!--render facet: 13:5374;a--><!--render facet: 14:5374;a-->
	</div>
</div>


 
Hi.

Happy about finally delivering option to get recordId by developer name, see relase info https://releasenotes.docs.salesforce.com/en-us/summer18/release-notes/rn_apex_developer_name.htm I wanted to use it. It works perfectly on Anonymous execution, however if used in apex class it is not possible to save due to method does not exists error.
Id devRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('PersonAccount').getRecordTypeId();
System.debug(devRecordTypeId);
In anonymous execution it returns a value in debug. Using in apex class gives an error:
Method does not exist or incorrect signature: void getRecordTypeInfosByDeveloperName() from the type Schema.DescribeSObjectResult
Do we have SF peoples here? Can you please fix it.
 
Is there a way to login to SF from custom python script without using login and password?
I mean something similar to SSH key authentication.

Scrip is using BulkAPI to insert data records when CSV file is provided in drop folder.

Hi. 
I want to replace some specific words in string with anothers using pattern and matcher. Example: I want format nicely SOQL query so:
[ SELECT Id, Name FROM Account WHERE Name =  'John' ]
should be changed to:
[SELECT
    Id, Name
FROM
    Account
WHERE 
    Name = 'John']

The code:
 

String convertInput = '[ SELECT Id, Name FROM Account WHERE Name =  \'John\' ]';
String convertOutput = '';
String regExp = '(SELECT|FROM|WHERE)';

Pattern p = Pattern.compile(regExp);      
Matcher m = p.matcher(convertInput);
    while (m.find() == true) {          
        convertOutput = m.replaceFirst('\n' + m.group(1) + '\n');

    } 
System.debug(convertOutput);

Gives error: System.LimitException: Regex too complicated

Where code:
String convertInput = '[ SELECT Id, Name FROM Account WHERE Name =  \'John\' ]';
String convertOutput = '';
String regExp = '(SELECT|FROM|WHERE)';

Pattern p = Pattern.compile(regExp);      
Matcher m = p.matcher(convertInput);
    while (m.find() == true) {          
        convertOutput = m.replaceAll('\n' + m.group(1) + '\n');
    } 
System.debug(convertOutput);

Gives output:
SELECT
Id, Name
SELECT
Account
SELECT
Name = 'John' ]

So I am confused what is so complicated in replaceFirst?
Do you have any suggestions how to solve that?
Hi,
I have an junction object with three lookup fields to three budget types (other objects). They are filled in depended on selected record type.
As result of formula I want to have 18 character Id.
Formula:
CASE(RecordType.Name,
'Product Budget', EMS_Product_Budget_gne__r.Id,
'Region Budget', EMS_Region_Budget_gne__r.Id,
EMS_Territory_Budget_gne__r.Id)

Compiled size: 523 characters. Great but it returns 15char Id. Lets use CASESAFEID()
CASESAFEID( CASE(RecordType.Name,
'Product Budget Allocation', EMS_Product_Budget_gne__r.Id,
'Region Budget Allocation', EMS_Region_Budget_gne__r.Id,
EMS_Territory_Budget_gne__r.Id) )

Error: Compiled formula is too big to execute (9,780 characters). Maximum size is 5,000 characters.
CASE(RecordType.Name,
'Product Budget Allocation', CASESAFEID( EMS_Product_Budget_gne__r.Id),
'Region Budget Allocation', CASESAFEID( EMS_Region_Budget_gne__r.Id),
CASESAFEID( EMS_Territory_Budget_gne__r.Id) )

Error: Compiled formula is too big to execute (8,374 characters). Maximum size is 5,000 characters

Why is it that expensive? Is there a way to wokaround this?



Hi,
I have an junction object with three lookup fields to three budget types (other objects). They are filled in depended on selected record type.
As result of formula I want to have 18 character Id.
Formula:
CASE(RecordType.Name,
'Product Budget', EMS_Product_Budget_gne__r.Id,
'Region Budget', EMS_Region_Budget_gne__r.Id,
EMS_Territory_Budget_gne__r.Id)

Compiled size: 523 characters. Great but it returns 15char Id. Lets use CASESAFEID()
CASESAFEID( CASE(RecordType.Name,
'Product Budget Allocation', EMS_Product_Budget_gne__r.Id,
'Region Budget Allocation', EMS_Region_Budget_gne__r.Id,
EMS_Territory_Budget_gne__r.Id) )

Error: Compiled formula is too big to execute (9,780 characters). Maximum size is 5,000 characters.
CASE(RecordType.Name,
'Product Budget Allocation', CASESAFEID( EMS_Product_Budget_gne__r.Id),
'Region Budget Allocation', CASESAFEID( EMS_Region_Budget_gne__r.Id),
CASESAFEID( EMS_Territory_Budget_gne__r.Id) )

Error: Compiled formula is too big to execute (8,374 characters). Maximum size is 5,000 characters

Why is it that expensive? Is there a way to wokaround this?



Hi.

Happy about finally delivering option to get recordId by developer name, see relase info https://releasenotes.docs.salesforce.com/en-us/summer18/release-notes/rn_apex_developer_name.htm I wanted to use it. It works perfectly on Anonymous execution, however if used in apex class it is not possible to save due to method does not exists error.
Id devRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('PersonAccount').getRecordTypeId();
System.debug(devRecordTypeId);
In anonymous execution it returns a value in debug. Using in apex class gives an error:
Method does not exist or incorrect signature: void getRecordTypeInfosByDeveloperName() from the type Schema.DescribeSObjectResult
Do we have SF peoples here? Can you please fix it.
 
I've gone through every step successfully but am banging my head against the wall with step 8. I have more than adequate code coverage but continue to get this error message:
User-added image
I have gone back and rewritten OrderTests twice according to the requirements but can't get past this error. Anyone else had any luck with this?

Here's my code for reference:
@isTest (SeeAllData=false)
private class OrderTests {
    
    static void SetupTestData() {
	    TestDataFactory.InsertTestData(5);
    }
 
    @isTest static void OrderExtension_UnitTest() {
        PageReference pageRef = Page.OrderEdit;
        Test.setCurrentPage(pageRef);
        SetupTestData();
        ApexPages.StandardController stdcontroller = new ApexPages.StandardController(TestDataFactory.orders[0]);        
        OrderExtension ext = new OrderExtension(stdcontroller);        
       	System.assertEquals(Constants.DEFAULT_ROWS, ext.orderItemList.size());
        ext.OnFieldChange();
        ext.SelectFamily();
        ext.Save();
        ext.First();
        ext.Next();
        ext.Previous();
        ext.Last();
        ext.GetHasPrevious();
        ext.GetHasNext();
        ext.GetTotalPages();
        ext.GetPageNumber();
        List<SelectOption> options = ext.GetFamilyOptions();
    }
    
@isTest
public static void OrderUpdate_UnitTest(){
    setupTestData();
    
   
    Test.startTest();
    
    List<Order> orders = TestDataFactory.orders;
    for (Order o : orders){
        o.Status = Constants.ACTIVATED_ORDER_STATUS;
    }
    List<Product2> oldProducts = TestDataFactory.products;
    Set<Id> productIds = new Set<Id>();
    for (Product2 oldProd : oldProducts){
        productIds.add(oldProd.Id);
    }
    oldProducts = [SELECT Id, Quantity_Ordered__c FROM Product2 WHERE ID IN :productIds];
    Map<Id, Integer> quantities = new Map<Id, Integer>();
    for (OrderItem oi : TestDataFactory.orderItems){
        Integer quantity = 0;
        List<PricebookEntry> pricebookentries = TestDataFactory.pbes;
        for (PricebookEntry pbe : pricebookentries){
            if (oi.PricebookEntryId == pbe.Id){                
                if (quantities.containsKey(pbe.Product2Id)){
                    quantity = quantities.get(pbe.Product2Id);
                }
                quantity += (Integer)oi.Quantity;
                quantities.put(pbe.Product2Id, quantity);
                break;
            }
        }
    }
   
    update orders;
    Map<Id, Product2> currentProducts = new Map<Id, Product2>([Select Id, Quantity_Ordered__c FROM Product2 WHERE Id IN :productIds]);
  
    for (Product2 prod : oldProducts){
      
        TestDataFactory.VerifyQuantityOrdered(prod, currentProducts.get(prod.Id), quantities.get(prod.Id));
  }
  Test.stopTest();
}
}

 
Our production deployments using the (ant) force migration tool have been consistently failing recently, after executing some percentage of our tests, with the error:

System.LimitException: Your runAllTests request is using too many DB resources.

All of our tests are @isTest(seeAllData=false) and we recreate all test data from scratch using factory classes at the beginning of each test method.

We contacted Salesforce support, and after a multiple calls, different people, and a lot of time, they told us that in addition to the per-transaction governor limits, there are undocumented limits that are shared amongst all executed code during the course of a runAllTests request:
  • The DML statement limit is 350,000
  • The SOQL statement limit is 450,000
Salesforce suggested that we use the @testSetup annotation to setup data in our tests (we have not been using that annotation), and this would help us in avoiding hitting the above limits. I wrote a small unit test to verify that this would actually help with limits, but the unit test suggests that the DML statements accrued in a @testSetup annotated method do indeed count in each testmethod.
@isTest(seeAllData=false)
public class TestSalesforceTestSetupDMLCount {

    @testSetup static void setup(){
        // Assert that no DMLs have occurred yet
        system.assertEquals(0, Limits.getDMLStatements());
        
        // Perform 4 DMLs
        for(Integer i=0; i<4; i++){
            insert new Account(Name='Test' + i);
        }
        
        // Assert that 4 DMLs have been performed
        system.assertEquals(4, Limits.getDMLStatements());
    }
    
    public static testmethod void testDmlCount1(){
		// THIS ASSERTION FAILS
        system.assertNotEquals(4, Limits.getDMLStatements());
    }
    
    public static testmethod void testDmlCount2(){
        // THIS ASSERTION FAILS
        system.assertNotEquals(4, Limits.getDMLStatements());
    }
}

The 2 testmethods fail because Limits.getDMLStatements() returns 4. The question is, regarding the runAllTests DML statement limit of 350,000, does the above test contribute 4 DML statements or does it contribute 12 DML statements (4 for setup(), 4 for testDmlCount1(), 4 for testDmlCount2())?

This is obviously something that only Salesforce can answer, but I at least want this issue documented somewhere, and will provide updates as we get answers from Salesforce.

Hi. 
I want to replace some specific words in string with anothers using pattern and matcher. Example: I want format nicely SOQL query so:
[ SELECT Id, Name FROM Account WHERE Name =  'John' ]
should be changed to:
[SELECT
    Id, Name
FROM
    Account
WHERE 
    Name = 'John']

The code:
 

String convertInput = '[ SELECT Id, Name FROM Account WHERE Name =  \'John\' ]';
String convertOutput = '';
String regExp = '(SELECT|FROM|WHERE)';

Pattern p = Pattern.compile(regExp);      
Matcher m = p.matcher(convertInput);
    while (m.find() == true) {          
        convertOutput = m.replaceFirst('\n' + m.group(1) + '\n');

    } 
System.debug(convertOutput);

Gives error: System.LimitException: Regex too complicated

Where code:
String convertInput = '[ SELECT Id, Name FROM Account WHERE Name =  \'John\' ]';
String convertOutput = '';
String regExp = '(SELECT|FROM|WHERE)';

Pattern p = Pattern.compile(regExp);      
Matcher m = p.matcher(convertInput);
    while (m.find() == true) {          
        convertOutput = m.replaceAll('\n' + m.group(1) + '\n');
    } 
System.debug(convertOutput);

Gives output:
SELECT
Id, Name
SELECT
Account
SELECT
Name = 'John' ]

So I am confused what is so complicated in replaceFirst?
Do you have any suggestions how to solve that?