(function(){page.using=u8.using.merge(page.using,{texts:["net_linktomainperson_text"]});page.wait("Ready",function(){var e=this.url.getUid();var n=$("<div id='output' />").appendTo(document.body);n.html("<b>"+$t("TXT_net_linktomainperson_text_0")+"</b>");u8.services.crud.readFields({uid:e,fields:["MainPersonKey"]},function(i,t){var r=t.values&&t.values[0];if(r){n.utml({template:'<b>{{text "TXT_net_linktomainperson_text_1"}}</b>{{Button({ textId:"TXT_net_linktomainperson_text_3", onClick:onClick })}}',data:{onClick:function(){history.go(-1)}}});return}u8.services.navigation.navigateToPage("Wizard",{Process:"LinkToMainPerson",InfoArea:e.infoAreaId,RecID:e.recordId,Scripts:"crm/pages/LinkToMainPerson.js"},{replace:true})})}.bind(page));page.linkToMainPerson=function(n,i){if(n.recordId===i.recordId){return e({},$t("TXT_net_linktomainperson_text_5"))}u8.request("AccountManagementChannel.LinkToMainPerson",{mainPersonUid:i,personUid:n},function(){u8.services.crud.readFields({uid:i,fields:["MainPersonSystem","MainPersonKey","CoGrp","CoNo","PeGrp","PeNo"]},mainperson_loaded)})};function e(e,n){page.wizard.raiseEvent(0);var i={type:"Error",error:e,message:n};page.wizard.raiseEvent(2,i)}})();