Skip to main content
Level 5
Oct 16, 2015 2:26 AM UTC
Solved

Pass value from context component to context manager

Hi

 
I have client context component, which takes emailid. On basis of this email its fetch the data from external system which initialize the session store.
Below is my code for init.js.jsp :
<%
        String leadAddress = properties.get("email", currentStyle.get("email",String.class));
        log.info("leadAddress ---> "+leadAddress);
%>
        if (CQ_Analytics.CCSFDataMgr) {
var email = <%= leadAddress %>;
                CQ_Analytics.CCSFDataMgr.addInitProperty('EMAILADDRESS', email);
                CQ_Analytics.CCSFDataMgr.init();
console.log(email);
        }
console.log doesn't show anything. & kernel's js 
if (!CQ_Analytics.CCSFDataMgr) {
    CQ_Analytics.CCSFDataMgr = new CQ_Analytics.SessionStore();
    CQ_Analytics.CCSFDataMgr.STOREKEY = "CCSFPROFILE";
    CQ_Analytics.CCSFDataMgr.STORENAME = "ccsfprofile";
    CQ_Analytics.CCSFDataMgr.data=  CQ.shared.HTTP.eval("https://ip:8443/bin/service/context.html?email="+this.EMAILADDRESS);
}
 
where this.EMAILADDRESS shows undefined.

 

 Also below code in init.js.jsp shows val null.
 if (CQ_Analytics.CCSFDataMgr) { var val=CQ_Analytics.ClientContext.get("/leadsearch/email",true); alert(val); } 
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Sham_HC
Sham_HCAccepted solution
Level 10
Oct 16, 2015 2:26 AM UTC

From your implementation the javascript variable "email" is scoped within if block and can't access outside if block and hence this.EMAILADDRESS shows undefined. Try with [1].

[1]    CQ_Analytics.CCSFDataMgr.data=  CQ.shared.HTTP.eval(" https://ip:8443/bin/service/context.html?email="+"<%= leadAddress %>");

1 reply

Sham_HC
Sham_HCAccepted solution
Level 10
Oct 16, 2015 2:26 AM UTC

From your implementation the javascript variable "email" is scoped within if block and can't access outside if block and hence this.EMAILADDRESS shows undefined. Try with [1].

[1]    CQ_Analytics.CCSFDataMgr.data=  CQ.shared.HTTP.eval(" https://ip:8443/bin/service/context.html?email="+"<%= leadAddress %>");
Translate