Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > How to set document name for custom document type based on two custom fields View modes: 
User avatar
Member
Member
joeh42 - 12/13/2011 1:00:13 PM
   
How to set document name for custom document type based on two custom fields
I have a document type custom.JobOpening. There are fields 'company' and 'title'.

I want the document name for all documents of this type to be Company mdash; Title, so I configured the Document name source field to be a new custom field DocumentNameCustom.

I was hoping to use the custom tree handler to populate these field before save. But if I do not enter a value into the 'form' tab of this document, I get the following error:

An error occurred when saving data:[TreeNode.Update]: The NodeName value was not specified. Data cannot be saved.

I tried allowing empty values and setting a default value. I don't believe macros work either (please correct me if wrong).

How can I accomplish this for all of the document types?

User avatar
Certified Developer 9
Certified Developer 9
charbf - 12/13/2011 2:09:41 PM
   
RE:How to set document name for custom document type based on two custom fields
Hi,

Here is what I would do. It might be a bit complex but here it is.

In the doctype definition I would create a 3rd field that would be assigned to the Document Name

At this point you have multiple choices...

1. Use a custom form layout (in the form tab) add some javascript to populate the 3rd field.

2. create a custom Form control and code the some javascript here (lots of exemples in /CMSFormControls (CMSFormControls Doc)

3. Create a custom New and Edit Page for Doctype creation (here you can handle any code/validation) you can use the API to create your document.



Francois



User avatar
Kentico Support
Kentico Support
kentico_jurajo - 12/14/2011 2:11:03 AM
   
RE:How to set document name for custom document type based on two custom fields
Hi,

Or, you can hide the document name field from the form, fill it with some fake default value and then in the custom handler in the OnAfterInsert/Update fill it with data you need.

Or, the above post sounds good too.

Best regards,
Juraj Ondrus