• Piotr B. Kożuchowski
  • NEWBIE
  • 0 Points
  • Member since 2016
  • Senior Salesforce Developer

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies
I have a custom Auth. Provider and a couple of Named Credential which use it.
The auth. provider metadata requires "Execute As" field which is represented as username in metadata and as you know,
usernames are globally unique in Salesforce.

So the deployment will always fail, because user will never exist on another sandbox and at the same time, the username field cannot be left 
empty.

What is the proper approach in this case in source driven development?

For now, I will have to run a script which replaces username when new scratch org is created and when source is deployed to staging environments. It's obviously far from perfect solution, because my teamies will have to use custom script instead of sfdx force:org:create and because the username change will be visible in VCS every time someone creates a new scratch org.

I really hope someone from Salesforce DX development team will see this.

Hi All

When I create test user in unit tests and execute a batch that does callout, it fails with "Uncommited work pending" exception.
It happens only when I try to insert User, if I comment out "insert user" and leave any other SObject insertions, it will work just fine.

Do you know how can I get around this?
 

@TestSetup
    static void testSetup() {
        Profile p = [SELECT Id FROM Profile WHERE Name = 'System Administrator'];
        User usr = new User(
                FirstName = 'Test',
                LastName = 'User',
                Email = 'example@dev.sandbox.com',
                Username = 'example@dev.sandbox.com',
                ProfileId = p.Id,
                Alias = 'example',
                CommunityNickname = 'example',
                TimeZoneSidKey = 'GMT',
                LocaleSidKey = 'nl_NL',
                EmailEncodingKey = 'UTF-8',
                LanguageLocaleKey = 'en_US'
        );
        insert usr;
        insert new Account(Name = 'Test');
    }

    @IsTest
    static void testBehavior() {
        Test.startTest();
        Test.setMock(HttpCalloutMock.class, new TestMock());
        Database.executeBatch(new POC_BatchCallout());
        Test.stopTest();
    }
The batch in this example does nothing else, but callout.

Kind Regards
 

Hi All

When I create test user in unit tests and execute a batch that does callout, it fails with "Uncommited work pending" exception.
It happens only when I try to insert User, if I comment out "insert user" and leave any other SObject insertions, it will work just fine.

Do you know how can I get around this?
 

@TestSetup
    static void testSetup() {
        Profile p = [SELECT Id FROM Profile WHERE Name = 'System Administrator'];
        User usr = new User(
                FirstName = 'Test',
                LastName = 'User',
                Email = 'example@dev.sandbox.com',
                Username = 'example@dev.sandbox.com',
                ProfileId = p.Id,
                Alias = 'example',
                CommunityNickname = 'example',
                TimeZoneSidKey = 'GMT',
                LocaleSidKey = 'nl_NL',
                EmailEncodingKey = 'UTF-8',
                LanguageLocaleKey = 'en_US'
        );
        insert usr;
        insert new Account(Name = 'Test');
    }

    @IsTest
    static void testBehavior() {
        Test.startTest();
        Test.setMock(HttpCalloutMock.class, new TestMock());
        Database.executeBatch(new POC_BatchCallout());
        Test.stopTest();
    }
The batch in this example does nothing else, but callout.

Kind Regards
 

Hi,

 

We are using Custom Labels for the translation of our application. In Apex Code, the method getLabel() retrieve the value of a given label in the language of the user. For example to retrieve the value of custom label we use: 

 

Schema.DescribeFieldResult F = Quote__c.Quote_Comment__c.getDescribe();

F.getLabel();

 

This getLabel() method returns the text label in the language of the user. However, we would like to get it in other languages. 

 

Let's illustrate this with an example. We've built a multi-langual quote engine (that can print quote in pdf thanks to a Visualforce page). As of now the Quoteis generated in the language of the user. However, we would like the user to be able to manually select in which language the Quote needs to be printed.

Therefore we need to be able to retrieve all CustomLabels translation in the Apex Code controller of the page to display thefields in the correct language (as chosen by the user).

 

It does not seem possible to do something like getLabel('Spanish') to retrieve the label translated in Spanish. Does anyone can confirm Apex Code do not support such a functionality? 

 

Thanks a lot in advance, 

 

Alexandre 

Message Edited by a_pitsaer on 08-31-2009 06:30 AM
Message Edited by a_pitsaer on 08-31-2009 06:31 AM
Message Edited by a_pitsaer on 08-31-2009 09:04 AM