• BP Singh
  • NEWBIE
  • 30 Points
  • Member since 2017

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 5
    Replies
I would like to create a validation rule that makes an Account lookup field required if a value is chosen from a picklist field. Specifically, in the Account object, when the "Reseller - Customer" option is chosen from the Type field, then the "Reseller" (account lookup) field becomes required to save the record. Here's a couple of validation rules that I've tried but neither of them works:

AND(
ISPICKVAL(Type, "Reseller - Customer"),
ISBLANK(Reseller__c)
)
_______________________________________________
AND(
ISPICKVAL(Type, "Reseller - Customer"),
Reseller__c = "")
 
I would like to create a validation rule that makes an Account lookup field required if a value is chosen from a picklist field. Specifically, in the Account object, when the "Reseller - Customer" option is chosen from the Type field, then the "Reseller" (account lookup) field becomes required to save the record. Here's a couple of validation rules that I've tried but neither of them works:

AND(
ISPICKVAL(Type, "Reseller - Customer"),
ISBLANK(Reseller__c)
)
_______________________________________________
AND(
ISPICKVAL(Type, "Reseller - Customer"),
Reseller__c = "")
 

I want to create a schedulable APEX class that fetches data from an external system using their REST API. For the other system, the developer needs to create an app, and enter an authorized URL for my "app".

How does one get a URL to my Apex class that his app can redirect to?

Thanks for your help!

Hi,

I am trying to write a test class for testing an HTTP callout. Test class compiles without errors. However, I am not getting the mock response inside. Below is the relevant parts of my code.

Test Class
 
@isTest

public static void testCRCampaignsCalloutSuccess() {
  CRAccount__c testCrAccount = 
   (CRAccount__c)SmartFactory.createSObject('CRAccount__c',true);
    testCrAccount.namedCredential__c ='TestNamedCredential';
    insert testCrAccount;

    Campaign testCampaign = (Campaign)SmartFactory.createSObject('Campaign',true);
    testCampaign.crId__c = '123456';
    insert testCampaign;
    Test.setMock(HttpCalloutMock.class, new TestMockingCrCampaigns());
      List<DO_Campaign> crCampaignsList = ImportCampaignsAngularPoCCntrl.getCrCampaigns(testCrAccount.namedCredential__c);
      system.assert(!crCampaignsList.isEmpty());
      }
Controller Method
public static List<DO_Campaign> getCRCampaigns(String namedcredential)
{ 
  HttpRequest sfRequest = new HttpRequest();
     HttpRequest req = new HttpRequest();
    req.setEndpoint('http://api.salesforce.com/foo/bar');
    req.setMethod('GET');
    Http h = new Http();
    system.debug('***RequestToSend***'+req);
    HttpResponse res = h.send(req);
    system.debug('***Response***'+response);
    List<DtoManager.CampaignDto> receivedCampaignDto = 
      (List<DtoManager.CampaignDto>) JSON.deserialize(res.getbody(),  List<DtoManager.CampaignDto>.class);
             if(receivedCampaignDto != null && !receivedCampaignDto.isEmpty()){
                List<DO_Campaign> campaignsReceived = doManager.generateCampaigns(receivedCampaignDto);
    return campaignsReceived;
}
MockResponseClass
 
@isTest
  global class TestMockingCrCampaigns implements HttpCalloutMock {

global HTTPResponse respond(HTTPRequest req) {
    system.debug('**Inside TestMockingCrCampaigns**');
    HttpResponse res = new HttpResponse();
     res.setHeader('Content-Type', 'application/json');
     res.setBody('[{"id":"502097","name": "CreatingCampaignfromCR","stamp": 1491545738,"last_mailing": 1494914539,"last_changed": 1491545814,"is_locked": false},{"id": "502099","name": "CreatingGroupviaAPIPostman","stamp": 1491483714,"last_mailing": 0,"last_changed": 0,"is_locked": false}]');
     res.setStatusCode(200);
     return res;
   }
  }

I am getting debug till RequestToSend . Not the Response. Cannot get the debug statement inside the respond method of TestMockingCrCampaigns. The code works fine without any issues outside test class.