cancel
Showing results for 
Search instead for 
Did you mean: 

Using customized content model in JavaScript code

lcandido
Champ in-the-making
Champ in-the-making
I'm coding in JavaScript (a .js file at space Data Dictionary/Scripts) and it's necessary to use some customized properties. The code runs fine when using the alfresco.org/model/content/ (cmSmiley Happy that don't need be explicit, but my "dataprev.gov.br/model/contentModelNotaTec" (notatecSmiley Happy does. How to do it? For example:

if (document.properties.title == "Restrito")
{
<code>
}
runs OK, but

if (document.properties.tipoAcesso == "Restrito") //meaning {http://dataprev.gov.br/model/contentModelNotaTec/1.0}tipoAcesso
{
<code>
}
does not.

I'm sure it's necessary to put "notatec:" at some place in this line, but where?

A more general question: How to know the content modeling of a document? In this example, the contentModelNotaTec.xml file has the lines:

<model name="notatec:contentModelNotaTec"

<namespaces>
    <namespace uri="http://www.dataprev.gov.br/model/contentModelNotaTec/1.0" prefix="notatec"/>
</namespaces>
…   

Which document property does save this information or method return it?

Thanks for any help,
2 REPLIES 2

parzgnat
Star Contributor
Star Contributor
The correct syntax is as follows:
document.properties["notatec:tipoAcesso"] = "Restrito";


Hope this helps.

kaynezhang
World-Class Innovator
World-Class Innovator
use the short form

if(document.properties["notatec:tipoAcesso"] == "Restrito"){
}

as Parzgnat said or use fully qualifed namespace form

if(document.properties["{http://www.alfresco.org/model/content/1.0}tipoAcesso"] == "Restrito"){
}