(function(){"use strict";if(page.process){page.process.advice={readLinkedRecord:function(e){var i=e.uid;$assert(u8.isValidRecordUid(i),"Failed to read linked BT record! Invalid MA record uid.");var r=$.Deferred();u8.services.crud.readLink({uid:i,linkName:"$Link[BT]"},function(e,i){r.resolve({adviceUid:i.uid})});return r.promise()},createLink:function(e){var i=e.uid,r=e.link,d;$assert(i.infoAreaId==="BT"&&u8.isValidRecordUid(i),"Failed to link BT record! No or invalid BT record uid passed.");$assert(r.infoAreaId==="MA"&&u8.isValidRecordUid(r),"Failed to link BT record! No or invalid MA record uid passed.");var o=$.Deferred();function s(e){u8.services.crud.readFields({uid:i,fields:["StatNo","SeqNo"]},function(i,r){if(r.error){o.resolve({error:"Failed to link advice!"})}else{d=r.values;e()}})}function c(){var e=[{field:"AdviceStatNo",value:d[0]},{field:"AdviceSeqNo",value:d[1]}];u8.services.crud.update({uid:r,fields:e},function(e,i){if(i.error){o.resolve({error:"Failed to link advice!"})}else{o.resolve({success:"Advice linked to activity successfully!"})}})}Function.chain(s,c)();return o.promise()},deleteRecord:function(e){var i=e.uid;$assert(i.infoAreaId==="BT"&&u8.isValidRecordUid(i),"Failed to delete BT record! No or invalid BT record uid passed.");var r=$.Deferred();u8.services.crud.delete_({uid:i},function(e,i){if(i.error){r.resolve({error:"Failed to delete the Advice."})}else{r.resolve({success:"Delete Advice successfully."})}});return r.promise()}}}})();