Expand my Community achievements bar.

SOLVED

Pass value from context component to context manager

Avatar

Level 5

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); } 
1 Accepted Solution

Avatar

Correct answer by
Level 10

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 %>");

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

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 %>");