Load Contexthub on conditional basis | Community
Skip to main content
Level 2
May 19, 2020
Solved

Load Contexthub on conditional basis

  • May 19, 2020
  • 1 reply
  • 4206 views

Hi All,

 

I want to load custom contexthub store on basis of some condition and for that, I have used apply method while registering the storeCandidate. The issue here is that I am getting "no suitable store Implementation found for ...." if condition fails. 

Is there any way that I can prevent these error from coming ?

Sample Code:- 

contextHub.Utils.storeCandidates.registerStoreCandidate(
"VariableName",
"contexthub.storeName",
0,

function(){return false};
);

 

Error message -- No suitable store implementation found for type: contexthub.storeName

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by BrianKasingli

@yashaswidotiya,

Sure, you can do this with a JavaScript condition block before you run the "registering the store candidate".

 

function registerStoreCandidate() { if (canRegisterStoreCandidate()) { contextHub.Utils.storeCandidates.registerStoreCandidate( "VariableName", contexthub.storeName, 0) } } function canRegisterStoreCandidate(){ // ...someLogicReturnsBoolean; // example: returns true if window.contexthub && window.contexthub.storeName both are not empty or undefined. return window.contexthub && window.contexthub.storeName; };

 

 

 

1 reply

BrianKasingli
Community Advisor and Adobe Champion
BrianKasingliCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
May 19, 2020

@yashaswidotiya,

Sure, you can do this with a JavaScript condition block before you run the "registering the store candidate".

 

function registerStoreCandidate() { if (canRegisterStoreCandidate()) { contextHub.Utils.storeCandidates.registerStoreCandidate( "VariableName", contexthub.storeName, 0) } } function canRegisterStoreCandidate(){ // ...someLogicReturnsBoolean; // example: returns true if window.contexthub && window.contexthub.storeName both are not empty or undefined. return window.contexthub && window.contexthub.storeName; };

 

 

 

Level 2
May 20, 2020
Thank you for answer.I tried above solution but still I am getting console error.