Unable to publish state and trigger event in plugin in the initialize function

Hi All,

Please find the code below in the initialise section of the plugin. While I’m able to see the data in an alert but unable to publish to the state and trigger an event.

function(instance, context) {  
/*
 * Subscribe to the EmbeddedApp onPageLoad event before initializing 
 */
     
ZOHO.embeddedApp.on("PageLoad",function(data)
	{
	console.log(data);
	//Custom Bussiness logic goes here
    alert(JSON.stringify(data));    //this is successfully displaying
    
    instance.publishState(pageload_data,JSON.stringify(data));
    instance.triggerEvent("pageload");    
	})    
/*
 * initializing the widget.
 */
ZOHO.embeddedApp.init();    
}

@jared.gibb requesting to pse guide

Put some parenthesis here

1 Like

I’m sure you meant quotes. (code…ewwww :wink:)

3 Likes

@jared.gibb Thanks so much. worked

2 Likes

@jared.gibb whats the best way to return data from client based action in a plugin ? . is there any other way other than updating the state ??? . I have this javascript SDK which has many API calls(>100) , which needs to return data to bubble app. Do you recommend creating so many states to publish in the plugin ?

1 Like

Hahah Yes and thank you :rofl: I said “out loud but I was looking at those stupid parentheses so that’s what I ended up writing. Thanks for pointing that out that will definitely help others in the future

I would recommend you check out this post that they created a while back that covers this topic specifically.

1 Like