Account.update event

I am trying to listen to the account.update event (Events)

I created an app to live at the Sales Account Details Page.

{
“platform-version”: “2.2”,
“product”: {
“freshworks_crm”: {
“location”: {
“sales_account_entity_menu”: {
“url”: “index.html”,
“icon”: “styles/images/icon.svg”
}
}
}
},
“whitelisted-domains”: ,
“engines”: {
“node”: “12.22.7”,
“fdk”: “7.5.1”
}
}

document.onreadystatechange = function() {
if (document.readyState === ‘interactive’) renderApp();
function renderApp() {
var onInit = app.initialized();

onInit.then(getClient).catch(handleErr);

function getClient(_client) {
  window.client = _client;
  client.events.on("account.update", propertyChangeCallback);
}

}
};

function propertyChangeCallback (data)
{
console.log(“event occurred”);
console.log(data);
};

function handleErr(err) {
console.error(Error occured. Details:, err);
}

I install the app. The icon shows up but I can’t make the event trigger. I update the account but no logs are written to the console.

Can you please try with tbe below snippet?
eg:

 app.initialized().then(_client => {
  window.client = _client;
  client.events.on("app.activated", () => {
   client.events.on("account.update", function (event) {
     console.log(event);
    });
  });
 });

Thanks

1 Like

Thank you for the response.

I tried this:

console.log('script started')
app.initialized().then(_client => {
  window.client = _client;
  client.events.on("app.activated", () => {
    console.log('app.activated event triggered')
    client.events.on("account.update", function (event) {
      console.log('account.update event triggered')
    });
  });
});

Still the account.update event won’t run.

This is the output of running the app in debug mode
NODE_DEBUG=fdk fdk run

(logger.js) Starting FDK in node v12.22.7 on linux
(sequelize.js) setting up sqilite at "/home/miqueias/CLIENTES/HAYTEK/FRESHWORKS/account-form/.fdk/store.sqlite"
(index.js) Running with args {"cmd":"run","gopts":{},"opts":{},"goptArg":{},"optArg":{},"args":[]}
(data-util.js) Read {"version_details":{"cli":{"deprecated":{"version":"<8","message":"This FDK version will be deprecated by August 31, 2022. There will be no further feature updates to this version. For a seamless app building experience, ensure to move to the latest FDK version. For more information, see https://community.developers.freshworks.com/t/5433."},"forced":{"version":"7.0.0","command":"npm install https://dl.freshdev.io/cli/fdk-7.0.0.tgz -g","message":"Your FDK version has been forced updated to v7.0.0, please visit https://community.developers.freshworks.com/t/fdk-v7-0-announcing-node-js-v12-and-es6-support/3606 to know more"},"latest":{"version":"8.2.0","command":"npm install https://dl.freshdev.io/cli/fdk.tgz -g","message":"For Freshservice, you can now build apps that use Entity Storage - Custom Objects. For more information, check out the documentation at https://developers.freshservice.com/docs/entity-storage-custom-objects/. For a demonstration of this feature, check out the sample apps at https://github.com/freshworks-developers/custom-objects-samples."}},"addon":{"version":"1.10.1","url":"https://dl.freshdev.io/cli-addon/addon-1.10.1.zip"}},"last_updated":{"time_stamp":1651770592411}}
(updater.js) last check less than an day ago, not looking for updates
(manifest.js) Reloading manifest with {"platform-version":"2.2","product":{"freshworks_crm":{"location":{"sales_account_entity_menu":{"url":"index.html","icon":"styles/images/icon.svg"}}}},"whitelisted-domains":[],"engines":{"node":"12.22.7","fdk":"7.5.1"}}.
(manifest.js) Inferred db as features.
(data-util.js) Read {"version_details":{"cli":{"deprecated":{"version":"<8","message":"This FDK version will be deprecated by August 31, 2022. There will be no further feature updates to this version. For a seamless app building experience, ensure to move to the latest FDK version. For more information, see https://community.developers.freshworks.com/t/5433."},"forced":{"version":"7.0.0","command":"npm install https://dl.freshdev.io/cli/fdk-7.0.0.tgz -g","message":"Your FDK version has been forced updated to v7.0.0, please visit https://community.developers.freshworks.com/t/fdk-v7-0-announcing-node-js-v12-and-es6-support/3606 to know more"},"latest":{"version":"8.2.0","command":"npm install https://dl.freshdev.io/cli/fdk.tgz -g","message":"For Freshservice, you can now build apps that use Entity Storage - Custom Objects. For more information, check out the documentation at https://developers.freshservice.com/docs/entity-storage-custom-objects/. For a demonstration of this feature, check out the sample apps at https://github.com/freshworks-developers/custom-objects-samples."}},"addon":{"version":"1.10.1","url":"https://dl.freshdev.io/cli-addon/addon-1.10.1.zip"}},"last_updated":{"time_stamp":1651770592411}}
(data-util.js) Read {"version_details":{"cli":{"deprecated":{"version":"<8","message":"This FDK version will be deprecated by August 31, 2022. There will be no further feature updates to this version. For a seamless app building experience, ensure to move to the latest FDK version. For more information, see https://community.developers.freshworks.com/t/5433."},"forced":{"version":"7.0.0","command":"npm install https://dl.freshdev.io/cli/fdk-7.0.0.tgz -g","message":"Your FDK version has been forced updated to v7.0.0, please visit https://community.developers.freshworks.com/t/fdk-v7-0-announcing-node-js-v12-and-es6-support/3606 to know more"},"latest":{"version":"8.2.0","command":"npm install https://dl.freshdev.io/cli/fdk.tgz -g","message":"For Freshservice, you can now build apps that use Entity Storage - Custom Objects. For more information, check out the documentation at https://developers.freshservice.com/docs/entity-storage-custom-objects/. For a demonstration of this feature, check out the sample apps at https://github.com/freshworks-developers/custom-objects-samples."}},"addon":{"version":"1.10.1","url":"https://dl.freshdev.io/cli-addon/addon-1.10.1.zip"}},"last_updated":{"time_stamp":1651770592411}}
(data-util.js) Read {"version_details":{"cli":{"deprecated":{"version":"<8","message":"This FDK version will be deprecated by August 31, 2022. There will be no further feature updates to this version. For a seamless app building experience, ensure to move to the latest FDK version. For more information, see https://community.developers.freshworks.com/t/5433."},"forced":{"version":"7.0.0","command":"npm install https://dl.freshdev.io/cli/fdk-7.0.0.tgz -g","message":"Your FDK version has been forced updated to v7.0.0, please visit https://community.developers.freshworks.com/t/fdk-v7-0-announcing-node-js-v12-and-es6-support/3606 to know more"},"latest":{"version":"8.2.0","command":"npm install https://dl.freshdev.io/cli/fdk.tgz -g","message":"For Freshservice, you can now build apps that use Entity Storage - Custom Objects. For more information, check out the documentation at https://developers.freshservice.com/docs/entity-storage-custom-objects/. For a demonstration of this feature, check out the sample apps at https://github.com/freshworks-developers/custom-objects-samples."}},"addon":{"version":"1.10.1","url":"https://dl.freshdev.io/cli-addon/addon-1.10.1.zip"}},"last_updated":{"time_stamp":1651770592411}}
(validate.js) asked to skip the following validations, 
(validate.js) running validator actions
(validate.js) running validator app-dir
(validate.js) running validator config-dir
(config-dir.js) Checking to see if /home/miqueias/CLIENTES/HAYTEK/FRESHWORKS/account-form/config/ exists.
(config-dir.js) Fetched the following config files iparams.json
(validate.js) running validator custom-objects
(validate.js) running validator event
(validate.js) running validator iparam
(validate.js) skipping validator lint
(validate.js) running validator manifest
(manifest.js) running manifest validation with type run_validation
(validate.js) skipping validator manifest-dependency
(validate.js) running validator oauth
(validate.js) skipping validator pkgsize
(validate.js) running validator schema
(validate.js) running validator version-check
(watcher.js) Preparing to watch the following files ./app,./config,./manifest.json
(data-util.js) Read {"accoun_101_101_freshworks_crm":{"accoun_101_101_custom_iparams":{},"isLocalAppInstalled":true,"isLocalAppEnabled":true}}
(custom-objects.js) to force or not? false
(custom-objects.js) beginning to re-sync db
(index.js) loading model at "/home/miqueias/.nvm/versions/node/v12.22.7/lib/node_modules/fdk/lib/models/bigint-pivot.js"
(index.js) loading model at "/home/miqueias/.nvm/versions/node/v12.22.7/lib/node_modules/fdk/lib/models/entity-field-choice.js"
(index.js) loading model at "/home/miqueias/.nvm/versions/node/v12.22.7/lib/node_modules/fdk/lib/models/entity-field.js"
(index.js) loading model at "/home/miqueias/.nvm/versions/node/v12.22.7/lib/node_modules/fdk/lib/models/entity.js"
(index.js) loading model at "/home/miqueias/.nvm/versions/node/v12.22.7/lib/node_modules/fdk/lib/models/record.js"
(index.js) loading model at "/home/miqueias/.nvm/versions/node/v12.22.7/lib/node_modules/fdk/lib/models/string-pivot.js"
(data-util.js) Read {"accoun_101_101_freshworks_crm":{"accoun_101_101_custom_iparams":{},"isLocalAppInstalled":true,"isLocalAppEnabled":true}}
(custom-objects.js) updated local store with latest entity hash
Starting local testing server at http://*:10001/    
Append 'dev=true' to your Freshworks_crm account URL to start testing    
e.g. https://domain.myfreshworks.com/crm/sales/contacts/2007663673?dev=true    
Quit the server with Control-C.
(data-util.js) Read {"accoun_101_101_freshworks_crm":{"accoun_101_101_custom_iparams":{},"isLocalAppInstalled":true,"isLocalAppEnabled":true}}
(data-util.js) Read {"accoun_101_101_freshworks_crm":{"accoun_101_101_custom_iparams":{},"isLocalAppInstalled":true,"isLocalAppEnabled":true}}
(iframe.js) Responding to product with {"configs":{},"displayName":"account-form","product":{"freshworks_crm":{"location":{"sales_account_entity_menu":{"url":"agent/index.html","icon":"agent/styles/images/icon.svg"}}}},"features":["db"],"actions":false,"omni":false,"products":["freshworks_crm"],"platform":"2.2","v2":[{"id":1,"version_id":1,"configs":{},"displayName":"account-form","placeholders":{"sales_account_entity_menu":{"url":"http://localhost:10001/iframe/index.html","icon":"styles/images/icon.svg"}}}]}
(data-util.js) Read {"accoun_101_101_freshworks_crm":{"accoun_101_101_custom_iparams":{},"isLocalAppInstalled":true,"isLocalAppEnabled":true}}
TypeError: Cannot read property 'location' of undefined
    at addScopeToURLs (/home/miqueias/.nvm/versions/node/v12.22.7/lib/node_modules/fdk/lib/routes/iframe.js:86:55)
    at iframeAPIHandler (/home/miqueias/.nvm/versions/node/v12.22.7/lib/node_modules/fdk/lib/routes/iframe.js:104:14)
    at Layer.handle [as handle_request] (/home/miqueias/.nvm/versions/node/v12.22.7/lib/node_modules/fdk/node_modules/express/lib/router/layer.js:95:5)
    at next (/home/miqueias/.nvm/versions/node/v12.22.7/lib/node_modules/fdk/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/home/miqueias/.nvm/versions/node/v12.22.7/lib/node_modules/fdk/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/home/miqueias/.nvm/versions/node/v12.22.7/lib/node_modules/fdk/node_modules/express/lib/router/layer.js:95:5)
    at /home/miqueias/.nvm/versions/node/v12.22.7/lib/node_modules/fdk/node_modules/express/lib/router/index.js:281:22
    at Function.process_params (/home/miqueias/.nvm/versions/node/v12.22.7/lib/node_modules/fdk/node_modules/express/lib/router/index.js:341:12)
    at next (/home/miqueias/.nvm/versions/node/v12.22.7/lib/node_modules/fdk/node_modules/express/lib/router/index.js:275:10)
    at Function.handle (/home/miqueias/.nvm/versions/node/v12.22.7/lib/node_modules/fdk/node_modules/express/lib/router/index.js:174:3)
    at router (/home/miqueias/.nvm/versions/node/v12.22.7/lib/node_modules/fdk/node_modules/express/lib/router/index.js:47:12)
    at Layer.handle [as handle_request] (/home/miqueias/.nvm/versions/node/v12.22.7/lib/node_modules/fdk/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/home/miqueias/.nvm/versions/node/v12.22.7/lib/node_modules/fdk/node_modules/express/lib/router/index.js:323:13)
    at /home/miqueias/.nvm/versions/node/v12.22.7/lib/node_modules/fdk/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/home/miqueias/.nvm/versions/node/v12.22.7/lib/node_modules/fdk/node_modules/express/lib/router/index.js:341:12)
    at Immediate.next (/home/miqueias/.nvm/versions/node/v12.22.7/lib/node_modules/fdk/node_modules/express/lib/router/index.js:275:10)
(iframe.js) Responding with contents of /index.html
(iframe.js) Responding with contents of /scripts/app.js
(coverage-util.js) Instrumenting /home/miqueias/CLIENTES/HAYTEK/FRESHWORKS/account-form/app/scripts/app.js
(coverage-util.js) Writing coverage.

@Miqueias_Dernier

possible, can you please share with us the App zip, will debug and get back to you at the earliest

Thanks

account-form.zip (4.6 KB)

@Miqueias_Dernier,
Good Day!
Sorry for the delay in responding!
I had reproduced the issue,
can you please confirm that you are using FDK to run the app (local app) by adding dev=true, and once you updated the account (Institutes) fields dev=true removed from the URL?
if so, this is the bug in the product. I will get in touch with the product team to solve this ASAP.
to unblock you for the development, I would suggest adding it as the custom app and testing your changes.

Hope it helps :slight_smile:

Thanks

Thank you for the reply.
I can’t make it work though, even when it’s added as a custom app.

@Miqueias_Dernier,
Maybe it is a problem with your account
with your same app, I add it as a custom app in one of my test accounts and I am able to get the event triggered.

I request you to create an L2 ticket by sending an email to support@freshsales.io

Thanks

This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.