• s shekar 28
  • NEWBIE
  • 30 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 5
    Replies

When I am trying to open default scratch org from VS Code terminal. I am getting below error. Can some assist on this.

C:\Program Files\Salesforce CLI\client\node_modules\@salesforce\kit\lib\json.js:27
        throw errors_1.JsonParseError.create(error, data, jsonPath);
        ^
JsonParseError: Unexpected end of JSON input
    at Function.create (C:\Program Files\Salesforce CLI\client\node_modules\@salesforce\kit\lib\errors.js:49:20)
    at Object.parseJson (C:\Program Files\Salesforce CLI\client\node_modules\@salesforce\kit\lib\json.js:27:39)
    at args.map.arg (C:\Program Files\Salesforce CLI\client\node_modules\@salesforce\core\lib\logger.js:548:53)
    at Array.map (<anonymous>)
    at _filter (C:\Program Files\Salesforce CLI\client\node_modules\@salesforce\core\lib\logger.js:500:17)
    at Logger.addFilter.args (C:\Program Files\Salesforce CLI\client\node_modules\@salesforce\core\lib\logger.js:96:37)
    at bunyan.filters.forEach (C:\Program Files\Salesforce CLI\client\node_modules\@salesforce\core\lib\logger.js:456:61)
    at Array.forEach (<anonymous>)
    at Logger.applyFilters (C:\Program Files\Salesforce CLI\client\node_modules\@salesforce\core\lib\logger.js:456:33)
    at Logger.fatal (C:\Program Files\Salesforce CLI\client\node_modules\@salesforce\core\lib\logger.js:450:32)
    at EventEmitter.Logger.uncaughtExceptionHandler (C:\Program Files\Salesforce CLI\client\node_modules\@salesforce\core\lib\logger.js:72:18)
    at EventEmitter.emit (events.js:194:15)
    at process.Logger.lifecycle.process.on.err (C:\Program Files\Salesforce CLI\client\node_modules\@salesforce\core\lib\logger.js:481:51)
    at process.emit (events.js:189:13)
    at process._fatalException (internal/bootstrap/node.js:496:27)
16:26:16.97 sfdx force:org:open ended with exit code 7

Hi all, 

I have a problem with this challenge :

Create a Queueable Apex class that inserts the same Contact for each Account for a specific state. Write unit tests that achieve 100% code coverage for the class.
Create an Apex class called 'AddPrimaryContact' that implements the Queueable interface.
Create a constructor for the class that accepts as its first argument a Contact sObject and a second argument as a string for the State abbreviation.
The execute method must query for a maximum of 200 Accounts with the BillingState specified by the State abbreviation passed into the constructor and insert the Contact sObject record associated to each Account. Look at the sObject clone() method.
Create an Apex test class called 'AddPrimaryContactTest'.
In the test class, insert 50 Account records for BillingState "NY" and 50 Account records for BillingState "CA". Create an instance of the AddPrimaryContact class, enqueue the job and assert that a Contact record was inserted for each of the 50 Accounts with the BillingState of "CA".
The unit tests must cover all lines of code included in the AddPrimaryContact class, resulting in 100% code coverage.
Run your test class at least once (via 'Run All' tests the Developer Console) before attempting to verify this challenge.


I haven't 100% for my test class. 
 
@isTest
 public class AddPrimaryContactTest {
   
   
     @isTest static void TestList(){
         List<Account> Teste = new List <Account>();
         for(Integer i=0;i<50;i++){
             
             Teste.add(new Account(BillingState = 'CA', name = 'Test'+i));
         }
             for(Integer j=0;j<50;j++){
             
             Teste.add(new Account(BillingState = 'NY', name = 'Test'+j));
         
         }
         insert Teste;
         Contact co = new Contact();
          String state = 'CA';
     AddPrimaryContact apc = new AddPrimaryContact(co, state);
	Test.startTest();
	System.enqueueJob(apc);
     Test.stopTest();
         for (Account t:Teste){
             if( t.BillingState == 'CA'){
               	  
             	System.assertEquals(1, t.Number_of_contacts__c);
            
             
         }
         }      
}
 }
 
public class AddPrimaryContact implements Queueable{
    private Contact c;
    private String state;
    public  AddPrimaryContact(Contact c, String state){
        this.c = c;
        this.state = state;
        
    }
     public void execute(QueueableContext context) {
        List<Account> ListAccount = [SELECT ID, Name FROM ACCOUNT WHERE BillingState = :state LIMIT 200];
         for (Account l:ListAccount){
             for (Contact co:l.Contacts){
                 
                 c = co.clone(false,false,false,false);
                 insert c;
             }
                 
                 
             }
             
         }

}


Anyone can help me please?
Thanks!

Hi All,

    i wrote this class for integration of Mailchimp with salesforce using apis

 

public class MailchimpOauth{public void invokeExternalWs(){Http h = new Http();   HttpRequest req = new HttpRequest();               //req.setHeader('Host','https://oauth.constantcontact.com/ws/oauth/request_token');      req.setBody('https://login.mailchimp.com/oauth2/authorize');   req.setBody('https://login.mailchimp.com/oauth2/token');   req.setBody('https://login.mailchimp.com/oauth2/');   req.setBody('https://login.mailchimp.com/oauth2/metadata');
    req.setHeader('Connection','keep-alive');    req.setHeader('Content-Type', 'application/atom+xml');    req.setMethod('POST');    req.setEndpoint('https://login.salesforce.com/services/oauth2/authorize?response_type=code&client_id=957533735502&redirect_uri=http://localhost/oauth/complete.php');

     HttpResponse res = h.send(req);      system.debug(res.getbody());
}}

 

But i got a response like  Status=Bad Request, StatusCode=400 &&&&&error=invalid_client_id&error_description=client%20identifier%20invalid.How to fix this.

any one can u please rectify this.can u give me the solution for fixing that.calient id given in that one is valid.But i dont know how the response coming like this.

 

Thanks in advance.

anu

 

  • September 27, 2011
  • Like
  • 0