• Pramod Nishane 17
  • NEWBIE
  • 160 Points
  • Member since 2017
  • Salesforce Consultant
  • Varasi

  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 34
    Replies
I have created a @RestResource, but the developer I am working with who is making the GET call from an external system is having an issue accessing. What am I missing? Thank you in advance for any help. 

[    
    {        
"errorCode": "FORBIDDEN",        
"message": "You do not have access to the Apex class named:
BlueCloudGetOptyDetail"    
     }
]
I have created a lead, and now it won't let me convert. This is th error message that I am receiving:
Converting A Lead
Global class AnimalLocator {
    Global static String getAnimalNameById(Integer numb){
        String response;
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        request.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals/'+numb);
        request.setMethod('GET');
        HttpResponse resp = http.send(request);
        if(resp.getStatusCode()==200){
            Map<String,Object> results = (Map<String,Object>) JSON.deserializeUntyped(response.getBody());
            Map<String,Object> animal = (Map<String,Object>)results.get('animal');
            response = (String)animal.get('name');
        }
        return response;
    }
}
I'm getting the error "Method does not exist or incorrect signature : void getBody() from String type "
 
Control Processes with Queueable Apex challenge of Asynchronous Apex module 
I wrote the bellow queueable class
public class AddPrimaryContact implements Queueable{
    public List<Contact> contacts = new List<Contact>();
    List<Account> accs = [Select Id, Name, BillingState from Account];
    public void AddPrimaryContact(List<Account> accs){
    
      for(Account a : accs){
        Contact con = new Contact();
        con.AccountID = a.Id;
        con.LastName = 'Contact of '+a;
        contacts.add(con);
        system.debug('con check'+con);
      }
       insert contacts; 
    }
  public void execute(QueueableContext context){
        for (Contact cont : contacts) {
        cont.MailingState = cont.Account.BillingState;
        }
        update contacts;
    }
}

And then wrote the below test class
@isTest
public class AddPrimaryContactTest {
    
    @testSetup
    static void setup(){
        List<Account> accs = new List<Account>();
        for (Integer j=0; j<2; j++){
            if(j==0){
                for (Integer i=0; i<50; i++){
                    accs.add(new Account( name='TestC Account'+i, BillingState='NY'));
                }
            }
            else{
                 for (Integer i=0; i<50; i++){
                    accs.add(new Account( name='TestD Account'+i, BillingState='CA'));
                }   
                    
             }
            
        }
        insert accs;
    }
    
    static testMethod void testQueueable(){
        List<Account> accts = [Select Id, Name, BillingState from Account where BillingState = 'NY' OR BillingState = 'CA'];
    	AddPrimaryContact addressput = new AddPrimaryContact(accts);
        Test.startTest();
        System.enqueueJob(addressput);
        Test.stopTest();
        
        System.assertEquals(50, [select count() from Contact where MailingState = 'NY']);
        System.assertEquals(50, [select count() from Contact where MailingState = 'CA']);
    }

}

The error I'm getting is "constructor not defined [AddPrimaryContact].(list). And when I run the queueable class in Anonymous execution I don't see SOQL querries running. What could be the issue here ?
I am trying to navigate to the sign up page at https://api.einstein.ai/signup - it brings me to the page to sign up using salesforce.  I am clicking on the sign up using Salesforce.
I click on the Allow access - and get "An error occured while serving your request" email already registered. 

Please help!
I'm trying to use the Username-Password OAuth Authentication Flow to connect to REST

Posting to https://test.salesforce.com/services/oauth2/token
Params
   grant_type = password
   client_id     = from connected app
   client_secret = from connected app
   username = my user name
   password = my password and API token

I'm getting 
   {"error":"invalid_grant","error_description":"authentication failure"}

When I look at my user in salesforce I see this error
    Failed: Login over insecure channel

I'm setting https.protocols = TLSv1,TLSv1.1,TLSv1.2

Any thoughts?
I have created a @RestResource, but the developer I am working with who is making the GET call from an external system is having an issue accessing. What am I missing? Thank you in advance for any help. 

[    
    {        
"errorCode": "FORBIDDEN",        
"message": "You do not have access to the Apex class named:
BlueCloudGetOptyDetail"    
     }
]
Aura App
<aura:application extends="force:slds">
    <c:myContactCmp recordId='0017F00000S7UjN'/>
</aura:application>

Componet 
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" controller="myContactController" access="global" >
    <aura:handler name="init" action="{!c.getContactList}" value="{!this}" />
    <aura:attribute name="contactList" type="List"/>
</aura:component>

Component controller 
({
    getContactList: function(component, event, handler) {
        
        var action = component.get("c.ContactsList");
        //var accId = component.get("v.recordId");
        alert('acc id '+ component.get("v.recordId"));
        /*action.setParams({
            accId : accId
        });*/
                action.setParams({ AccountId : component.get("v.recordId") });

        action.setCallback(this, function(response){
            var state = response.getState();
            if(state == 'SUCCESS'){
                var contactList = response.getReturnValue();
                //alert("From server: " + contactList);
               //console.log("From server: " + contactList);
               component.set("v.contactList", contactList);
            }else{
                alert('alert in getting data');
            }
        });
            $A.enqueueAction(action);       
    }
})

Apex Controller

It's shows null recordId 

public class myContactController {
    
    @AuraEnabled 
    public static List<Contact> ContactsList(Id accountId){
        system.debug('acc id is '+accountId);
        List<Contact> contacts = [SELECT ID,name,AccountId,Phone,Email from Contact where accountId =: accountId];
        return contacts;
    }
}
 
I have read the documentation that every points other similar questions to, but for the life of me I just can't get my head around this.

I have a very simple query
Select Id, Department, Email, FirstName, LastName, Phone From Contact
  Where Id IN (Select OwnerId From Case)
That gives me the error "The selected field 'OwnerId' in the subquery and the left operand field in the where expression in the outer query 'Id' should point to the same object type"

I want to return a list of contacts, but our contacts data is massive.  So I want to only return the contacts that are the owners of cases.   Any suggestions?
 
I have a custom Object SBQQ__Subscription__c. It has some fields that I want to retrieve. This is my controller:

public with sharing class ActiveController_2 {
    
    private ApexPages.StandardController stdController;
    private final Account acct;

    public ActiveController_2(ApexPages.StandardController stdController) {
        this.stdController = stdController;
        this.acct = (Account)stdController.getRecord();
     }

public List<SBQQ__Subscription__c> getSubscriptions() {
        List<SBQQ__Subscription__c> subscriptionResults = [SELECT Name, MasterDeviceName__c, SBQQ__ProductName__c, Location__c, DeviceId__c, SBQQ__ContractNumber__c, Server_Status__c  FROM SBQQ__Subscription__c WHERE DeviceId__c LIKE :acct.AccountNumber];
        return subscriptionResults;
    }
}

I get the following errror: SObject row was retrieved via SOQL without querying the requested field: Account.AccountNumber 

I read through the forum and I saw that there are other people having the same issue and I get that I should mention Account.AccountNumber somewhere in my query, but I cannot understand how.

Also, I went through the WSDL of our organisation and here is what I found on the SBQQ__Subscription__c object:

<complexType name="SBQQ__Subscription__c">
<complexContent>
<extension base="ens:sObject">
<sequence>
<element name="SBQQ__Account__c" nillable="true" minOccurs="0" type="tns:ID"/>
<element name="SBQQ__Account__r" nillable="true" minOccurs="0" type="ens:Account"/>


If you could give me an idea of what is going on in here?
Thank you,
Violeta
I have created a lead, and now it won't let me convert. This is th error message that I am receiving:
Converting A Lead
 I am trying to access additional information about a failed batch job. 

I read the doc at https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/asynch_api_batches_get_info_all.htm
The solution there is to build a URL to form a GET request to return information about a particular job.

Here is the general form of the URL:
https://instance_name—api.salesforce.com/services/async/APIversion/job/jobid/batch

So I then substituted the specifics of my org into this url, and the URL becomes 
https://NA##—api.salesforce.com/services/async/42/job/7071J00008J6XVu/batch (## is instance server)

This should take me to information about the batch. But it doesn't.
It redirects me to 
https://xn--na##api-516c.salesforce.com/services/async/42/job/7071J00008J6XVu/batch

And then I get the following error message in my web browser: 
"This site can’t be reached
xn--naXXapi-516c.salesforce.com’s server IP address could not be found.
Try running Network Diagnostics.
DNS_PROBE_FINISHED_NXDOMAIN"

No information about my batch job is provided.

What is this website?
I formed the URL correctly, so what is going wrong?

SF Support said I needed to access it via API, but the docs said a simple GET request shoudl return info...so what lightweight tool can i use to just get Apex batch info from a jobid?
I am trying to figure out how to prompt a user to create an Opportunity after they've saved an Account that meets our specific criteria. I know there is functionality to do this but I'm not sure how to trigger it this way specifically.  

I've Googled like a mad man and can't seem to find a solid solution so any help would be appreciated. 
Hello I have a problem, the notification via email when changing the owner of a lead does not work. When changing the owner of a lead, I mark the check to send an email and nothing happens. The owner changes but the mail never arrives. It should be noted that this type of email arrives at another type of notifications from the organization, only the problem is in the change of owner manually.

Has someone happened to you?
Is there some kind of configuration that I should review?

I'd appreciate your help.

Regards
Hi there,

I have a JSON that is being returned from an HTTP Callout and for which I am using an Apex Class to deserialize. Everything is working as expected when I test it through the developer console. But when I write test coverage, the class for which I am deserializing to is showing up as not covered by the test class.

Does the JSON.deserialize cover the class that it's deserializing to or does it not? Thanks.

Sanch.
 
Map<String,String> Selected = new Map<String,String>();
Map<String,String> customvalues = new Map<String,String>();
List<String> lst = new List<String>();
for(String t: customvalues.keySet()){
    String test= customvalues.get(t);
for(String s: Selected.keySet()){
    String Sample= Selected.get(s);
//how to restrict duplicates here intering into this loop
if(test.equals(s)){ lst.add(Sample);
    }
  }
}
if(lst!=null){
for(Integer i=0;i<=lst.size();i++){
Lead le = new Lead();
le.LastName=lst[0];
le.Company = lst[1];
le.Status = lst[2];
le.LightiningEd__City__c = lst[3];
le.LightiningEd__State__c = lst[4];
le.LightiningEd__Country__c = lst[5];
LeadList.add(le);
} if(!LeadList.isEmpty()){
upsert LeadList;
}

Thanks I adavance,If anybody having idea please let me know.
Hi All,

I have Account object and Issue(custom object). Issue object have look up relation with Account. I have a button called create Issue on Account object which is overriden by VF page. When I click on create Issue, i want to render some fields based on associated account region. so in my controller i want to check something like below.
If(Issue__c.Account__r.Region__c == 'abc') is this the correct way? I am getting the expected value. Can some one please help me with this pls?

Thanks.
  • February 02, 2018
  • Like
  • 0

I would like to create a formula field on the oportunity that looks up the "FirstName" of the related contact. To complicate matters we may have more than one contact related to an opportunity, so I want to get the primary contact, which may be assigned by another field called "PrimaryContact__c". 

Is this possible with a formula field? Do I need to write a soql query to accomplish this? What's the best way to make this work?

Thanks in advance for your help!

Global class AnimalLocator {
    Global static String getAnimalNameById(Integer numb){
        String response;
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        request.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals/'+numb);
        request.setMethod('GET');
        HttpResponse resp = http.send(request);
        if(resp.getStatusCode()==200){
            Map<String,Object> results = (Map<String,Object>) JSON.deserializeUntyped(response.getBody());
            Map<String,Object> animal = (Map<String,Object>)results.get('animal');
            response = (String)animal.get('name');
        }
        return response;
    }
}
I'm getting the error "Method does not exist or incorrect signature : void getBody() from String type "
 
trigger HelloWorld on Lead (before update) {
    For (Lead l: Trigger.new) {
        l.FirstName = 'Hello';
        l.LastName = 'World';
        
    }

}
This Trigger works as expected in Classic, but will update a New record in Lightning.  Why?