You need to sign in to do that
Don't have an account?
Sai Kiran 1846
ApexTesting
public without sharing class X311Portal_EditProfileCtrl {
@AuraEnabled
public static Map<String, Object> getContactDetails(){
Map<String, Object> returnMap = new Map<String, Object>();
User userRecord = [SELECT Id, AccountId, ContactId FROM User WHERE Id =: UserInfo.getUserId()];
Account personAccRecord = [SELECT FirstName, LastName, PersonEmail, Phone, PersonMailingCity, PersonMailingState,
PersonMailingPostalCode, PersonMailingStreet FROM Account WHERE Id =: userRecord.AccountId];
returnMap.put('personAccRecord', personAccRecord);
return returnMap;
}
@AuraEnabled
public static void updateContactDetails(String record) {
Account accountRecord = (Account) JSON.deserialize(record, Account.class);
upsert accountRecord;
}
}
@AuraEnabled
public static Map<String, Object> getContactDetails(){
Map<String, Object> returnMap = new Map<String, Object>();
User userRecord = [SELECT Id, AccountId, ContactId FROM User WHERE Id =: UserInfo.getUserId()];
Account personAccRecord = [SELECT FirstName, LastName, PersonEmail, Phone, PersonMailingCity, PersonMailingState,
PersonMailingPostalCode, PersonMailingStreet FROM Account WHERE Id =: userRecord.AccountId];
returnMap.put('personAccRecord', personAccRecord);
return returnMap;
}
@AuraEnabled
public static void updateContactDetails(String record) {
Account accountRecord = (Account) JSON.deserialize(record, Account.class);
upsert accountRecord;
}
}
//Create person account
Use System.runAs(user){
//create user record where userId.Account = personAccId
test.startTest();
//Invoke your class - X311Portal_EditProfileCtrl.getContactDetails();
test.stopTest();
}
Let me know if it helps.
try with below code.
If this helps, Please mark it as best answer.
Thanks!!