- Java锁的逻辑(结合对象头和ObjectMonitor)
- 还在用饼状图?来瞧瞧这些炫酷的百分比可视化新图形(附代码实现)⛵
- 自动注册实体类到EntityFrameworkCore上下文,并适配ABP及ABPVNext
- 基于Sklearn机器学习代码实战
本篇参考:
https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.reference_get_record_notify 。
https://developer.salesforce.com/docs/component-library/documentation/en/lwc/reference_notify_record_update 。
我们在 Salesforce LWC学习(二十九) getRecordNotifyChange(LDS拓展增强篇) 中讲述了针对LDS通知获取最新版本数据使用。在winter23的v56版本中,此方法还在正常使用,在 spring23的v57版本中,getRecordNotifyChange方法已被标记弃用,官方推荐notifyRecordUpdateAvailable方法,功能相同.
notifyRecordUpdateAvailable方法和 getRecordNotifyChange传递形参一样,针对此方法,分成两步走.
1. 头部引入: import { notifyRecordUpdateAvailable } from 'lightning/uiRecordApi' ,
2. 需要刷新的地方使用: notifyRecordUpdateAvailable ( items : Array < {recordId : string } > ) 。
需要注意的是, recordId同样需要在user interface api支持的,否则不生效.
详情: https://developer.salesforce.com/docs/atlas.en-us.uiapi.meta/uiapi/ui_api_all_supported_objects.htm 。
接下来demo进行参考.
import { LightningElement, wire,api,track } from 'lwc' ; import { getRecord,notifyRecordUpdateAvailable } from 'lightning/uiRecordApi' ; import { refreshApex } from '@salesforce/apex' ; import saveAccount from '@salesforce/apex/RecordNotifyChangeController.saveAccount' ; import getAccount from '@salesforce/apex/RecordNotifyChangeController.getAccount' ; import PHONE_FIELD from '@salesforce/schema/Account.Phone' ; import INDUSTRY_FIELD from '@salesforce/schema/Account.Industry' ; import NAME_FIELD from '@salesforce/schema/Account.Name' ; export default class RecordNotifyChangeSample extends LightningElement { @api recordId; @track phone; @track industry; @track accountName; fields = [PHONE_FIELD,INDUSTRY_FIELD]; accountRecord; @wire(getAccount,{recordId : '$recordId' }) wiredAccount(value) { this .accountRecord = value; const { data, error } = value; if (data) { this .industry = data.Industry; this .phone = data.Phone; this .accountName = data.Name; } } handleChange(event) { if (event.target.name === 'phone' ) { this .phone = event.detail.value; } else if (event.target.name === 'industry' ) { this .industry = event.detail.value; } } async handleSave() { await saveAccount({ recordId: this .recordId, industry : this .industry, phone : this .phone}) .then(result => { if (result === 'success' ) { refreshApex( this .accountRecord); notifyRecordUpdateAvailable([{recordId: this .recordId}]); } else { // TODO } }) . catch (error => { // TODO }); } }
详情demo可以参考:https://boulder-bard-27f.notion.site/lightning-e757a8902c194f9bbe633b92a9d81673 。
总结: 尽管官方弃用了此方法,但是没有提及后续会移除此方法,所以以前的方法可以保留,后续的话,推荐使用新方法。篇中有错误欢迎指出,有不懂欢迎留言.
最后此篇关于SalesforceLWC学习(四十二)getRecordNotifyChange已弃用的文章就讲到这里了,如果你想了解更多关于SalesforceLWC学习(四十二)getRecordNotifyChange已弃用的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。
我是一名优秀的程序员,十分优秀!