public with sharing class PropertyDataController { @AuraEnabled(cacheable=true) public static List getProperties() { try { System.debug('=== FETCHING ALL PROPERTIES FROM PCRM OBJECT ==='); // Query using fields that are actually available in pcrm__Property__c String query = 'SELECT Id, Name, ' + 'pcrm__Property_Type__c, pcrm__Status__c, ' + 'pcrm__Bathrooms__c, pcrm__Bedrooms__c, pcrm__Size__c, ' + 'pcrm__Sale_Price_min__c, pcrm__Sale_Price_max__c, ' + 'pcrm__Rent_Price_min__c, pcrm__Rent_Price_max__c, ' + 'pcrm__Description_English__c, pcrm__Title_English__c, ' + 'pcrm__City_Bayut_Dubizzle__c, pcrm__Community_Propertyfinder__c, ' + 'pcrm__Furnished__c, pcrm__Floor__c, pcrm__Build_Year__c, ' + 'pcrm__Parking_Spaces__c, pcrm__Offering_Type__c, ' + 'pcrm__Unit_Number__c, pcrm__Locality_Bayut_Dubizzle__c, ' + 'pcrm__Sub_Locality_Bayut_Dubizzle__c, pcrm__Tower_Bayut_Dubizzle__c, ' + 'pcrm__Sub_Community_Propertyfinder__c, pcrm__Property_Name_Propertyfinder__c, ' + 'pcrm__City_Propertyfinder__c, ' + 'CreatedDate, LastModifiedDate ' + 'FROM pcrm__Property__c ' + 'ORDER BY Name ASC'; List properties = Database.query(query); System.debug('=== PROPERTIES FETCHED FROM PCRM ==='); System.debug('Total properties found: ' + properties.size()); // Log first property details for debugging if (!properties.isEmpty()) { pcrm__Property__c firstProp = properties[0]; System.debug('First property details:'); System.debug('Name: ' + firstProp.Name); System.debug('Type: ' + firstProp.pcrm__Property_Type__c); System.debug('Status: ' + firstProp.pcrm__Status__c); System.debug('Bedrooms: ' + firstProp.pcrm__Bedrooms__c); System.debug('Bathrooms: ' + firstProp.pcrm__Bathrooms__c); System.debug('Size: ' + firstProp.pcrm__Size__c); System.debug('Sale Price Min: ' + firstProp.pcrm__Sale_Price_min__c); System.debug('Sale Price Max: ' + firstProp.pcrm__Sale_Price_max__c); System.debug('Rent Price Min: ' + firstProp.pcrm__Rent_Price_min__c); System.debug('Rent Price Max: ' + firstProp.pcrm__Rent_Price_max__c); System.debug('City: ' + firstProp.pcrm__City_Bayut_Dubizzle__c); System.debug('Community: ' + firstProp.pcrm__Community_Propertyfinder__c); System.debug('Description: ' + firstProp.pcrm__Description_English__c); System.debug('Title: ' + firstProp.pcrm__Title_English__c); System.debug('Furnished: ' + firstProp.pcrm__Furnished__c); System.debug('Floor: ' + firstProp.pcrm__Floor__c); System.debug('Build Year: ' + firstProp.pcrm__Build_Year__c); System.debug('Parking Spaces: ' + firstProp.pcrm__Parking_Spaces__c); System.debug('Offering Type: ' + firstProp.pcrm__Offering_Type__c); } return properties; } catch (Exception e) { System.debug('Error fetching properties: ' + e.getMessage()); System.debug('Stack trace: ' + e.getStackTraceString()); throw new AuraHandledException('Failed to fetch properties: ' + e.getMessage()); } } @AuraEnabled(cacheable=true) public static pcrm__Property__c getPropertyDetails(String propertyId) { try { System.debug('=== FETCHING COMPLETE PROPERTY DETAILS FROM PCRM ==='); System.debug('Property ID: ' + propertyId); // Query using fields that are actually available in pcrm__Property__c String query = 'SELECT Id, Name, ' + 'pcrm__Property_Type__c, pcrm__Status__c, ' + 'pcrm__Bathrooms__c, pcrm__Bedrooms__c, pcrm__Size__c, ' + 'pcrm__Sale_Price_min__c, pcrm__Sale_Price_max__c, ' + 'pcrm__Rent_Price_min__c, pcrm__Rent_Price_max__c, ' + 'pcrm__Description_English__c, pcrm__Title_English__c, ' + 'pcrm__City_Bayut_Dubizzle__c, pcrm__Community_Propertyfinder__c, ' + 'pcrm__Furnished__c, pcrm__Floor__c, pcrm__Build_Year__c, ' + 'pcrm__Parking_Spaces__c, pcrm__Offering_Type__c, ' + 'pcrm__Unit_Number__c, pcrm__Locality_Bayut_Dubizzle__c, ' + 'pcrm__Sub_Locality_Bayut_Dubizzle__c, pcrm__Tower_Bayut_Dubizzle__c, ' + 'pcrm__Sub_Community_Propertyfinder__c, pcrm__Property_Name_Propertyfinder__c, ' + 'pcrm__City_Propertyfinder__c, ' + 'CreatedDate, LastModifiedDate ' + 'FROM pcrm__Property__c ' + 'WHERE Id = :propertyId'; pcrm__Property__c property = Database.query(query); if (property != null) { System.debug('=== PROPERTY DETAILS FETCHED FROM PCRM ==='); System.debug('Name: ' + property.Name); System.debug('Type: ' + property.pcrm__Property_Type__c); System.debug('Status: ' + property.pcrm__Status__c); System.debug('Bedrooms: ' + property.pcrm__Bedrooms__c); System.debug('Bathrooms: ' + property.pcrm__Bathrooms__c); System.debug('Size: ' + property.pcrm__Size__c); System.debug('Sale Price Min: ' + property.pcrm__Sale_Price_min__c); System.debug('Sale Price Max: ' + property.pcrm__Sale_Price_max__c); System.debug('Rent Price Min: ' + property.pcrm__Rent_Price_min__c); System.debug('Rent Price Max: ' + property.pcrm__Rent_Price_max__c); System.debug('City: ' + property.pcrm__City_Bayut_Dubizzle__c); System.debug('Community: ' + property.pcrm__Community_Propertyfinder__c); System.debug('Description: ' + property.pcrm__Description_English__c); System.debug('Title: ' + property.pcrm__Title_English__c); System.debug('Furnished: ' + property.pcrm__Furnished__c); System.debug('Floor: ' + property.pcrm__Floor__c); System.debug('Build Year: ' + property.pcrm__Build_Year__c); System.debug('Parking Spaces: ' + property.pcrm__Parking_Spaces__c); System.debug('Offering Type: ' + property.pcrm__Offering_Type__c); } return property; } catch (Exception e) { System.debug('Error fetching property details: ' + e.getMessage()); System.debug('Stack trace: ' + e.getStackTraceString()); throw new AuraHandledException('Failed to fetch property details: ' + e.getMessage()); } } @AuraEnabled(cacheable=true) public static Integer getPropertyCount() { try { return [SELECT COUNT() FROM pcrm__Property__c]; } catch (Exception e) { System.debug('Error getting property count: ' + e.getMessage()); return 0; } } }