cancel
Showing results for 
Search instead for 
Did you mean: 

Add aspect using Client side javascript

suman_nitt
Champ in-the-making
Champ in-the-making
I want to add custom aspect on a content if not added already when i click on document library action.

I used record.jsNode.hasAspect("cm:templatable"), to check whether the content has this aspect already. It worked.

But when i try to add the aspect like record.jsNode.addAspect("cm:templatable"), i get javascript error at client side that "addAspect" method is not available.

I have seen the following examples and this approach not worked for me. I believe all this can happen at server side java script.

var props = new Array(1);
props["cm:template"] = document.nodeRef;
document.addAspect("cm:templatable", props);

props = new Array(1);
props["cm:lockIsDeep"] = true;
document.addAspect("cm:lockable", props);

props = new Array(1);
props["cm:hits"] = 1;
document.addAspect("cm:countable", props);

I am looking for a way to add an aspect using client side javascript.
2 REPLIES 2

afaust
Legendary Innovator
Legendary Innovator
Hello,

there is no way to add an aspect with client side JavaScript without you having to perform an AJAX call on a predefined operation (web script) that implements such a functionality. You can use addAspect in a Repository web script that uses JavaScript for the controller logic, but not on the Share-tier (client JavaScript or Share web script).
As I know of no out-of-the-box web scripts that perform this kind of low-level operation, you would have to write your own. But I would recommend moving your business logic away from the client-side into the Repository backend.

Regards
Axel

suman_nitt
Champ in-the-making
Champ in-the-making
Hi Axel,

Thanks for the response. It was helpful.

Now i created Repository web script and adding aspect to the node with the help of noderef. I am also sending email to group of assignees using this script.

Is it fine that i call Repository web script from share context? How do i pass data like email recipients, noderef to this Repository webscript? Currently i pass as URL parameters. If there is a way to send as JSon data or some other means, please tell me.