Not getting new currentEntityInfo when app.activate is triggered

My custom app is not getting updated currentEntityInfo when contact is changed to a new contact. My app is loaded on contacts pages in freshsales crm. The app.activated is triggered and I call client.data.get inside the app.activated event handler, but the contact ID I get back is from the contact that was loaded initially. Regardless of how many times I change the contact, the original contact id is returned.

Here are the steps:

  1. Load a contact
  2. Select my custom app in left nav
  3. View console log and see the client id for the correct client is printed
  4. Search for a new contact in the searchbox at top of page
  5. Pick a different contact from the search results and wait for page to load
  6. Select my custom app in left nav
  7. Observe the client id from the previous contact is printed

Below is the code:

document.onreadystatechange = function () {
  if (document.readyState === 'interactive'){
    app.initialized().then(function (_client) {
      log.setLevel('trace')
      window.client = _client
      client.events.on('app.activated', function(){
        log.info('SAFR App Activated.')

        // The Data Method is used after the app is activated
        client.data.get('currentEntityInfo').then(function (data) {
          var contact_id=data.currentEntityInfo.currentEntityId
          log.info('Got Contact ID', contact_id)
          window.contact_id=contact_id
        })
      })
    })
  }
}

Each time I load a contact, I see the log “SAFR App Activated” followed by a contact Id. But every time the contact Id is for the first contact that was loaded.

Even if I don’t load my custom app for the first contact, if I then load 2nd contact and open the custom app for that contact, the contact_id printed is for the very first contact that was loaded.

So in this case the flow is like this:

  1. Load contact 1
  2. Use search at top and load contact 2
  3. use Search and top and load contact 3
  4. Open my custom app → Observe contact Id for contact 1 is printed in log.

I’ve followed guidance on Control the context within the app with App Lifecycle Methods to the best I can see.

Can someone help please explain what I’m doing wrong to not get refreshed contact id?

1 Like

@stevemc I am also getting the same issue. Any luck on that?

Not yet. I submitted a ticket about this with FW team and met with a FW developer. They were able to repro my issue and are investigating. I have not heard back. in fact, I was thinking just yesterday to check in with them and it slipped my mind.

I’ll report back here once I learn of a solution. Until then the only workaround I know is to change to a completed different page (i.e. click on all contacts list in left nav) and then search for a new contact.

2 Likes

@rahulsaini A fix has been released by Freshworks and this issue is now fixed. :smile:

2 Likes

@stevemc Thanks for the update! Yes, I see it’s fixed. Thanks Again! :pray:

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