Tuesday 15 November 2016

Find flow details using ID

Find flow details using ID:

Using workbench:
in workbench we need to select Restexplorer:

Syntax:
/services/data/v37.0/tooling/sobjects/flow/id





Test class for product and pricebook

Test class for product and pricebook:

Product2 prod = new Product2(Name = 'Laptop X200',
                                     Family = 'Hardware');
        insert prod;
       
        Id pricebookId = Test.getStandardPricebookId();
       
        PricebookEntry standardPrice = new PricebookEntry(
            Pricebook2Id = pricebookId, Product2Id = prod.Id,
            UnitPrice = 10000, IsActive = true);
        insert standardPrice;
       
        Pricebook2 customPB = new Pricebook2(Name='Custom Pricebook', isActive=true);
        insert customPB;
       
        PricebookEntry customPrice = new PricebookEntry(
            Pricebook2Id = customPB.Id, Product2Id = prod.Id,
            UnitPrice = 12000, IsActive = true);
        insert customPrice;
       
        List<PricebookEntry> pbez = [SELECT ID, Product2Id, Pricebook2.isStandard, Pricebook2.isActive, isActive FROM PricebookEntry];
       
        system.debug(pbez[0].Pricebook2.isStandard);
        system.debug(pbez[0].Pricebook2.isActive);




test class best practices in salesforce

Test class best practices in sales-force:


we need to use System.assert / System.assertEquals in the test. How would you know you are             getting  what is expected from the test? There have to be assert statements.
we need to avoid @isTest(seeAlldata = true) ?
        we have to setup our own data for testing purpose and should not rely on the Org data.
Provide a description of what you are test is doing(comments).
we need have setup method for all your data creation.
we should test for both positive and negative scenarios.
Tests are run as System Administrator only, is this how we do in the real system also? If not test        users needs to be created and by using  System.runAs () it has to tested as appropriate.
•     we should have only what exactly you are testing in between  Test.StartTest() and          Test.Stoptest().


Following are applicable for all the test classes.
The Ideal test class should be somewhat like this

@isTest
public class nameOfTestClass {

// any statics you want to define

// Have your setup methods defined here


/**
* Comments for the test method1
*
**/



static testMethod void testNameOfTheMethod1(){

// All the set up should be here

test.startTest();

// only what you want to test should be here.

test.stopTest();

}
/**
* Comments for the test method2
*
**/

static testMethod void testNameOfTheMethod2(){

// All the set up should be here

test.startTest();

// only what you want to test should be here.

test.stopTest();
}
}

Test Class Best practises










Apex Exception Email

Apex Exception Email:


1.Actually the 'Send Apex Warning Emails' settings on the User record only controls whether or not you get Apex warning emails every time that an Apex scrip surpasses more than 50% of any governor limit.

2.Runtime exception messages (which is what the "Developer script execution" emails are about) always get sent to the 'Last Modified By' user of the Apex class that generates the exception.

3.The only way to disable those emails is to have another user update the Apex class(es) in question. Marking your user record as Inactive in the Org might also work, but I'm not sure.

4.UPDATE: 
This is possible now with the Winter 16 release. Under Setup go to "Apex Exception Email" to specifiy what email(s) you want to receive error messages. Here is an exceprt from the release notes:

Increase Java Heap Space

Increase Java Heap Space:

we need to follow below steps to increase Heap Space

1.PC Properties
2.Advanced System Settings
3.Environment Variables
4.System Variables
5.Select NEW.


Java heap space increment

Complete Salesforce CPQ training Free videos

Salesforcestart:: We are excited to announce that our YouTube channel, Salesforcestart, is your one-stop-shop for all things Salesforce CPQ!...