How to get current site details in alfresco repository

cancel
Showing results for 
Search instead for 
Did you mean: 
ratik_singhal
Established Member

How to get current site details in alfresco repository

Hello,

 

In datalist(custom), I am submitting a form (creating 'NewItem' ) and validating that it should not allow saving duplicate based on a property(e.g BatchName).

I know that it's handled by http://localhost:8080/share/proxy/alfresco/api/type/mySmiley Tonguerop/formprocessor. That's why I am overriding form.post.json.js

In form.post.json.js, based on itemId I am doing validation. 

if(itemId == "mySmiley Tonguerop"){
var luceneQuery = "PATH:\"/app:company_home/st:sites/cm:"+siteId+"//*\" AND TYPE:\"mySmiley Tonguerop\" AND @my\\:batchName:\""+selectedValue+"\"";

var result = search.luceneSearch(luceneQuery);
logger.system.out("@ luceneQuery : " + luceneQuery);
logger.system.out("@ Result length: " + result.length);
if(result.length >0){
status.setCode(409, "already exist..");
return;
}
}
persistedObject = formService.saveForm(itemKind, itemId, repoFormData);

But my prob is that I am not able to get the site value here. and I want to check duplicate in the current site. 

Anyway so that I can get the site here ???

'NewItem' of toolbar.js and toolBar.get.html.ftl the method is already overwritten in another datalist.  Hope I cannot override toolbar multiple times. 

1 Reply
jpotts
Professional

Re: How to get current site details in alfresco repository

I cannot answer your question directly because it has been too long since I fooled with form processors. If you had a node ref you could ask the site service which site it belongs to, but I don't think you have a node ref.

But in thinking about your problem, I wonder if it would make more sense from a dev perspective and an end-user perspective to do the check on the Share tier or even from the client-side. You could easily write your own web script that would check for the existence of that value in a give site and you could invoke that from either a Share tier web script or from client-side JavaScript (like in a custom form control, for example).

That would allow you to reject the save much earlier. Just a thought.

Jeff