• Jean-Noel Casassus
  • NEWBIE
  • 69 Points
  • Member since 2014
  • Technical development manager

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 8
    Replies
Hi
I have a Json string, I want to store it into custom object.
json string is:
'{"FRAPI":{"STATUS":"0","MSG":" ","ACCOUNTLIST":{"ACCOUNT":[{"ACCOUNTID":"1083302481D3","ACCOUNTNAME":"kelly Roosevelt","DEFAULTDATE":"20121231"},{"ACCOUNTID":"119334261AD3","ACCOUNTNAME":"Stephen King","DEFAULTDATE":"20121231"}]}}}'
I have written below code but I am getting null value in Wrapper output
global class json2Apex{
public string xmlstring{get;set;}
public string jsstring{get;set;}
public cls_FRAPI  Wrapper{get;set;}
public string resstring{get;set;}
public json2Apex(){
datapull();
}
public void datapull(){

    xmlstring= p.GetAccountList('TGAINES','FRdemo13!','DEMO201212','1');
  jsstring='{"FRAPI":{"STATUS":"0","MSG":" ","ACCOUNTLIST":{"ACCOUNT":[{"ACCOUNTID":"1083302481D3","ACCOUNTNAME":"Teddy Roosevelt","DEFAULTDATE":"20121231"},{"ACCOUNTID":"119334261AD3","ACCOUNTNAME":"Stephen King","DEFAULTDATE":"20121231"}]}}}';
      
      
      
       resstring=jsstring.replace('\\n','').replace('\\','').replace('"{','{').replace('}"','}');
      Wrapper =(cls_FRAPI ) System.JSON.deserialize(resstring, cls_FRAPI .class);
      System.debug('>>>>>'+Wrapper  );
 }  

   public cls_FRAPI FRAPI{get;set;}
    class cls_FRAPI {
        public String STATUS{get;set;}  //0
        public String MSG{get;set;}  // 
        public cls_ACCOUNTLIST ACCOUNTLIST{get;set;}
    }
    class cls_ACCOUNTLIST {
        public list<ACCOUNT> cls_ACCOUNT {get;set;}
    }
    class cls_ACCOUNT {
        public String ACCOUNTID{get;set;}    //1083302481D3
        public String ACCOUNTNAME{get;set;}  //Teddy Roosevelt
        public String DEFAULTDATE{get;set;} //20121231
    }
}


Result is:
cls_FRAPI:[ACCOUNTLIST=null, MSG=null, STATUS=null]

Please suggest the soluton.

Thanks
  • March 28, 2017
  • Like
  • 0
I have a field issue date in custom object and i want to add another formula field to calculate 13 months from issue date and date should be the last day of the month.
I used DATE(YEAR(ccs_IssueDate__c) +1, MONTH(ccs_IssueDate__c) + 2, 1) - 1 this formula .
But if the  issue date is in decemeber month its showing #error in formula field.

Please give me some solution..
Thank you.
From a brand new dev org, here is issue I'm facing with challenge 3

Challenge Not yet complete... here's what's wrong: 
There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: AFYRHOYT
Hello,

bulk as an annotation look like to be permitted in a trigger, is there any documentation on the purpose of it ?

For instance, the 2 following are valid
trigger AccountTrigger on Account bulk (before insert){
// Do something
}
trigger AccountTrigger on Account  (before insert){
// Do something
}
I'm stuck on step #2 of Einstein Analytics and Discovery Insights Specialist superbadge.  I'm getting this warning while checking the challenge:
Challenge #2 Not complete
The step "Churn Tenure' is in compact form, so the filter values need to be specifed as a minimum and maximum
The static step that feeds has the following the value:
 
"Tenure_Length": {
                "broadcastFacet": false,
                "label": "Tenure Length",
                "selectMode": "single",
                "type": "staticflex",
                "values": [
                    {
                        "display": "High Risk",
                        "value": "1 to 12 months",
                        "min": 1,
                        "max": 12
                    },
                    ...
                ]
            }


I'm using selection binding for min and max values.  The dashboard is correctly filtering:
User-added image
User-added image
Any ideas? 
I've tried a non-compact form step where I inject a saql fragment into the query, as well as where I inject min/max values using a range filter serialization...All these efforts end in the same challenge failure message.

Any help/suggesitions are welcome!
Something went wrong in the Build a Lemonade Stand App project, so I deleted the dashboard and reports and started this section again.  However, I'm not able to call a report "Order Total by Flavor", as is required for the task, as the system notes that this name has been used previously - I had to call it "Order Total by Flavour".  As as result I can't complete the task, as when I attempt to verify the step, the system can't detect the "Order Total by Flavor" report.  Is it possible to reset this part of the project or even reset the whole project to start again?  Thank you.
Hi
I have a Json string, I want to store it into custom object.
json string is:
'{"FRAPI":{"STATUS":"0","MSG":" ","ACCOUNTLIST":{"ACCOUNT":[{"ACCOUNTID":"1083302481D3","ACCOUNTNAME":"kelly Roosevelt","DEFAULTDATE":"20121231"},{"ACCOUNTID":"119334261AD3","ACCOUNTNAME":"Stephen King","DEFAULTDATE":"20121231"}]}}}'
I have written below code but I am getting null value in Wrapper output
global class json2Apex{
public string xmlstring{get;set;}
public string jsstring{get;set;}
public cls_FRAPI  Wrapper{get;set;}
public string resstring{get;set;}
public json2Apex(){
datapull();
}
public void datapull(){

    xmlstring= p.GetAccountList('TGAINES','FRdemo13!','DEMO201212','1');
  jsstring='{"FRAPI":{"STATUS":"0","MSG":" ","ACCOUNTLIST":{"ACCOUNT":[{"ACCOUNTID":"1083302481D3","ACCOUNTNAME":"Teddy Roosevelt","DEFAULTDATE":"20121231"},{"ACCOUNTID":"119334261AD3","ACCOUNTNAME":"Stephen King","DEFAULTDATE":"20121231"}]}}}';
      
      
      
       resstring=jsstring.replace('\\n','').replace('\\','').replace('"{','{').replace('}"','}');
      Wrapper =(cls_FRAPI ) System.JSON.deserialize(resstring, cls_FRAPI .class);
      System.debug('>>>>>'+Wrapper  );
 }  

   public cls_FRAPI FRAPI{get;set;}
    class cls_FRAPI {
        public String STATUS{get;set;}  //0
        public String MSG{get;set;}  // 
        public cls_ACCOUNTLIST ACCOUNTLIST{get;set;}
    }
    class cls_ACCOUNTLIST {
        public list<ACCOUNT> cls_ACCOUNT {get;set;}
    }
    class cls_ACCOUNT {
        public String ACCOUNTID{get;set;}    //1083302481D3
        public String ACCOUNTNAME{get;set;}  //Teddy Roosevelt
        public String DEFAULTDATE{get;set;} //20121231
    }
}


Result is:
cls_FRAPI:[ACCOUNTLIST=null, MSG=null, STATUS=null]

Please suggest the soluton.

Thanks
  • March 28, 2017
  • Like
  • 0
I have a field issue date in custom object and i want to add another formula field to calculate 13 months from issue date and date should be the last day of the month.
I used DATE(YEAR(ccs_IssueDate__c) +1, MONTH(ccs_IssueDate__c) + 2, 1) - 1 this formula .
But if the  issue date is in decemeber month its showing #error in formula field.

Please give me some solution..
Thank you.
Hi all, I seem to be stuck on authoring the class and test classes on the Superbadge Data Integration Specialist. I have authored the ProjectCalloutService plus the test class and HTTPCallouts, but encounter a Null pointer exception error at line 35:1

Anything I should add to the code. I have built the process builder as needed.

Project Callout Service
public class ProjectCalloutService {
    public static Id opportunityId;
    
    @InvocableMethod
    public static void postOpportunityToPMS(List<Id> opportunityIds){
        opportunityId=opportunityIds.get(0);
        Opportunity opp=[Select Id,Name, closeDate,amount,Account.Name FROM Opportunity Where Id =: opportunityId];
        ID jobID = System.enqueueJob(new QueueablePMSCall(opp));
    }    
    
    public class QueueablePMSCall implements system.Queueable,Database.AllowsCallouts
    {
        private String jsonOpp;
        private Opportunity opportunityObject;
        public QueueablePMSCall(Opportunity opp)
        {
            opportunityObject=opp;
            JSONGenerator gen = JSON.createGenerator(true);
            gen.writeStartObject();
            gen.writeStringField('opportunityId', opp.Id);
            gen.writeStringField('opportunityName', opp.Name);
            gen.writeStringField('accountName', opp.account.Name);
            gen.writeDateField('closeDate', opp.closeDate);
            gen.writeNumberField('amount', opp.amount);
            
            gen.writeEndObject();            
            
            jsonOpp= gen.getAsString();
            System.debug('jsonOpp: ' + jsonOpp);
            
        }
        public void execute(QueueableContext context) {
            
            ServiceTokens__c token= ServiceTokens__c.getValues('ProjectServiceToken');
            System.debug(token.Token__c);
            
            // create an HTTPrequest object    
            HttpRequest req = new HttpRequest();
            req.setMethod('POST');
            req.setEndpoint('callout:ProjectService/'+ token.Token__c);
            req.setHeader('Content-Type', 'application/json');
            req.setBody(jsonOpp);    
            
            // create a new HTTP object
            Http http = new Http();
            HTTPResponse res = http.send(req);
            if (res.getStatusCode() != 201) {
                System.debug('Error from ' + req.getEndpoint() + ' : ' +
                             res.getStatusCode() + ' ' + res.getStatus());
                
                Opportunity opportunity1=[Select Id, StageName FROM Opportunity Where Id =: opportunityObject.Id];
                opportunity1.StageName='Resubmit Project';
                update opportunity1;
                
            }
            else {
                Opportunity opportunity2=[Select Id, StageName FROM Opportunity Where Id =: opportunityObject.Id];
                opportunity2.StageName='Submitted Project';
                update opportunity2;
            }      
        }
        
    } 
}
Test Class
@isTest
private class ProjectCalloutServiceTest {
  //Implement mock callout tests here
  public static testMethod void testSuccess(){
      Account acc = new Account(Name='Test Account');
      insert acc;
      Opportunity opp = new Opportunity(Name='Test Opportunity',
                        AccountId=acc.id, CloseDate=System.Today(),
                        Amount=12480.00,
                        Type='New Project',
                        StageName='Qualification');
      insert opp;
      Test.startTest();
      Test.setMock(HttpCalloutMock.class, new ProjectCalloutServiceMock());
      Test.stopTest();
      opp.StageName='Closed Won';
      update opp;
      
  }
  public static testMethod void testFailure(){
      Account acc = new Account(Name='Test Account');
      insert acc;
      Opportunity opp = new Opportunity(Name='Test Opportunity',
                        AccountId=acc.id, CloseDate=System.Today(),
                        Amount=12480.00,
                        Type='New Project',
                        StageNAme='Qualification');
      insert opp;
      Test.startTest();
      Test.setMock(HttpCalloutMock.class, new ProjectCalloutServiceMockFailure());
      Test.stopTest();
      opp.StageName='Closed Won';
      update opp;
  }
}

HTTP Callout Success
global class ProjectCalloutServiceMock implements HttpcalloutMock{
   //Implement http mock callout here
   global HttpResponse respond(Httprequest request){
       HttpResponse response = new Httpresponse();
       String resBody = '[Status=Created, StatusCode=201]';
       response.setHeader('Content-Type','application/json');
       response.setBody(resBody);
       response.setStatusCode(201);
       return response;
   }
}
HTTP Callout Fail
 
//ProjectCalloutServiceMockFailure
global class ProjectCalloutServiceMockFailure implements HttpcalloutMock{
   //Implement http mock callout failure here 
   //Implement http mock callout here
   global HttpResponse respond(Httprequest request){
       HttpResponse response = new Httpresponse();
       String resBody = '[Status=Created, StatusCode=501]';
       response.setBody(resBody);
       response.setStatusCode(501);
       return response;
   }
}


 

Build an Account Reassignment Wizard-Implement the Flow with Visualforce
http://trailhead.salesforce.com/project/flow_reassign/flow_reassign_implement

'Challenge Not yet complete... here's what's wrong: 
Couldn't find two users in your org with a 'Salesforce' license. Check the instructions'

The instructions directs me to add two users in my developer org. One is assigned Salesforce License and Standard User profile. The second is to be assigned Salesforce Platform License with Standar User profile. However this is not possible as the only option is the Standard Platform User profile.

Hello,

bulk as an annotation look like to be permitted in a trigger, is there any documentation on the purpose of it ?

For instance, the 2 following are valid
trigger AccountTrigger on Account bulk (before insert){
// Do something
}
trigger AccountTrigger on Account  (before insert){
// Do something
}