You can try to run the Associate-function after you created your lead, and se if that works out, just provide the guids, relationship name (should be something like "new_new_contatto_Contactid_contact" and the correct schema names in the code below:
// NOTE: Associate Request in Xrm.WebApi supports multiple children, you can add them inside the relatedEntities array
var associateRequest = {
target: { entityType: "contact", id: "11111111-1111-1111-1111-111111111111" },
relatedEntities: [
{ entityType: "new_contatto", id: "11111111-1111-1111-1111-111111111111" }
],
relationship: "new_new_contatto_Contactid_contact",
getMetadata: function () { return { boundParameter: null, parameterTypes: {}, operationType: 2, operationName: "Associate" }; }
};
Xrm.WebApi.execute(associateRequest).then(
function success(response) {
if (response.ok) {
console.log("Success");
}
}
).catch(function (error) {
console.log(error.message);
});
-------------------------------------------------------------------------
If this is the answer for your question, please mark the post as Solved.
If this answer helps you in any way, please give it a like.