cancel
Showing results for 
Search instead for 
Did you mean: 

How to use jsonUtils in a script?

matthew_walters
Champ in-the-making
Champ in-the-making
I'd like to use jsonUtils in a script (not a webscript).

My intent is to convert a javascript object to json.

My understanding is that it's available to webscripts but not scripts.

Is there any way I can configure Alfresco to make it available to regular scripts?
Is there something similar that's already available to regular scripts?

If not, is it possible to call a webscript from a script?  How would I do so?


Thanks,
Matthew
3 REPLIES 3

rjohnson
Star Contributor
Star Contributor
Can you explain what you see as the difference between a webscript and a script? Do you mean using Javascript on the client side (in the browser) or do you mean scripts in Rules and behaviours?

Bob Johnson

By script, I mean a js file that resides in "Data Dictionary\Scripts" and can be set as the script of a rule that 'executes script'

rjohnson
Star Contributor
Star Contributor
I had exactly this problem. According to the documentation jsonUtils should be available in any script that runs in the repository context (alfresco) which unless someone tells me otherwise rule scripts do; except, as you have found, out it isn't available or at least wasn't available in 4.0a (I haven't tried it in 4.2c). See my post

http://forums.alfresco.com/forum/developer-discussions/alfresco-share-development/jsonutils-rules-sc...

which sadly drew no replies.

All you need to do is include the java bean that provides jsonUtils in the configuration of root objects in rules. I never got round to doing this (but I probably will have to soon) so I cannot give you chapter and verse on how you do this (hopefully someone on the forums can do this).

I have added my own objects in rules,so it has to be achievable, but in the end I didn't bother with jsonUtils.

Wish I could be more help; I hope someone can.

Bob Johnson