cancel
Showing results for 
Search instead for 
Did you mean: 

Webscript is not getting executed

udayakumar_p
Confirmed Champ
Confirmed Champ

We have defined a rule which executes the following javascript.

if(document.properties["common:contentStatus"] != null ) {
document.properties["common:createdBy"] = person.properties.userName;
document.properties["common:createdDate"] = date;
document.save();
}

The above script is used to set the created by user and creation date to a common property defined in the model. This scripts needs to be executed whenever a content is created using alfresco share.

The script does not get called when we are trying to create a content from a custom model which has a hidden.ftl field defined in share-config.xml.

Below is a sample configuration.

<appearance>

<field id="cm:content">
<control template="/org/alfresco/components/form/controls/hidden.ftl">
<control-param name="contextProperty">cm:content</control-param>
</control>
</field>

</appearance>

When this field is there, the webscript does not get called. Due to this the created by and created date property is unset. When this field is removed from share-config definition, the webscript gets executed. But we want this field definition.

1. Why is the javascript code not getting executed but gets executed when the field definition is removed?

2. Is the above field configuration correct?

Kindly assist.

6 REPLIES 6

krutik_jayswal
Elite Collaborator
Elite Collaborator

At which time your rule will be triggerred(create ,update etc)?Share-config contains the ui configuration of the forms.So there should not be any impact of it on rule.

One more thing, You have defined hidden.ftl for cm:content field.It does not make sense because, even if you remove this configuration, form will look as it is.It will look save if you include field with hidden.ftl as well.

Hi,

The rule will be triggered during create.

Only when we include cm:content field, mimetype is automatically set as text/plain. We want this to be done otherwise without that field mimetype is set as application/octet-stream.

You can set the mimetype inside the rule.Mimetype is getting decided on the value of cm:content.as hidden.ftl will contain the "" string value it is setting as text/plain.Set the mimtype inside the rule.

Hi,

I was able to set the mimetype with the help of following script.

document.properties["cm:content"].content="";
document.properties["cm:content"].mimetype="text/plain";

This works perfectly fine with 5.2 but not in 5.0. What's the problem with 5.0? Totally stuck with this.

You can set mimetype using below code.

document.mimetype = 'text/plain';

udayakumar_p
Confirmed Champ
Confirmed Champ

Hi,

We tried that approach as recommended here - How to set default mimetype for custom models .

The approach works in 5.2 but not in 5.0.

In 5.0, even though we set the mimetype to text/plain in the rule, somewhere down the line it is getting over written as application/octet-stream.

Is it possible to set cm:content in the webscript? like document.properties.content=""?