Trigger Create_Doc on Knowledge__kav (After insert) {
list<id> ids = new list<id>();
For(Knowledge__kav k : trigger.new)
{
ids.add (k.Id);
}
list<Knowledge__kav> recs = [select Upload__Name__s, Upload__ContentType__s, Upload__Length__s, Upload__Body__s from Knowledge__kav where id =: ids];
for(Knowledge__kav k1 : recs)
{
Document doc = new Document();
doc.Name = k1.Upload__Name__s;
doc.FolderId = '00l2v000002hABpAAM'; // Document folder id
doc.Body = k1.Upload__Body__s;
doc.ContentType = k1.Upload__ContentType__s;
doc.Type = k1.Upload__ContentType__s;
insert doc;
}
}
As I've created one article name "upload file3" with file type attachment "test.txt"
After Update this article file type attachment "text.txt" is inserted in document with folder public images
No comments:
Post a Comment