Examples of Vlocity/SF LWC components (in various states of working)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.4 KiB

  1. import tmpl from './myActionComponent.html';
  2. import { LightningElement, track } from 'lwc';
  3. import { OmniscriptBaseMixin } from 'vlocity_cmt/omniscriptBaseMixin';
  4. export default class MyActionComponent extends OmniscriptBaseMixin(LightningElement) {
  5. @track url;
  6. @track query = JSON.stringify({
  7. datasource: {
  8. type: "query",
  9. value: {
  10. query: "SELECT Id, name FROM Contact LIMIT 1"
  11. }
  12. },
  13. url: "/${data[0].Id}",
  14. target: "_blank",
  15. parameters: {},
  16. navigate: false
  17. });
  18. connectedCallback() {
  19. console.log('MyActionComponent - Connected');
  20. }
  21. render() {
  22. return tmpl;
  23. }
  24. fetchData(evt) {
  25. let action = evt.target;
  26. let def = JSON.parse(this.query);
  27. action.definition = this.query;
  28. action.triggerAction();
  29. }
  30. // I'm passing these properties down to the navigate-action via
  31. // attributes.
  32. onSuccessCallback(evt) {
  33. let result = evt.detail.result;
  34. this._targetType = "Record";
  35. this._targetId = result[0].Id;
  36. // Because we're setting the attribute values via attributes,
  37. // we need to give the ui a chance to re-render.
  38. Promise.resolve().then(() => {
  39. this.url = result[0].attributes.url;
  40. });
  41. }
  42. onErrorCallback(error) {
  43. console.log(error);
  44. }
  45. }