API Questions on Kentico API.
Version 6.x > API > How to automatically change DocumentName after new document created View modes: 
User avatar
Member
Member
rherring-fs.fed - 5/30/2012 10:05:09 AM
   
How to automatically change DocumentName after new document created
What I would like to happen is that when a user creates a new document (i.e. new document from custom document type), I want the documentname value to be the DocumentForeignKeyValue of that custom document type.

I've been trying to figurue out a way to automatically assign a documentname to a new document (i.e. not having the user input that information). I've read through the API documents and it seems I have to use the DocumentEvents.Insert.After += Document_Insert_After hanlder...but I'm not sure of what code I'll need to write.

Any help would be greatly appreciated...I've been stuck on this for a few days now.

Thanks,
Rob


User avatar
Kentico Support
Kentico Support
kentico_jurajo - 5/30/2012 3:25:50 PM
   
RE:How to automatically change DocumentName after new document created
Hi,

the option using custom handler is also possible. You'll need to write the code to get the document foreign key value and then assign it to the document name field. Please, see the API examples in Site Manager -> Support section to see how to work with documents in the API. Or, also in the tree node handler is a sample of code.

The other way could be that you will bind given field to be the source of the document name for given document type. On the Fields tab you can see that under the fields there are two drop downs you can use for this purpose. Or, you can aslo try adding a macro as a default value for given field and disable editing.

Best regards,
Juraj Ondrus