We have a cloud page which is used to unsubscribe the records in Marketing cloud. We need to update the "HasOptedOut" field on Contact and a related custom object with a custom field in Sales cloud. This action needs to taken when the email recipient clicks on the Submit button of the landing page.
I know there is a function of Ampscript to update the record in Sales cloud, but I'm not able to implement it as to where and how to use it.
Also, if I need to pass a recordId in the Ampscript of the custom Object which is present in the sendable Data Extention, how can we fetch it in the ampscript and update the custom Object record as well.