728x90
문제 당시
LWC JS
import { LightningElement, api, track, wire } from 'lwc';
import { getRecord } from 'lightning/uiRecordApi';
import { refreshApex } from '@salesforce/apex';
import checkConfirm from '@salesforce/apex/className.checkSubmit';
export default class absentAsManagement extends LightningElement {
@api recordId;
@track record;
@track error;
/// 중간생략 ///
submitButton() {
checkSubmit({
rId : recordId
, cnt : cnt
})
.then(() => {
refreshApex(this.record)
.then(() => {
// do something with the refreshed data in this.opptiesOverAmount
});
})
.catch((error) => {
this.message = 'Error received: code' + error.errorCode + ', ' +
'message ' + error.body.message;
});
}
}
Apex class
@AuraEnabled(cacheable=true)
public static Obj__c checkSubmit(String rId, Integer cnt) {
Obj__c target = [SELECT ID FROM Obj__c WHERE Id = :rId LIMIT 1];
update target;
return target;
}
원인
- @AuraEnabled(cacheable=true)
사실 수정을 여러가지 과정을 거쳐서 시도했는데 결국 원인은 저게 문제였다
(리턴값을 변경해보고, 리스트로 가져오는 값을 오브젝트 자체 단일값으로 바꿔보기도 하고 등등..)
JS단도 여러가지 수정을 했지만 어쨌든 가장 크리티컬한 오류는 저 친구여서 수정은 단순했다.
중간단계에서 알게된 개념
- (cacheable=true) 얘랑 @wire 얘는 셋트
- @wire
- 세일즈포스 데이터를 가져온다의 개념이었지.. 그다음 어떻게 사용하는지 몰랐던..나^^..
- 얘는 Property에 붙일수도 있고 Funtion에도 붙일 수 있습니다..
- Property
- HTML 사이드로 움직인다
- 리턴데이터 심플하다
- Funtion
- 리턴데이터로 뭔가 가공해야한다~
- Property
- Imperative call
얘도 나중에 따로 공부 후 포스팅 예정...
최종 수정 (단순)
@AuraEnabled
public static Obj__c checkSubmit(String rId, Integer cnt) {
Obj__c target = [SELECT ID FROM Obj__c WHERE Id = :rId LIMIT 1];
update target;
return target;
}
참고
https://developer.salesforce.com/forums/?id=9062I000000IE4kQAG
DeveloperForce
Welcome to Support! Search for an answer or ask a question of the zone or Customer Support. Need help? Dismiss + Start a Discussion
dfc-org-production.force.com
https://tempflip.medium.com/3-ways-to-call-an-apex-method-from-a-lighting-web-component-b2d2f56e447b
728x90
'개발' 카테고리의 다른 글
[Salesforce] lightning-button 클릭시 Event를 통해 Id, Name 가져오기 (0) | 2022.10.20 |
---|---|
[Salesforce] 인텔리제이 커넥션 오류, Security Token Reset / 토큰 리셋, 생성하는법 (0) | 2022.10.19 |
[Salesforce] LWC Decorators @Wire @Api @track 비교 (0) | 2022.10.14 |
[Salesforce] Record ID: cannot specify Id in an insert call (0) | 2022.10.10 |
[Salesforce] Winter 23 관련 참고 사이트 (0) | 2022.09.21 |