How can I add tab for activity

How can I add a new tab like Activities in this image ??

Reference: Can we create activity tab in RSV (Required site visit) doctype - #2 by NCP

I added the Activity but when I assign task or event give me this error ?

Already provided the reference, so check the code and how it works.