【前言】:在使用Path时,我们期望在Community中隐藏“Mark Stage as Complete”按钮,来避免业务员手动控制Stage,在App Builder里面能够选择性显隐,但在Community Builder中却没有标准的开关。
【Sample Code】:
1. PathComponent.cmp
2. PathComponentController.js
({handleSelect : function (component, event, helper) {var stepName = event.getParam("detail").value;var toastEvent = $A.get("e.force:showToast");toastEvent.setParams({"title": "Success!","message": "Toast from " + stepName});//toastEvent.fire();}
})
3. PathComponent.design
【效果预览】:
![](https://img.php1.cn/3cd4a/1eebe/cd5/0d80e8a685a9a87b.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2l0c21lX3dlYg==,size_16,color_FFFFFF,t_70)
【常见问题】:
Q1. 如何确保Path的Guidance默认打开?Make the key fields and guidance for success visible by default
A1: 勾上下图标注的"Remember user's Path preferences" checkbox即可。那Lead记录举例,假如有A/B/C 3个记录,勾上后如果用户再查看A记录时选择的折叠,随后打开B/C时,默认折叠;反之,当查看B记录选择打开时,随后查看其他Lead记录默认打开。至于该全局设置是基于Sobject还是基于User的,待验证!
![](https://img.php1.cn/3cd4a/1eebe/cd5/43a754c811e7ec5c.webp?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2l0c21lX3dlYg==,size_16,color_FFFFFF,t_70)
Q2. 如何为Personal Account类记录类型的页面布局展示Path?
A2: Personal Account展示Path时,Picklist类型的字段Stage应该创建在Account上,而非Contact上。我们知道在Contact创建一个Satge字段,Account上就又一个对应的Stage__pc被创建,此时基于该字段创建Path,即使Path组件通过APP Builder或Community Builder被拖拽到Page Layout,也无法显示。
【资源链接】:
Path (Lightning Community Component)