Skip to content

Commit

Permalink
Fixed Config Error on None-Record-Detail Exp Page (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
hrk623 authored Mar 5, 2024
1 parent d4030d8 commit 901e0e5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export default class SearchCardClassic extends LightningElement {
if (data && !data.hasError) {
// eslint-disable-next-line @lwc/lwc/no-api-reassignments
this.objectApiName = data.body;
console.log("this.objectApiName", this.objectApiName);
} else if (data && data.hasError) {
this.showConfigurationError(data.errorMessage);
} else if (error) {
Expand Down
16 changes: 10 additions & 6 deletions force-app/main/v2/shared/classes/SchemaDataService.cls
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ public with sharing class SchemaDataService extends DataService {
@AuraEnabled(cacheable=true)
public static Result getObjectApiNameById(String recordId) {
try {
return new Result(
((ID) recordId)
.getSObjectType()
.getDescribe(SObjectDescribeOptions.DEFERRED)
.getName()
);
if (String.isBlank(recordId)) {
return new Result('');
} else {
return new Result(
((ID) recordId)
.getSObjectType()
.getDescribe(SObjectDescribeOptions.DEFERRED)
.getName()
);
}
} catch (Exception e) {
return new Result('', e.getMessage());
}
Expand Down
13 changes: 12 additions & 1 deletion force-app/main/v2/shared/classes/TestSchemaDataService.cls
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,22 @@ public class TestSchemaDataService {
static void getObjectApiNameById() {
User u = [SELECT Id, LastName FROM User LIMIT 1][0];
String userId = u.Id;

DataService.Result result = SchemaDataService.getObjectApiNameById(userId);
String objectApiName = (String) result.body;
System.assertEquals('User', objectApiName);
}
@isTest
static void getObjectApiNameByIdWhenRecordIdIsNull() {
DataService.Result result = SchemaDataService.getObjectApiNameById(null);
String objectApiName = (String) result.body;
System.assertEquals('', objectApiName);
}
@isTest
static void getObjectApiNameByIdWhenRecordIdIsEmpty() {
DataService.Result result = SchemaDataService.getObjectApiNameById('');
String objectApiName = (String) result.body;
System.assertEquals('', objectApiName);
}

// TEST: Result getFieldInfo(String objectApiName, String fieldApiName)
@isTest
Expand Down
20 changes: 0 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 901e0e5

Please sign in to comment.