Hi Carlo,
Yes this is possible to do. It does require custom code to do this.
Also be sure to think about what happens if someone edits the SharePoint list item created or edited by InfoPath and if you need that updated in the InfoPath form too, in which case you need to handle that in your code.
Our qRules product can do this: http://www.qdabra.com/en/products/qRules.aspx and there is a demo video on that page showing how it's done.
qRules would save you time over writing your own code since it already has the code done.
Hope that helps
Ted