Advertisement
Guest User

Untitled

a guest
Aug 25th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. trigger InsertTopic on Account (after insert) {
  2.  
  3. List<TopicAssignment> taList = new List<TopicAssignment>();
  4. List<TopicAssignment> taList1 = new List<TopicAssignment>();
  5. List<Topic> topicList= new List<Topic>();
  6.  
  7. for(Account c : trigger.new)
  8. {
  9. String d1= c.Topics__c; // Custom field on Account Object.
  10. system.debug('aaaaaaaaaa'+d1);
  11. String[] d= d1.split('\s*,\s*');
  12. for(String s: d)
  13. {
  14. Topic ta1 = new Topic();
  15. ta1.Name=s;
  16. topicList.add(ta1);
  17. }
  18. system.debug('aaaaaaaaaa'+topicList);
  19. insert topicList;
  20.  
  21. for(Topic s1: topicList)
  22. {
  23. TopicAssignment ta = new TopicAssignment();
  24. ta.TopicId=s1.Id;
  25. taList.add(ta);
  26. ta.EntityId = c.Id;
  27. }
  28.  
  29. insert taList;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement