Skip to main content
Solved

Data Connector: Poll vs regular action


Forum|alt.badge.img+4

I am using Data Connectors.  I have a Poll action as well as a traditional action (ImportSimDataAction) that is tied to a UI button that my extension editor calls performDataAction on. 

Both the pollAction and ImportSimDataAction call the same shared code that reads CSV files from an Azure Container and imports the csv data into a Lucid “data source” with multiple collections.  For some reason, only the ImportSimDataAction use of the shared code results in the data being imported into Lucid’s data source and collections.  The pollAction version runs and executes without errors, but, the data is not in the collection.  Specifically, in the document's datatools, I do not see it.  Only the version that starts with a user clicking on a button and calling performDataAction with ImportSimData always works.

Are there known capability differences between what can be done in "Poll" vs a regular action?

Thanks,

Dan

Best answer by ablackburn

Hey @quodsimDan , I think that if you add the `HardRefresh` action to your data connector as well (it can use exactly the same implementation as your poll action) it will start working. We have a security check in place that prevents us from sending data back to documents during polling unless we have verified that a user on that doc has permission to see the resource in the third party. The `HardRefresh` action is what we use to establish that trust. Unfortunately, I don’t think we have this documented, I’ll try to make sure that happens.

 

So big picture you should try something like:

manifest.json

{
  ...
  "dataConnectors": [
    {
      ...
      "dataActions": {
        "Import": "",
        "Poll": "",
        "HardRefresh": "" // Add this one
      }
    }
  ]
}

/dataconnectors/index.ts

export const makeDataConnector = (dataConnectorClient: DataConnectorClient) => {
    ...
    return new DataConnector(dataConnectorClient)
        .defineAsynchronousAction(LucidDataConnectorActionNames.Import, importAction)
        .defineAsynchronousAction(LucidDataConnectorActionNames.Poll, pollAction)
        .defineAsynchronousAction(LucidDataConnectorActionNames.HardRefresh, pollAction); // Add this one
};

and then see if it starts working

View original
Did this topic help you find an answer to your question?

Humas1985
Lucid Legend Level 9
Forum|alt.badge.img+21
  • Lucid Legend Level 9
  • March 30, 2025

Hi ​@quodsimDan 

Poll actions have limitations when it comes to document context and refresh behavior, differing from user-triggered actions like performDataAction.

  • Consider verifying the document context by checking if the Poll action has access to the correct document ID, comparing it to the ID used when ImportSimDataAction runs successfully. If the IDs don't match, the Poll action might be running in a different context.

In addition, Poll actions may fetch data without automatically updating the document's Data Tools UI.

Try manually refreshing the data source after the Poll action completes. On the other hand, adopt a hybrid approach where the Poll action detects new data availability, triggering a separate action or notifying the user to refresh data via performDataAction. This approach leverages Poll actions' suitability for detecting changes rather than directly persisting data.

To learn more - DocumentId of running Poll and HardRefresh Data Connector Action | Community

Hope this helps - Happy to help further!!
Thank you very much and have a great one!
Warm regards


Forum|alt.badge.img+4

Huma,

Thanks for the response.  I have tried to manually refresh the data tools after a poll without success unfortunately.

I am confused by this: 

  • Consider verifying the document context by checking if the Poll action has access to the correct document ID, comparing it to the ID used when ImportSimDataAction runs successfully. If the IDs don't match, the Poll action might be running in a different context.

I see both my actions (poll vs regular contain action: DataConnectorAsynchronousAction.  DataConnectorAsynchronousAction extends DataConnectorAction which contain DataConnectorActionContext which has the following:

    documentCollections: {

        [collectionId: CollectionId]: ItemPrimaryKey[];

    };

would i be looking for the documentId in here?
 

I like this suggestion:  “adopt a hybrid approach where the Poll action detects new data availability, triggering a separate action or notifying the user to refresh data via performDataAction”

The poll action is running outside of the document in a server in the cloud.   I need to somehow push a data change to the document that the editor extension can detect to allow the hybrid approach to work.  Do you have any suggestions how the Poll action can do this if the Poll action is unable to push data to the document?

 

Thanks very much for your discussion.

Sincerely, Dan

 

 


Humas1985
Lucid Legend Level 9
Forum|alt.badge.img+21
  • Lucid Legend Level 9
  • March 31, 2025

Hi ​@quodsimDan 

Thank you for pointing this out!

To clarify, when working with DataConnectorActionContext, the documentCollections object only provides mappings of collection IDs to their primary keys, but it doesn't contain the documentId.

  • To access the documentId, you should check context.document?.id, which is typically available when actions run within a document-specific context.
  • To verify if your Poll action is running in the correct context, log the document ID in both actions. If context.document?.id is undefined in your Poll action, it means the action isn't running in a document-specific context. This could be why data changes made by the Poll action aren't reflected in Lucid's Data Tools.

Since your Poll action runs outside of the document, it might lack access to the document context. To resolve this, consider explicitly passing the documentId as a parameter to your Poll action or adopt a hybrid approach.

In this approach, the Poll action detects new data availability and triggers a separate user-initiated action (like performDataAction) to update the document.

With the below Java script, be able to check on how you can log the document ID in both actions

// In Poll action

console.log("[Poll] Document ID:", context.document?.id);

// In ImportSimDataAction

console.log("[UI Action] Document ID:", context.document?.id);

Best Regards


ablackburn
Forum|alt.badge.img+2
  • Lucid product team
  • March 31, 2025

Hey @quodsimDan , I think that if you add the `HardRefresh` action to your data connector as well (it can use exactly the same implementation as your poll action) it will start working. We have a security check in place that prevents us from sending data back to documents during polling unless we have verified that a user on that doc has permission to see the resource in the third party. The `HardRefresh` action is what we use to establish that trust. Unfortunately, I don’t think we have this documented, I’ll try to make sure that happens.

 

So big picture you should try something like:

manifest.json

{
  ...
  "dataConnectors": [
    {
      ...
      "dataActions": {
        "Import": "",
        "Poll": "",
        "HardRefresh": "" // Add this one
      }
    }
  ]
}

/dataconnectors/index.ts

export const makeDataConnector = (dataConnectorClient: DataConnectorClient) => {
    ...
    return new DataConnector(dataConnectorClient)
        .defineAsynchronousAction(LucidDataConnectorActionNames.Import, importAction)
        .defineAsynchronousAction(LucidDataConnectorActionNames.Poll, pollAction)
        .defineAsynchronousAction(LucidDataConnectorActionNames.HardRefresh, pollAction); // Add this one
};

and then see if it starts working


Reply