You need to sign in to do that
Don't have an account?
santosh konathala
Hi, please help me my challenge not yet complete,not sure where i did wrong.Below you can check the error which i am facing along with the code
Superbadge
Data Integration Specialist
Challenge Not yet complete... here's what's wrong:
Error : The 'ProjectRESTService' Apex REST service does not appear to be working properly. Calling the service either didn't update the opportunity correctly, return the string 'OK', create an associated project correctly or function correctly in general.
Synchronize external PMS system project data with Salesforce
Use the requirements above to implement an Apex REST service to process related project and opportunity data that comes in from the Square Peg external application. Before checking this section, run the service method in the ProjectRESTService class to confirm that it’s working as expected.
Below is my code:
@RestResource(urlMapping = '/project/*')
global with sharing class ProjectRESTService {
@HttpPost
global static String postProjectData(String ProjectRef, String ProjectName, String OpportunityId,
Date StartDate, Date EndDate, Double Amount, String Status){
String retMsg = 'Error';
SavePoint sp1 = Database.setSavePoint();
try{
List<Opportunity> lstOfOpps = new List<Opportunity>();
if(OpportunityId != null && OpportunityId.trim().length() > 0){
Opportunity opp = [SELECT Id, DeliveryInstallationStatus__c, Discount_Percent__c FROM Opportunity WHERE Id = :OpportunityId];
opp.DeliveryInstallationStatus__c = 'In progress';
lstOfOpps.add(opp);
}
UPDATE lstOfOpps;
List<Project__c> lstOfRrjts = new List<Project__c>();
Project__c prjt = new Project__c();
prjt.ProjectRef__c = ProjectRef;
prjt.Name = ProjectName;
prjt.Opportunity__c = OpportunityId;
prjt.Start_Date__c = StartDate;
prjt.End_Date__c = EndDate;
prjt.Billable_Amount__c = Amount;
prjt.Status__c = Status;
lstOfRrjts.add(prjt);
UPSERT lstOfRrjts;
retMsg = 'OK';
}catch(Exception ex){
Database.rollback(sp1);
retMsg = ex.getMessage();
}
return retMsg;
}
}
Data Integration Specialist
Challenge Not yet complete... here's what's wrong:
Error : The 'ProjectRESTService' Apex REST service does not appear to be working properly. Calling the service either didn't update the opportunity correctly, return the string 'OK', create an associated project correctly or function correctly in general.
Synchronize external PMS system project data with Salesforce
Use the requirements above to implement an Apex REST service to process related project and opportunity data that comes in from the Square Peg external application. Before checking this section, run the service method in the ProjectRESTService class to confirm that it’s working as expected.
Below is my code:
@RestResource(urlMapping = '/project/*')
global with sharing class ProjectRESTService {
@HttpPost
global static String postProjectData(String ProjectRef, String ProjectName, String OpportunityId,
Date StartDate, Date EndDate, Double Amount, String Status){
String retMsg = 'Error';
SavePoint sp1 = Database.setSavePoint();
try{
List<Opportunity> lstOfOpps = new List<Opportunity>();
if(OpportunityId != null && OpportunityId.trim().length() > 0){
Opportunity opp = [SELECT Id, DeliveryInstallationStatus__c, Discount_Percent__c FROM Opportunity WHERE Id = :OpportunityId];
opp.DeliveryInstallationStatus__c = 'In progress';
lstOfOpps.add(opp);
}
UPDATE lstOfOpps;
List<Project__c> lstOfRrjts = new List<Project__c>();
Project__c prjt = new Project__c();
prjt.ProjectRef__c = ProjectRef;
prjt.Name = ProjectName;
prjt.Opportunity__c = OpportunityId;
prjt.Start_Date__c = StartDate;
prjt.End_Date__c = EndDate;
prjt.Billable_Amount__c = Amount;
prjt.Status__c = Status;
lstOfRrjts.add(prjt);
UPSERT lstOfRrjts;
retMsg = 'OK';
}catch(Exception ex){
Database.rollback(sp1);
retMsg = ex.getMessage();
}
return retMsg;
}
}
Trailhead Help (https://trailhead.salesforce.com/en/help?support=home) can provide assistance for situations where Trailhead does not appear to be functioning correctly. You can reach out to them if this is the case.
Please close the thread by selected as Best Answer so that we can keep our community clean
Thanks,