|
|
- import tmpl from './myActionComponent.html';
- import { LightningElement, track } from 'lwc';
- import { OmniscriptBaseMixin } from 'vlocity_cmt/omniscriptBaseMixin';
-
- export default class MyActionComponent extends OmniscriptBaseMixin(LightningElement) {
- @track url;
- @track query = JSON.stringify({
- datasource: {
- type: "query",
- value: {
- query: "SELECT Id, name FROM Contact LIMIT 1"
- }
- },
- url: "/${data[0].Id}",
- target: "_blank",
- parameters: {},
- navigate: false
- });
-
- connectedCallback() {
- console.log('MyActionComponent - Connected');
- }
-
- render() {
- return tmpl;
- }
-
- fetchData(evt) {
- let action = evt.target;
- let def = JSON.parse(this.query);
- action.definition = this.query;
- action.triggerAction();
- }
- // I'm passing these properties down to the navigate-action via
- // attributes.
- onSuccessCallback(evt) {
- let result = evt.detail.result;
- this._targetType = "Record";
- this._targetId = result[0].Id;
-
- // Because we're setting the attribute values via attributes,
- // we need to give the ui a chance to re-render.
- Promise.resolve().then(() => {
- this.url = result[0].attributes.url;
- });
- }
-
- onErrorCallback(error) {
- console.log(error);
- }
-
-
- }
|