How to fix the timeout exception in angularJs? - angularjs

I try to do some processing that take time, and suddenly the server returns me a timeOut exception.
Since my controller, I call the generate method that calls a service, and this service calls my class where there is the method that does the processing.
What is the solution in your opinion?
vm.afficher = function() {
vm.details = [];
var x = vm.applicationField;
if (x === undefined || x === null) {
x = 'off';
}
FacturationSvc.generate({
selectedDt : new Date(vm.selectedDt),
applicationField : x
}).$promise.then(function(resp) {
vm.details = JSON.parse(JSON.stringify(resp));
vm.table.check = true;
});
}
vm is the instance of the controller.
#RequestMapping("/facturations")
#Controller
public class FacturationController {
private FacturationSvc facturationSvc;
#Autowired
public FacturationController(FacturationSvc svc, UserSvc userSvc) {
super();
this.facturationSvc = svc;
}
#RequestMapping(value = "/generate/{selectedDt}/applicationName/{applicationField}", method = RequestMethod.GET)
#ResponseBody
public List<Facturation> generate(#PathVariable Date selectedDt,#PathVariable String applicationField) throws NoSuchFieldException{
return facturationSvc.facturer(selectedDt,applicationField);
}
}

Related

when clicked on button "reschedule scheduled service" spinner keeps on loading

trying to reschedule the calim but when clicked on button spinner keeps on rotating and unable to reschedule
see the screenshots for the error
Creatfurniturecontroller.js
createFurnitureServiceInfo : function(component) {
var scheduleServiceWrapper = component.get('v.scheduleService');
var scheduleServiceWrappperComments = scheduleServiceWrapper.Comments.replace(/\\/g, '');
var escapedComments = this.encodeSpecialCharacters(scheduleServiceWrappperComments);
scheduleServiceWrapper.Comments = escapedComments;
scheduleServiceWrapper.ButtonLabel = component.get('v.buttonLabel');
component.set('v.isLoading',true);
var isIndependentServicer = component.get('v.isIndependentServicerChecked');
var independentServicer = component.get('v.independentServicer');
var action = component.get('c.createFurnitureServices');
var parameters = {
"scheduleServiceJSON": JSON.stringify(scheduleServiceWrapper),
"independentServicerJSON": JSON.stringify(independentServicer),
"isIndependentServicer": isIndependentServicer
};
//console.log('params: ' + JSON.stringify(parameters));
action.setParams(parameters);
action.setCallback(this, function(response) {
component.set('v.isLoading',false);
var state = response.getState();
if (state === "SUCCESS") {
this.displayToast('Success', 'The service has been successfully scheduled.','success');
var navEvt = $A.get("e.force:navigateToSObject");
navEvt.setParams({
"recordId": response.getReturnValue(),
"slideDevName": "detail"
});
this.closeModal(component);
this.refreshFurnitureServiceRecord();
navEvt.fire();
} else {
console.error(response.getError());
this.displayToast('Error', 'Something went wrong, the service was NOT scheduled. Please verify zip code and additional address fields.','error');
}
});
$A.enqueueAction(action);
},
refreshFurnitureServiceRecord : function() {
window.setTimeout(
$A.getCallback(function() {
var refreshFurnitureServiceEvent = $A.get("e.c:refreshFurnitureServiceEvent");
refreshFurnitureServiceEvent.fire();
}), 2000
);
},
getDayOfWeek : function(serviceDate) {
var momentDate = moment(serviceDate);
var weekDay = momentDate.format('dddd');
return weekDay;
},
formatServiceDate : function(serviceDate) {
return serviceDate.substring(5, 7) + '/' + serviceDate.substring(8, 10) + '/' + serviceDate.substring(0, 4);
},
displayToast : function(title, message, type, mode){
var toastEvent = $A.get("e.force:showToast");
toastEvent.setParams({
title : title,
message: message,
duration:' 5000',
key: 'info_alt',
type: type,
mode: mode ? mode : 'pester'
});
toastEvent.fire();
},
getRelatedCase : function(component, event, helper) {
var workspaceAPI = component.find("workspace");
workspaceAPI.getFocusedTabInfo().then(function(response) {
//console.log(JSON.parse(JSON.stringify(response)));
var parentTabId = response.parentTabId;
workspaceAPI.getTabInfo({
tabId: parentTabId
}).then(function(parentTabResponse) {
var parentTabObjectAPIName = parentTabResponse.pageReference.attributes.objectApiName;
//console.log(parentTabObjectAPIName);
// If the parent tab is a Case record
if(parentTabObjectAPIName === "Case"){
var caseRecord = {
"recordId" : parentTabResponse.recordId,
"label" : parentTabResponse.title
}
component.set('v.caseRecord',caseRecord);
} else {
// If the parent tab is not a Case record
var relatedSubTabs = parentTabResponse.subtabs;
for (let i = 0; i < relatedSubTabs.length; i++) {
var subtab = relatedSubTabs[i];
var subTabObjectAPIName = subtab.pageReference.attributes.objectApiName;
if(subTabObjectAPIName === "Case"){
var caseRecord = {
"recordId" : subtab.recordId,
"label" : subtab.title
}
component.set('v.caseRecord',caseRecord);
}
}
}
helper.fetchCaseData(component, event, helper);
});
})
.catch(function(error) {
console.log(error);
});
},
isValidToSave : function(component, event, helper) {
var validityErrors = [];
var notPopulatedRequiredFields = [];
var isIndependentServicer = component.get('v.isIndependentServicerChecked');
try {
// validation for both: regular and independent servicer scheduling
let serviceDateField = isIndependentServicer ? component.find('serviceDate2') : component.find('serviceDate');
serviceDateField.reportValidity();
if (!serviceDateField.get('v.value')) validityErrors.push('Service Date must be selected.');
let addressField = isIndependentServicer ? component.find('addressField2a') : component.find('addressField');
addressField.reportValidity();
if (!addressField.get('v.value')) notPopulatedRequiredFields.push('address');
let zipCodeField = isIndependentServicer ? component.find('zipCodeField2') : component.find('zipCodeField');
zipCodeField.reportValidity();
if (!zipCodeField.get('v.value')) notPopulatedRequiredFields.push('zip code');
let stateField = isIndependentServicer ? component.find('stateField2') : component.find('stateField');
stateField.reportValidity();
if (!stateField.get('v.value')) notPopulatedRequiredFields.push('state');
let cityField = isIndependentServicer ? component.find('cityField2') : component.find('cityField');
cityField.reportValidity();
if (!cityField.get('v.value')) notPopulatedRequiredFields.push('city');
// validation for independent servicer scheduling
if (isIndependentServicer) {
var caseRecord = component.get('v.caseRecord');
if (!caseRecord || !caseRecord.Id) validityErrors.push('Selecting case related to service is required.');
if (!caseRecord.Independent_Servicer__r) {
validityErrors.push('Independent Servicer needs to be assigned to the selected Case.');
} else if (!caseRecord.Independent_Servicer__r.Servicer_Id__c) {
validityErrors.push('Independent Servicer assigned to the selected Case needs to have Servicer Id value.');
}
let callBackContactField = component.find('callBackContact');
callBackContactField.reportValidity();
if (!callBackContactField.get('v.value')) notPopulatedRequiredFields.push('contact');
let callBackNumberField = component.find('callBackNumber');
callBackNumberField.reportValidity();
if (!callBackNumberField.get('v.value')) {
notPopulatedRequiredFields.push('phone');
} else if (callBackNumberField.get('v.value').length != 10) {
validityErrors.push('Phone field must be 10 digits long.');
}
} else {
// validation for regular scheduling
var routeCode = component.get('v.selectedRouteCode');
if($A.util.isUndefinedOrNull(routeCode) || $A.util.isEmpty(routeCode) || routeCode.trim() == ''){
validityErrors.push('A Route code is required.');
}
var selectedAvailableAppointmentUnits = Number(component.get('v.selectedAppointmentUnits'));
var availableUnits = Number(component.get('v.scheduleService.AppointmentUnits'));
if(availableUnits > selectedAvailableAppointmentUnits){
validityErrors.push('There is not enough appointment units available for the selected service date.');
}
}
if (isIndependentServicer) {
if (notPopulatedRequiredFields.length > 0) validityErrors.push('You need to populate those fields on the selected case: ' + notPopulatedRequiredFields.join(', ') + '.');
} else {
if (notPopulatedRequiredFields.length > 0) validityErrors.push('You need to populate those fields: ' + notPopulatedRequiredFields.join(', ') + '.');
}
} catch(err) {
console.error(err);
}
return validityErrors;
},
isIndependentServicerCheckedChanged : function(component, event, helper) {
let checkboxValue = component.get('v.isIndependentServicerChecked');
try{
// If the checkbox was checked
if(checkboxValue){
// Set service date as current date
component.set('v.selectedServiceDate', new Date().toISOString().slice(0, 10));
let caseRecord = component.get('v.caseRecord');
let scheduleService = component.get('v.scheduleService');
// If this property is already filled, it means the service was already scheduled once, so we should consider data from POPS
if(scheduleService.Servicer){
let independentServicer = {
CustomerName : scheduleService.CustomerName,
Address : scheduleService.Address,
ZipCode : scheduleService.ZipCode,
State : scheduleService.State,
City : scheduleService.City,
ContactPhone : scheduleService.ContactPhone,
ContactPhoneExtension : scheduleService.ContactPhoneExtension,
Servicer : caseRecord.Independent_Servicer__r.Servicer_Id__c,
CaseId : caseRecord.Id
};
component.set('v.independentServicer',independentServicer);
} else {
// This means it's the first time creating the independent servicer furniture service, so we should consider data from the associated Case
let independentServicer = {
CustomerName : caseRecord.Call_Back_Contact__c,
Address : caseRecord.Shipping_Address_1__c,
ZipCode : caseRecord.Shipping_Postal_Code__c,
State : caseRecord.Shipping_State__c,
City : caseRecord.Shipping_City__c,
ContactPhone : caseRecord.Requested_Call_Back_Number__c,
ContactPhoneExtension : caseRecord.Requested_Call_Back_Number_Ext__c,
Servicer : caseRecord.Independent_Servicer__r.Servicer_Id__c,
CaseId : caseRecord.Id
};
component.set('v.independentServicer',independentServicer);
}
} else {
component.set('v.selectedServiceDate', null);
}
} catch (err) {
console.error(err);
}
}
})
Apex class
public without sharing class CreateFurnitureServicesCtrl {
#AuraEnabled
public static ScheduleServiceWrapper getScheduleServiceWrapper(String claimRecordId){
String[] claimFieldsList = new List<String>{
'Id', 'OrderNumber__c','AccountNumber__c', 'ClaimId__c'
};
Map<String,String> claimsFieldValueMap = new Map<String,String>();
claimsFieldValueMap.put('Id',claimRecordId);
Claims__x objClaims = nfm_ExternalClaimRequest.getClaims(claimFieldsList, claimsFieldValueMap, 'Id', 'ASC')[0];
String[] orderDetailsFieldsList = new List<String>{
'Id','CustomerZip__c','CustomerPhone__c','OrderState__c','OrderCity__c','CustomerState__c','CustomerCity__c','DistributionMethod__c',
'AccountNumber__c','OrderNumber__c','OrderZip__c', 'OrderPrimaryCallAhPhExt__c', 'CustomerName__c',
'CustomerAddress1__c','CustomerAddress2__c','OrderAddress1__c','OrderAddress2__c'
};
Map<String,String> orderDetailsFieldValueMap = new Map<String,String>();
orderDetailsFieldValueMap.put('OrderNumber__c',objClaims.OrderNumber__c);
OrderDetails__x objOrderDetails = nfm_ExternalOrderDetailsRequest.getOrders(orderDetailsFieldsList, orderDetailsFieldValueMap, 'Id', 'ASC', false)[0];
ScheduleServiceWrapper objScheduleServiceWrapper = new ScheduleServiceWrapper();
objScheduleServiceWrapper.NumberOfDays = 15;
objScheduleServiceWrapper.AppointmentUnits = 1;
objScheduleServiceWrapper.StartDate = String.valueOf(System.today());
objScheduleServiceWrapper.ClaimId = objClaims.ClaimId__c;
objScheduleServiceWrapper.ServiceDate = 'TBD';
objScheduleServiceWrapper.RouteCode = 'TBD';
objScheduleServiceWrapper.ServiceCode = 'TBD';
objScheduleServiceWrapper.Comments = ' ';
FurnitureServices__x objFurnitureServices = getPreviousFurnitureService(objClaims.ClaimId__c);
Set<String> customerDistributionSet = new Set<String>{'P','T'};
Set<String> orderDistributionSet = new Set<String>{'D','W','I','O'};
// Here we're verifying if a basic field is blank, so that means that the furnite service hasn't been scheduled yet
if(objFurnitureServices.InspectAddress1__c == null){
// In this case, the details are filled according to the Order's Delivery Method
objScheduleServiceWrapper.CustomerName = objOrderDetails.CustomerName__c;
objScheduleServiceWrapper.ContactName = objOrderDetails.CustomerName__c;
objScheduleServiceWrapper.ContactPhone = objOrderDetails.CustomerPhone__c;
if(customerDistributionSet.contains(objOrderDetails.DistributionMethod__c)){ // Customer
objScheduleServiceWrapper.City = objOrderDetails.CustomerCity__c;
objScheduleServiceWrapper.State = objOrderDetails.CustomerState__c;
objScheduleServiceWrapper.ZipCode = objOrderDetails.CustomerZip__c.substring(0,5);
objScheduleServiceWrapper.Address = objOrderDetails.CustomerAddress1__c + ' ' + nfm_Utils.ifNull(objOrderDetails.CustomerAddress2__c,'');
} else if(orderDistributionSet.contains(objOrderDetails.DistributionMethod__c)) { //Order
objScheduleServiceWrapper.City = objOrderDetails.OrderCity__c;
objScheduleServiceWrapper.State = objOrderDetails.OrderState__c;
objScheduleServiceWrapper.ZipCode = objOrderDetails.OrderZip__c.substring(0,5);
objScheduleServiceWrapper.ContactPhoneExtension = objOrderDetails.OrderPrimaryCallAhPhExt__c;
objScheduleServiceWrapper.Address = objOrderDetails.OrderAddress1__c + ' ' + nfm_Utils.ifNull(objOrderDetails.OrderAddress2__c,'');
}
} else {
// In this case, the details are filled according to the previous Furniture Service
objScheduleServiceWrapper.CustomerName = objFurnitureServices.InspectName__c;
objScheduleServiceWrapper.ContactName = objFurnitureServices.ContactDescription__c;
objScheduleServiceWrapper.ContactPhone = objFurnitureServices.ContactPhone__c;
objScheduleServiceWrapper.ContactPhoneExtension = objFurnitureServices.ContactPhoneExtension__c;
objScheduleServiceWrapper.Address = objFurnitureServices.InspectAddress1__c;
objScheduleServiceWrapper.City = objFurnitureServices.InspectCity__c;
objScheduleServiceWrapper.State = objFurnitureServices.InspectState__c;
objScheduleServiceWrapper.ZipCode = objFurnitureServices.InspectZip__c.substring(0,5);
}
objScheduleServiceWrapper.Servicer = nfm_Utils.ifNull(objFurnitureServices.Servicer__c,'');
return objScheduleServiceWrapper;
}
public class ScheduleServiceWrapper{
#AuraEnabled public String ClaimId{get;set;}
#AuraEnabled public String ZipCode{get;set;}
#AuraEnabled public String StartDate{get;set;}
#AuraEnabled public String ServiceDate{get;set;}
#AuraEnabled public String ServiceCode{get;set;}
#AuraEnabled public String RouteCode{get;set;}
#AuraEnabled public Integer NumberOfDays{get;set;}
#AuraEnabled public Integer AppointmentUnits{get;set;}
#AuraEnabled public String CustomerName{get;set;}
#AuraEnabled public String Address{get;set;}
#AuraEnabled public String Servicer{get;set;}
#AuraEnabled public String State{get;set;}
#AuraEnabled public String City{get;set;}
#AuraEnabled public String ContactName{get;set;}
#AuraEnabled public String ContactPhone{get;set;}
#AuraEnabled public String ContactPhoneExtension{get;set;}
#AuraEnabled public String Comments{get;set;}
#AuraEnabled public String ButtonLabel{get;set;}
}
public class IndependentServicerWrapper{
#AuraEnabled public String CustomerName{get;set;}
#AuraEnabled public String Address{get;set;}
#AuraEnabled public String State{get;set;}
#AuraEnabled public String City{get;set;}
#AuraEnabled public String ZipCode{get;set;}
#AuraEnabled public String ContactPhone{get;set;}
#AuraEnabled public String ContactPhoneExtension{get;set;}
#AuraEnabled public String Servicer{get;set;}
#AuraEnabled public String CaseId{get;set;}
}
#AuraEnabled
public static String createFurnitureServices(String scheduleServiceJSON, String independentServicerJSON, Boolean isIndependentServicer){
ScheduleServiceWrapper objScheduleServiceWrapper = (ScheduleServiceWrapper) System.JSON.deserialize(scheduleServiceJSON, ScheduleServiceWrapper.class);
IndependentServicerWrapper objIndependentServicerWrapper = !isIndependentServicer ? null : (IndependentServicerWrapper) System.JSON.deserialize(independentServicerJSON, IndependentServicerWrapper.class);
JSONGenerator jsonGenerator = JSON.createGenerator(false);
jsonGenerator.writeStartObject();
jsonGenerator.writeObjectField('ClaimId__c', objScheduleServiceWrapper.ClaimId);
jsonGenerator.writeObjectField('Comments__c','[' + System.today().format() + '][' + nfm_Utils.userAlias + '] ' + objScheduleServiceWrapper.Comments);
String inspectDateYear = objScheduleServiceWrapper.ServiceDate.substring(0,4);
String inspectDateMonth = objScheduleServiceWrapper.ServiceDate.substring(5,7);
String inspectDateDay = objScheduleServiceWrapper.ServiceDate.substring(8,10);
jsonGenerator.writeObjectField('InspectDate__c', inspectDateMonth + '/' + inspectDateDay + '/'+ inspectDateYear);
if (!isIndependentServicer) {
//specific fields
jsonGenerator.writeObjectField('InspectName__c', objScheduleServiceWrapper.CustomerName);
jsonGenerator.writeObjectField('ServiceCode__c', objScheduleServiceWrapper.ServiceCode);
jsonGenerator.writeObjectField('RouteCode__c', objScheduleServiceWrapper.RouteCode);
jsonGenerator.writeObjectField('AppointmentUnits__c', String.valueOf(objScheduleServiceWrapper.AppointmentUnits));
//common fields
jsonGenerator.writeObjectField('InspectAddress1__c', objScheduleServiceWrapper.Address);
jsonGenerator.writeObjectField('InspectAddress2__c', '');
jsonGenerator.writeObjectField('InspectCity__c', objScheduleServiceWrapper.City);
jsonGenerator.writeObjectField('InspectState__c', objScheduleServiceWrapper.State);
jsonGenerator.writeObjectField('InspectZip__c', objScheduleServiceWrapper.ZipCode);
jsonGenerator.writeObjectField('ContactPhone__c', objScheduleServiceWrapper.ContactPhone);
jsonGenerator.writeObjectField('ContactPhoneExtension__c', nfm_Utils.IfNull(objScheduleServiceWrapper.ContactPhoneExtension,''));
}
if (isIndependentServicer) {
//specific fields
String servicerCode = Test.isRunningTest() ? '12345' : objIndependentServicerWrapper.Servicer;
jsonGenerator.writeObjectField('Servicer__c', servicerCode); //servicer 5-digit code
//common fields
jsonGenerator.writeObjectField('InspectAddress1__c', objIndependentServicerWrapper.Address);
jsonGenerator.writeObjectField('InspectAddress2__c', '');
jsonGenerator.writeObjectField();
jsonGenerator.writeObjectField('InspectCity__c', objIndependentServicerWrapper.City);
jsonGenerator.writeObjectField('InspectState__c', objIndependentServicerWrapper.State);
jsonGenerator.writeObjectField('InspectZip__c', objIndependentServicerWrapper.ZipCode);
jsonGenerator.writeObjectField('InspectName__c', objIndependentServicerWrapper.CustomerName);
jsonGenerator.writeObjectField('ContactPhone__c', objIndependentServicerWrapper.ContactPhone);
jsonGenerator.writeObjectField('ContactPhoneExtension__c', nfm_Utils.IfNull(objIndependentServicerWrapper.ContactPhoneExtension,''));
}
String jsonBody = '\'' + jsonGenerator.getAsString() + '\'';
String jsonResult = nfm_FurnitureServicesCallout.upsertFurnitureServicesCallout(jsonBody);
String result = '';
if(!Test.isRunningTest()){
Map<String, Object> jsonResultMap = (Map<String, Object>) JSON.deserializeUntyped(jsonResult);
String[] furnitureServicesFieldsList = new List<String>{ 'ExternalId','Id','AppointmentUnits__c','InspectAddress1__c','InspectName__c','InspectDate__c' };
Map<String,String> furnitureServicesFieldValueMap = new Map<String,String>();
furnitureServicesFieldValueMap.put('ClaimId__c', String.valueOf(jsonResultMap.get('ClaimId')));
FurnitureServices__x objFurnitureServices = nfm_ExternalFurnitureServicesRequest.getFurnitureServices(furnitureServicesFieldsList, furnitureServicesFieldValueMap, 'Id', 'ASC')[0];
UserActivityController.createRecord(objScheduleServiceWrapper.ButtonLabel, 'Claim', objScheduleServiceWrapper.ClaimId);
if(isIndependentServicer){
updateServiceAssignedDate(objIndependentServicerWrapper.CaseId, Date.newInstance(Integer.valueOf(inspectDateYear), Integer.valueOf(inspectDateMonth), Integer.valueOf(inspectDateDay)));
}
return objFurnitureServices.Id;
} else {
result = 'ok';
}
return result;
}
public static FurnitureServices__x getPreviousFurnitureService(String claimId){
Map<String,String> furnitureServicesFieldValueMap = new Map<String,String>();
furnitureServicesFieldValueMap.put('ClaimId__c', claimId);
return nfm_ExternalFurnitureServicesRequest.getFurnitureServices(SObjectUtils.getAllFieldsAPINames('FurnitureServices__x'), furnitureServicesFieldValueMap, 'Id', 'ASC')[0];
}
#AuraEnabled
public static List<FurnitureServiceRoutes__x> getFurnitureServiceRoutes(String startDate,String numberOfDays,String zipCode){
String[] furnitureServiceRoutesFieldsList = new List<String>{
'Id', 'NumberOfDays__c', 'RouteCode__c', 'RouteDescription__c', 'ServiceCode__c', 'StartDate__c', 'ZipCode__c'
};
Map<String,String> furnitureServiceRoutesFieldValueMap = new Map<String,String>();
furnitureServiceRoutesFieldValueMap.put('NumberOfDays__c',numberOfDays);
furnitureServiceRoutesFieldValueMap.put('StartDate__c',startDate);
furnitureServiceRoutesFieldValueMap.put('ZipCode__c',zipCode);
return nfm_ExternalFurnitureServiceRoutesReq.getFurnitureServiceRoutes(furnitureServiceRoutesFieldsList, furnitureServiceRoutesFieldValueMap, 'RouteCode__c', 'ASC');
}
#AuraEnabled
public static List<FurnitureServiceAppointments__x> getFurnitureServiceAppointments(String startDate,String numberOfDays,String zipCode, String routeCode){
String[] furnitureServiceAppointmentsFieldsList = new List<String>{
'Id', 'AppointmentUnits__c', 'ServiceDate__c', 'StartDate__c', 'ZipCode__c','RouteCode__c'
};
Map<String,String> furnitureServiceAppointmentsFieldValueMap = new Map<String,String>();
furnitureServiceAppointmentsFieldValueMap.put('NumberOfDays__c',numberOfDays);
furnitureServiceAppointmentsFieldValueMap.put('StartDate__c',startDate);
furnitureServiceAppointmentsFieldValueMap.put('ZipCode__c',zipCode);
furnitureServiceAppointmentsFieldValueMap.put('RouteCode__c',routeCode);
return nfm_ExternalFurnitureServiceAppRequest.getFurnitureServiceAppointments(furnitureServiceAppointmentsFieldsList, furnitureServiceAppointmentsFieldValueMap, 'RouteCode__c', 'ASC');
}
#AuraEnabled
public static Boolean hasAccessToIndependentServicerPermset(){
Id userId = UserInfo.getUserId();
String permsetApiName = 'Custom_Contact_Center_Support_Team';
return nfm_Utils.isPermsetAssignedToUser(userId, permsetApiName);
}
**#AuraEnabled
public static Case retrieveCaseObject(Id caseId){
return [
SELECT
Id, Shipping_Address_1__c, Shipping_Address_2__c, Shipping_City__c, Shipping_State__c,
Shipping_Postal_Code__c, Call_Back_Contact__c, Requested_Call_Back_Number__c,
Requested_Call_Back_Number_Ext__c ,Independent_Servicer__r.Id, Independent_Servicer__r.Servicer_Id__c, Independent_Servicer__r.Name
FROM Case
WHERE Id = :caseId
LIMIT 1
];
}**
public static void updateServiceAssignedDate(Id caseId, date newDate){
Case objCase = [SELECT Id, Service_Assigned_Date__c FROM Case WHERE Id = :caseId LIMIT 1];
objCase.Service_Assigned_Date__c = newDate;
update objCase;
}
}
method to fetch case record
fetchCaseData : function(component, event, helper) {
var caseRecord = component.get('v.caseRecord');
var newCaseId = caseRecord.recordId;
var retrieveCaseAction = component.get('c.retrieveCaseObject');
var actionParams = {'caseId':newCaseId};
retrieveCaseAction.setParams(actionParams);
retrieveCaseAction.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
var result = response.getReturnValue();
//console.log('RESULT: ' + JSON.stringify(result));
var currentCaseRecord = component.get('v.caseRecord');
result.label = currentCaseRecord.label;
result.recordId = currentCaseRecord.recordId;
component.set('v.caseRecord', result);
component.set('v.isLoading', false);
} else {
console.log(response.getError());
}
});
$A.enqueueAction(retrieveCaseAction);
},
when clicked on reschedule spinner should not spin continuously
enter image description here
enter image description here
should be able to reschedule
Needs more info (but too long for comment).
Which JS function is called when that button (quick action?) is clicked? It doesn't look like you followed the customary {!c.doInit} naming convention.
You pasted a lot of code, servicer_id__c appears in 3 places. Next time try to cut the useless pieces until you're left with Minimal Reproducible Example.
Check Apex Developer Console for errors / problems, maybe one of the functions genuinely returns null / throws error:
lack of permissions to run this apex class
really bad data (Case without some lookup populated?)
maybe you carefully created a wrapper class to hold stuff returned from apex - but you forgot to mark every field as public and #AuraEnabled
I suspect the bad code is around places like caseRecord.Independent_Servicer__r.Servicer_Id__c in isIndependentServicerCheckedChanged. You don't check if the middle part is null. A ternary operator or optional chaining could make it easier to spot.
Enable Setup -> Debug mode (if not done already) and next time just click that error logged in JavaScript console. You'll be taken to the line in source code where it happened. It won't look exactly like your source code (SF transpiles a bit and merges multiple files into 1) but it should be close enough for you to recognise and fix the mistake. Or at least put some breakpoints / watches.

Breakpoints not being hit or methods not being called when using $http.get to call methods in APIController

When I call $http.get('/api/calendarevent/getall') in my Angular code, the breakpoints for the method in my API Controller that matches that route are not being hit. I don't know if that means the methods in the controller aren't being called or if it's bypassing the breakpoints set in the method. In the IE Developer tools, I receive a 500 error code. So the method is being found but I'm not sure if it's being executed since I would have received some kind of 400 error if it wasn't being found. Below, I've included the necessary code, can anyone see where I might be going wrong?
Angular Code:
function () {
var deferred = $q.defer();
$http.get('/api/calendarevent/getall').success(function (data) {
deferred.resolve(data);
});
return deferred.promise;
}
Global.asax.cs:
protected void Application_Start(object sender, EventArgs e)
{
AreaRegistration.RegisterAllAreas();
RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapHttpRoute(
name: "Default",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = System.Web.Http.RouteParameter.Optional });
}
APIController:
public class CalendarEventController : ApiController
{
[HttpGet]
[ActionName("all")]
public object GetAll()
{
using (var entity = new RPOEntities())
{
CalendarEventViewModel returnModel = new CalendarEventViewModel();
var events = entity.CalendarEvents.Where(e => !e.Deleted);
var eventList = events.ToList();
var calendarEvents = eventList.Select(e => new
{
id = e.CalendarEventId,
title = e.Title,
start = e.StartDate,
end = e.EndDate,
url = "details/" + e.CalendarEventId.ToString(),
contact = e.Contact,
location = e.Location,
property = e.AllProperties ? "All Properties" : e.Property != null ?
e.Property.PropertyName : "",
active = e.Active,
canEdit = Helper.IsRPOAdmin || Helper.IsCorporateAdmin || (e.PropertyStaffId.HasValue && e.PropertyStaffId.Value == Helper.CurrentUserId)
}).ToList();
return new {
events = calendarEvents,
color = "",
textColor = "" };
}
}

Get Enum value on client side

I am trying to send the value of an enumeration to Angularjs from
Server side :
Model :
public class Consultant implements Serializable {
#Enumerated(EnumType.STRING)
#Column(name = "etat_qualification")
private EtatQualification etatQualification;
public EtatQualification getEtatQualification() {
return etatQualification;
}
public void setEtatQualification(EtatQualification etatQualification) {
this.etatQualification = etatQualification;
}
}
public enum EtatQualification {
EN_COURS("en cours"),
OK("ok"),
CONSULTANT_TV("consultant TV"),
KO("ko");
private String libelle;
EtatQualification(String libelle) {
this.libelle = libelle;
}
public String getLibelle() {
return libelle;
}
}
My resource :
#RequestMapping(value = "/consultants/{id}",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
#Timed
public ResponseEntity<Consultant> getConsultant(#PathVariable Long id) {
log.debug("REST request to get Consultant : {}", id);
Consultant consultant = consultantRepository.findOne(id);
return Optional.ofNullable(consultant)
.map(result -> new ResponseEntity<>(
result,
HttpStatus.OK))
.orElse(new ResponseEntity<>(HttpStatus.NOT_FOUND));
}
On AngularJS side :
var consultant = Consultant.get({id : $stateParams.id});
But when i watch consultant.etatQualification value I get 'EN_COURS'.
I want to get : 'en cours'
Is it possible?
Thanks.
if you use jackson as json parser use this
#JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum EtatQualification { ... }

Breezejs/Angular/EF - cannot execute until metadastore is populated

I started to learn angularjs and trying to put together Angularjs+Breezejs+EntityFramework.
Here is my context cs file:
public class GrantsDbContext : DbContext {
public GrantsDbContext() {
Database.SetInitializer<GrantsDbContext>(new MigrateDatabaseToLatestVersion<GrantsDbContext, Configuration>());
}
public DbSet<OrgItem> OrgList;
}
OrgItem is just model-class (contained: ID, FullName, ShortName), and I set automigrate, and write default connection string in Web.config
That's breeze controller cs file:
[BreezeController]
public class DbController : ApiController {
private EFContextProvider<GrantsDbContext> _contextProvider = new EFContextProvider<GrantsDbContext>();
[HttpGet]
public String Metadata() {
return _contextProvider.Metadata();
}
[HttpPost]
public SaveResult SaveChanges(JObject saveBundle) {
return _contextProvider.SaveChanges(saveBundle);
}
[HttpGet]
public IQueryable<OrgItem> OrgList() {
return _contextProvider.Context.OrgList;
}
}
Here is angular service, that created manager for breeze:
angular.module('app').factory("entityManagerFactory", ["breeze", emFactory]);
function emFactory(breeze) {
new breeze.ValidationOptions({ validateOnAttach: false }).setAsDefault();
var serviceName = "breeze/db";
var metadataStore = new breeze.MetadataStore();
var provider = {
newManager: newManager
};
return provider;
function newManager() {
var mgr = new breeze.EntityManager({
serviceName: serviceName,
metadataStore: metadataStore
});
return mgr;
}
}
That's my controller that called query:
angular.module("app")
.controller("OrgCtrl", ['entityManagerFactory', OrgCtrl]);
function OrgCtrl(entityManagerFactory) {
var vm = this;
vm.orgs = [];
var manager = entityManagerFactory.newManager();
var orgsQuery = new breeze.EntityQuery("OrgList").select("ID, FullName, ShortName");
manager.executeQuery(orgsQuery).then(succesCallback).catch(failCallback);
function succesCallback(data) {
vm.orgs = data.result;
}
function failCallback(error) {
console.log(error);
}
}
When I firstly started the app, database was created with one table '_MigrationHistory' and then I got the error: 'Error: cannot execute _executeQueryCore until metadataStore is populated.'
'localhost:49934/breeze/db/Metadata' is available (200 OK).
All libraries updated with nuget.
Help please to solve this problem!
Thanks!

actionscript 3 load URL from array

I'm making a mp3/steaming radio with MVC, where I'm trying to load an URL from a array.
I have a radio class:
public class Radio
{
private var titel:String;
private var url:URLRequest;
private var cover:Bitmap;
public function Radio(titel:String, url:URLRequest, cover:Bitmap)
{
this.titel = titel;
this.url = url;
this.cover = cover;
}
public function getTitel():String {
return titel;
}
public function getURL():URLRequest {
return url;
}
public function getCover():Bitmap {
return cover
}
}
In the controller i have this:
public function selectRadio(radio:Radio):void{
model.selectRadio(radio);
}
In view I have the button with the eventlistner:
radio.addEventListener(MouseEvent.CLICK, function():void {
controller.selectRadio(model.getRadio(0));
});
And finally in the model i have:
private var radio:Radio = new Radio("P3", new URLRequest("http://live-icy.gss.dr.dk:80/A/A05L.mp3"), drp3);
private var radioArray:Array = new Array(radio);
private var r:Number;
public function selectRadio(radio:Radio):void {
var s:Sound = new Sound();
var chan:SoundChannel = s.play();
s.load();
trace("radio");
}
public function getRadios():Array {
return radioArray;
trace("All radio channels collected");
}
public function getRadio(radioNumber:int):Radio {
r = radioNumber;
return radioArray[radioNumber];
trace("Actual radio collected");
}
The problem is in the selectRadio function. I don't know how to load the URL in the arrays. It should be s.load(--something in here--); The reason why I'm doing this, is because I want to have multiple radio stations.
Hope you can help :)
var s:Sound = new Sound(radio.getURL());
var chan:SoundChannel = s.play();
load function will be called automatically by the constructor, also don't forget to stop previous SoundChannel.
and here: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Sound.html you will find everything about Sound

Resources